Build with Maven 3.9.6 #1876
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
pull_request: | |
branches: | |
- '**' | |
types: | |
- opened | |
- synchronize | |
push: | |
branches: | |
- main | |
workflow_call: {} | |
workflow_dispatch: {} | |
jobs: | |
linting: | |
name: Linting | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Initialize Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: 21 | |
cache: 'maven' | |
- name: Run Maven checks | |
shell: bash | |
run: >- | |
./mvnw -B -U | |
-DskipTests=true | |
-Dmaven.main.skip | |
-Dmaven.jar.skip | |
-Dmaven.resources.skip | |
-Dmaven.test.skip | |
verify | |
- name: Run ShellCheck | |
uses: ludeeus/action-shellcheck@master | |
with: | |
check_together: 'yes' | |
scandir: './scripts' | |
- name: Validate codecov.yml | |
continue-on-error: false | |
if: always() | |
shell: bash | |
run: curl --fail -vv --data-binary @codecov.yml https://codecov.io/validate | |
build: | |
name: Build on JDK ${{ matrix.java-version }} (${{ matrix.os-name }}) | |
runs-on: ${{ matrix.os-name }} | |
needs: | |
- linting | |
strategy: | |
fail-fast: false | |
max-parallel: 6 | |
matrix: | |
os-name: [ubuntu-latest] | |
java-version: | |
- 11 | |
- 12 | |
- 13 | |
- 14 | |
- 15 | |
- 16 | |
- 17 | |
- 18 | |
- 19 | |
- 20 | |
- 21 | |
include: | |
# MacOS builds (only check one version). | |
- os-name: macos-latest | |
java-version: 21 | |
# Windows builds (only check one version). | |
- os-name: windows-latest | |
java-version: 21 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Initialize JDK | |
uses: actions/setup-java@v4 | |
with: | |
cache: maven | |
check-latest: true | |
distribution: zulu | |
java-version: ${{ matrix.java-version }} | |
- name: Install dependencies | |
shell: bash | |
run: |- | |
source "./scripts/common.sh" | |
# Ensure consistent versions of tools we use. MacOS uses an outdated version of bash, for | |
# example. | |
case "${OSTYPE}" in | |
win*|msys*) | |
run <<< "choco install xsltproc" | |
;; | |
darwin*) | |
run <<< "brew install bash libxslt" | |
;; | |
linux*) | |
run <<< "sudo apt-get update -q" | |
run <<< "sudo apt-get install xsltproc -qy" | |
;; | |
*) | |
warn "Unknown OS type '${OSTYPE}'. Update build.yaml with a new case." | |
;; | |
esac | |
- name: Dump system and JDK info | |
shell: bash | |
run: |- | |
source "./scripts/common.sh" | |
function report() { | |
info "${1}:" | |
run <<< "${2}" | |
echo | |
} | |
report "System" "uname -a" | |
report "JRE/JVM" "java -version" | |
report "JDK" "javac -version" | |
report "Maven" "./mvnw -v" | |
- name: Compile and run tests | |
shell: bash | |
run: ./mvnw -B -U -Dcheckstyle.skip=true -Dlicense.skip=true clean verify | |
- name: Annotate test reports with build environment info | |
if: always() | |
shell: bash | |
run: >- | |
scripts/prepare-test-outputs-for-merge.sh | |
-j "${{ matrix.java-version }}" | |
-o "${{ matrix.os-name }}" | |
# Compress first so that the collection job later takes far less time (order of a few minutes | |
# or so). GitHub does not compress these until after the workflow finishes, meaning when | |
# we unstash them to produce the coverage reports, it will make an HTTP call for every single | |
# file. This can take several minutes and is somewhat painful to have to wait for. | |
- name: Compress test and coverage reports into tarball | |
if: always() | |
shell: bash | |
run: |- | |
set -x | |
# Allow globs to not match anything without causing errors. | |
shopt -s nullglob | |
# XZ with max compression, more efficient than using GZip. | |
XZ_OPT=-9 tar -Jcvf reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tar.xz \ | |
$(find . -name surefire-reports -o -name failsafe-reports) \ | |
$(find . -name 'jacoco.xml') | |
- name: Stash reports tarball | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: reports-${{ matrix.java-version }}-${{ matrix.os-name }} | |
if-no-files-found: error | |
path: reports-${{ matrix.java-version }}-${{ matrix.os-name }}.tar.xz | |
retention-days: 30 | |
publish-test-reports: | |
name: Publish test reports | |
runs-on: ubuntu-latest | |
if: always() | |
needs: | |
- build | |
- linting | |
permissions: | |
checks: write | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# Needed to keep actions working correctly. | |
fetch-depth: 2 | |
- name: Download stashed tarballs | |
uses: actions/download-artifact@v3 | |
with: | |
path: 'artifacts/reports-*.tar.xz' | |
- name: Decompress stashed report tarballs | |
shell: bash | |
run: |- | |
find artifacts/ -name "reports-*.tar.xz" -exec tar -Jxvf {} \; | |
find artifacts/ -name "reports-*.tar.xz" -exec rm -v {} \; | |
- name: Publish test results | |
continue-on-error: true | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
action_fail: false | |
check_run_annotations: "skipped tests" | |
deduplicate_classes_by_file_name: true | |
json_test_case_results: true | |
json_thousands_separator: "," | |
junit_files: "**/TEST-*.xml" | |
report_individual_runs: false | |
test_changes_limit: 500 | |
time_unit: "milliseconds" | |
- name: Publish to codecov | |
continue-on-error: true | |
if: always() | |
shell: bash | |
run: |- | |
curl --fail https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring \ | |
--keyring trustedkeys.gpg --import | |
curl --fail -Os https://uploader.codecov.io/latest/linux/codecov | |
curl --fail -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM | |
curl --fail -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig | |
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM | |
shasum -a 256 -c codecov.SHA256SUM | |
chmod -v +x codecov | |
./codecov -v | |
generate-documentation: | |
name: Generate documentation | |
runs-on: ubuntu-latest | |
needs: | |
- linting | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Initialize Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
# Must use >= JDK 17 for JavaDocs to generate correctly. | |
java-version: 21 | |
cache: 'maven' | |
- name: Generate JavaDocs | |
shell: bash | |
run: >- | |
./mvnw -B -U -am -pl java-compiler-testing | |
-Dmaven.test.skip=true | |
-Dcheckstyle.skip=true | |
-Dlicense.skip=true | |
clean compile javadoc:jar | |
- name: Upload JavaDocs as a build artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: java-compiler-testing/target/apidocs | |
publish-documentation: | |
name: Publish documentation | |
# Do not run multiple builds at once, as it can fail. | |
concurrency: | |
cancel-in-progress: true | |
group: snapshot-javadocs | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' | |
permissions: | |
pages: write | |
id-token: write | |
needs: | |
- generate-documentation | |
- build | |
steps: | |
- name: Deploy JavaDocs build artifact to GitHub Pages | |
id: snapshot-javadocs | |
uses: actions/deploy-pages@v2 | |
- name: Delete temporary artifacts | |
uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: github-pages | |
failOnError: false |