[英]GitHub Action: How to fix mvn: command not found issue with nektos/act
我目前正在為 GitHub 項目做貢獻。
為此,我在 GitHub Action 中編寫了一個 GitHub 工作流程來測試 JavaDoc 文件的創建。
此工作流程應與act一起運行。
GitHub 的項目 當我想添加這個 GitHub 工作流程時: https://github.com/MathieuSoysal/Javadoc-publisher.yml
問題是,當我使用 act 執行 GitHub 工作流時,出現此錯誤。
[Test Actions/Test with Java 11] 🚀 Start image=catthehacker/ubuntu:act-latest
[Test Actions/Test with Java 11] 🐳 docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=false
[Test Actions/Test with Java 11] 🐳 docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Test Actions/Test with Java 11] 🐳 docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Test Actions/Test with Java 11] ☁ git clone 'https://github.com/GuillaumeFalourd/assert-command-line-output' # ref=v2
[Test Actions/Test with Java 11] ⭐ Run Pre GuillaumeFalourd/assert-command-line-output@v2
[Test Actions/Test with Java 11] ☁ git clone 'https://github.com/actions/setup-node' # ref=v2
[Test Actions/Test with Java 11] ✅ Success - Pre GuillaumeFalourd/assert-command-line-output@v2
[Test Actions/Test with Java 11] ⭐ Run Main actions/checkout@v3
[Test Actions/Test with Java 11] 🐳 docker cp src=/workspaces/Javadoc-publisher.yml/. dst=/workspaces/Javadoc-publisher.yml
[Test Actions/Test with Java 11] ✅ Success - Main actions/checkout@v3
[Test Actions/Test with Java 11] ⭐ Run Main ./
[Test Actions/Test with Java 11] ⭐ Run Main actions/checkout@v3
[Test Actions/Test with Java 11] 🐳 docker cp src=/workspaces/Javadoc-publisher.yml/. dst=/workspaces/Javadoc-publisher.yml
[Test Actions/Test with Java 11] ✅ Success - Main actions/checkout@v3
[Test Actions/Test with Java 11] ☁ git clone 'https://github.com/actions/setup-java' # ref=v3
[Test Actions/Test with Java 11] ⭐ Run Main actions/setup-java@v3
[Test Actions/Test with Java 11] 🐳 docker cp src=/home/codespace/.cache/act/actions-setup-java@v3/ dst=/var/run/act/actions/actions-setup-java@v3/
[Test Actions/Test with Java 11] 🐳 docker exec cmd=[node /var/run/act/actions/actions-setup-java@v3/dist/setup/index.js] user= workdir=
[Test Actions/Test with Java 11] ❓ ::group::Installed distributions
| Trying to resolve the latest version from remote
| Resolved latest version as 11.0.17+8
| Trying to download...
| Downloading Java 11.0.17+8 (Adopt-Hotspot) from https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.17%2B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.17_8.tar.gz ...
[Test Actions/Test with Java 11] 💬 ::debug::Downloading https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.17%252B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.17_8.tar.gz
[Test Actions/Test with Java 11] 💬 ::debug::Destination /tmp/8533ad34-250e-4794-b6bd-f014648ce8b2
[Test Actions/Test with Java 11] 💬 ::debug::download complete
| Extracting Java archive...
[Test Actions/Test with Java 11] 💬 ::debug::Checking tar --version
[Test Actions/Test with Java 11] 💬 ::debug::tar (GNU tar) 1.30%0ACopyright (C) 2017 Free Software Foundation, Inc.%0ALicense GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.%0AThis is free software: you are free to change and redistribute it.%0AThere is NO WARRANTY, to the extent permitted by law.%0A%0AWritten by John Gilmore and Jay Fenlason.
| [command]/usr/bin/tar xz --warning=no-unknown-keyword -C /tmp/4f3b749d-13d5-497d-87d7-45e30a9927cc -f /tmp/8533ad34-250e-4794-b6bd-f014648ce8b2
[Test Actions/Test with Java 11] 💬 ::debug::Caching tool Java_Adopt_jdk 11.0.17-8 x64
[Test Actions/Test with Java 11] 💬 ::debug::source dir: /tmp/4f3b749d-13d5-497d-87d7-45e30a9927cc/jdk-11.0.17+8
[Test Actions/Test with Java 11] 💬 ::debug::destination /opt/hostedtoolcache/Java_Adopt_jdk/11.0.17-8/x64
[Test Actions/Test with Java 11] 💬 ::debug::finished caching tool
| Java 11.0.17+8 was downloaded
| Setting Java 11.0.17+8 as the default
| Creating toolchains.xml for JDK version 11 from adopt
| Writing to /root/.m2/toolchains.xml
|
| Java configuration:
| Distribution: adopt
| Version: 11.0.17+8
| Path: /opt/hostedtoolcache/Java_Adopt_jdk/11.0.17-8/x64
|
[Test Actions/Test with Java 11] ❓ ::endgroup::
[Test Actions/Test with Java 11] ❓ ##[add-matcher]/run/act/actions/actions-setup-java@v3/.github/java.json
| Creating settings.xml with server-id: github
| Writing to /root/.m2/settings.xml
[Test Actions/Test with Java 11] ✅ Success - Main actions/setup-java@v3
[Test Actions/Test with Java 11] ⚙ ::set-output:: distribution=Adopt-Hotspot
[Test Actions/Test with Java 11] ⚙ ::set-output:: path=/opt/hostedtoolcache/Java_Adopt_jdk/11.0.17-8/x64
[Test Actions/Test with Java 11] ⚙ ::set-output:: version=11.0.17+8
[Test Actions/Test with Java 11] ⭐ Run Main Generate Javadoc
[Test Actions/Test with Java 11] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1-composite-2.sh] user= workdir=
| /var/run/act/workflow/1-composite-2.sh: line 2: mvn: command not found
[Test Actions/Test with Java 11] ❌ Failure - Main Generate Javadoc
[Test Actions/Test with Java 11] exitcode '127': command not found, please refer to https://github.com/nektos/act/issues/107 for more information
[Test Actions/Test with Java 11] ☁ git clone 'https://github.com/JamesIves/github-pages-deploy-action' # ref=v4.4.0
[Test Actions/Test with Java 11] ❌ Failure - Main ./
[Test Actions/Test with Java 11] exitcode '127': command not found, please refer to https://github.com/nektos/act/issues/107 for more information
[Test Actions/Test with Java 11] ⭐ Run Post ./
[Test Actions/Test with Java 11] ⭐ Run Post actions/setup-java@v3
[Test Actions/Test with Java 11] 🐳 docker exec cmd=[node /var/run/act/actions/actions-setup-java@v3/dist/cleanup/index.js] user= workdir=
[Test Actions/Test with Java 11] ✅ Success - Post actions/setup-java@v3
[Test Actions/Test with Java 11] ✅ Success - Post ./
[Test Actions/Test with Java 11] 🏁 Job failed
GitHub 工作流程
我的 GitHub 工作流程:
name: Test Actions
on: [pull_request, push]
jobs:
test:
runs-on: ubuntu-latest
name: Test with Java 11
steps:
- uses: actions/checkout@v3
- uses: ./ # Uses an action in the root directory
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
javadoc-branch: javadoc-test
java-version: 11
target-folder: javadoc
- uses: GuillaumeFalourd/assert-command-line-output@v2
with:
command_line: ls -lha
contains: javadoc
expected_result: PASSED
GitHub 行動
項目的GitHub Action: https://github.com/MathieuSoysal/Javadoc-publisher.yml/blob/main/action.yml
命令
運行 nektos/act 的執行命令: act
有人知道我們如何解決這個問題mvn: command not found issue
with nektos/act嗎?
您的問題是由於您使用 nektos/act 的圖像沒有 mvn。
您有多種修復方法。
第一種解決方案:如果你想保持你的形象。
您可以在 GitHub 工作流程中添加這些行以添加 mvn:
#### This step is only needed for GHA local runner, act:
# https://github.com/nektos/act
- name: Install curl (for nektos/act local CI testing)
run: apt-get update && apt-get install build-essential curl pkg-config openssl -y
- name: Download Maven
run: |
curl -sL https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip -o maven.zip
apt-get update
apt-get -y install unzip
unzip -d /usr/share maven.zip
rm maven.zip
ln -s /usr/share/apache-maven-3.6.3/bin/mvn /usr/bin/mvn
echo "M2_HOME=/usr/share/apache-maven-3.6.3" | tee -a /etc/environment
####
第二種解決方案:如果您同意更改您使用過的圖像。
您可以執行以下命令,而不是您的act
命令:
act -P ubuntu-latest=quay.io/jamezp/act-maven
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.