Skip to content

Commit 9ec8832

Browse files
authored
Merge pull request #4859 from evolvedbinary/improve/githubactions
Use mvnd in GitHub Actions
2 parents 4f7bc7e + 7020674 commit 9ec8832

File tree

2 files changed

+100
-4
lines changed

2 files changed

+100
-4
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: 'install-mvnd'
2+
description: 'Install the Maven Daemon'
3+
inputs:
4+
version:
5+
description: 'The version of the Maven Daemon to install'
6+
required: true
7+
default: '0.9.0'
8+
file-version-suffix:
9+
description: 'A suffix to append to the version of the download file of Maven Daemon to install'
10+
required: false
11+
default: ''
12+
install-path:
13+
description: 'The folder in which Maven Daemon will be installed as a sub-folder'
14+
required: true
15+
default: '/tmp'
16+
cache:
17+
description: 'Set to true to cache Maven Daemon artifacts per-platform-architecture'
18+
required: true
19+
default: 'true'
20+
mvnd-connect-timeout:
21+
description: 'The timeout (as a duration, e.g. `90 seconds`) for connecting to the Maven Daemon'
22+
required: true
23+
default: '90 seconds'
24+
outputs:
25+
mvnd-dir:
26+
description: "The directory where the command mvnd is located"
27+
value: ${{ steps.mvnd-location.outputs.mvnd-dir }}
28+
runs:
29+
using: "composite"
30+
steps:
31+
- name: Determine mvnd platform and architecture
32+
shell: bash
33+
run: |
34+
if [ "$RUNNER_OS" == "Linux" ]; then
35+
MVND_PLATFORM="linux"
36+
elif [ "$RUNNER_OS" == "macOS" ]; then
37+
MVND_PLATFORM="darwin"
38+
elif [ "$RUNNER_OS" == "Windows" ]; then
39+
MVND_PLATFORM="windows"
40+
else
41+
"echo Unknown platform: $RUNNER_OS"
42+
exit 1
43+
fi
44+
MVND_ARCHITECTURE="amd64"
45+
echo "MVND_PLATFORM=${MVND_PLATFORM}" >> $GITHUB_ENV
46+
echo "MVND_ARCHITECTURE=${MVND_ARCHITECTURE}" >> $GITHUB_ENV
47+
echo "MVND_NAME=maven-mvnd-${{ inputs.version }}${{ inputs.file-version-suffix }}-${MVND_PLATFORM}-${MVND_ARCHITECTURE}" >> $GITHUB_ENV
48+
- name: Cache mvnd
49+
if: inputs.cache == 'true'
50+
id: cache-mvnd
51+
uses: actions/cache@v3
52+
with:
53+
path: |
54+
${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip
55+
${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip.sha256
56+
${{ inputs.install-path }}/${{ env.MVND_NAME }}
57+
key: setup-${{ env.MVND_NAME }}
58+
- name: Download mvnd
59+
if: steps.cache-mvnd.outputs.cache-hit != 'true'
60+
shell: bash
61+
run: |
62+
curl -fsSL -o ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/${{ env.MVND_NAME }}.zip
63+
curl -fsSL -o ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip.sha256 https://archive.apache.org/dist/maven/mvnd/${{ inputs.version }}/${{ env.MVND_NAME }}.zip.sha256
64+
- name: Install sha256sum (macOS)
65+
if: ${{ runner.os == 'macOS' }}
66+
shell: bash
67+
run: brew install coreutils
68+
- name: Verify mvnd sha256 checksum
69+
shell: bash
70+
run: echo "$(cat ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip.sha256) ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip" | sha256sum --check
71+
- name: Unzip mvnd
72+
if: steps.cache-mvnd.outputs.cache-hit != 'true'
73+
shell: bash
74+
run: unzip ${{ inputs.install-path }}/${{ env.MVND_NAME }}.zip -d ${{ inputs.install-path }}/
75+
- name: Show Maven Daemon version
76+
shell: bash
77+
run: |
78+
${{ inputs.install-path }}/${{ env.MVND_NAME }}/bin/mvnd -D'mvnd.connectTimeout=${{ inputs.mvnd-connect-timeout }}' --version
79+
${{ inputs.install-path }}/${{ env.MVND_NAME }}/bin/mvnd -D'mvnd.connectTimeout=${{ inputs.mvnd-connect-timeout }}' --status
80+
- name: Set mvnd-dir
81+
id: mvnd-location
82+
shell: bash
83+
run: |
84+
MVND_BIN_DIR="${{ inputs.install-path }}/${{ env.MVND_NAME }}/bin"
85+
if [ "$RUNNER_OS" == "Windows" ]; then
86+
MVND_BIN_DIR="$(cygpath --absolute --long-name --windows $MVND_BIN_DIR)"
87+
fi
88+
echo "MVND_BIN_DIR=${MVND_BIN_DIR}" >> $GITHUB_ENV
89+
echo "mvnd-dir=${MVND_BIN_DIR}" >> $GITHUB_OUTPUT

.github/workflows/ci-test.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,22 @@ jobs:
4545
distribution: temurin
4646
java-version: ${{ env.DEV_JDK }}
4747
cache: 'maven'
48+
- name: Install Maven Daemon
49+
id: install-mvnd
50+
uses: ./.github/actions/install-mvnd
51+
with:
52+
version: '1.0-m6'
53+
file-version-suffix: '-m40'
54+
cache: 'true'
4855
- name: Maven Build
4956
timeout-minutes: 10
50-
run: mvn -V -B -T 1C compile test-compile -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
57+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B -T 1C compile test-compile -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
5158
- name: Maven Test
5259
timeout-minutes: 60
53-
run: mvn -V -B verify -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
60+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B verify -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
5461
- name: Javadoc (Linux only)
5562
if: ${{ matrix.os == 'ubuntu-latest' }}
56-
run: mvn -V -B -q -T 1C install javadoc:javadoc -DskipTests -D'dependency-check.skip' -D'license.skip' --projects '!exist-distribution,!exist-installer' --also-make
63+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B -q -T 1C install javadoc:javadoc -DskipTests -D'dependency-check.skip' -D'license.skip' --projects '!exist-distribution,!exist-installer' --also-make
5764
- name: Maven Code Coverage (Develop branch on Linux only)
5865
if: ${{ github.ref == 'refs/heads/develop' && matrix.os == 'ubuntu-latest' }}
5966
env:
@@ -62,7 +69,7 @@ jobs:
6269
CI_BUILD_NUMBER: ${{ github.run_id }}
6370
CI_BUILD_URL: https://github.com/${{ github.repository }}/commit/${{ github.event.after }}/checks
6471
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
65-
run: mvn -V -B jacoco:report coveralls:report
72+
run: ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd -V -B jacoco:report coveralls:report
6673
- name: Archive build logs
6774
if: always()
6875
uses: actions/upload-artifact@v3

0 commit comments

Comments
 (0)