diff --git a/.github/workflows/_check-compliance.yml b/.github/workflows/_check-compliance.yml new file mode 100644 index 000000000..2b32288d1 --- /dev/null +++ b/.github/workflows/_check-compliance.yml @@ -0,0 +1,46 @@ +on: + workflow_call: {} + +jobs: + compliance: + name: Check Compliance + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Initialize Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 17 + cache: 'maven' + + - name: Run checks + run: >- + ./mvnw + -B + -Pdependency-scan + -T8 + -U + --no-transfer-progress + -DskipTests=true + -Dstyle.color=always + -Dmaven.main.skip + -Dmaven.jar.skip + -Dmaven.resources.skip + -Dmaven.test.skip + -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 + verify + + - name: Archive Dependency Scan reports + uses: actions/upload-artifact@v3 + if: always() + with: + name: dependency-scan-report + path: | + **/target/dependency-check-report.html + retention-days: 30 diff --git a/.github/workflows/_generate-javadocs.yml b/.github/workflows/_generate-javadocs.yml new file mode 100644 index 000000000..f695dfd65 --- /dev/null +++ b/.github/workflows/_generate-javadocs.yml @@ -0,0 +1,37 @@ +on: + workflow_call: {} + +jobs: + generate-javadocs: + name: Generate + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Initialize Java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + # Must use >= JDK 17 for JavaDocs to generate correctly. + java-version: 17 + cache: 'maven' + + - name: Generate JavaDocs + run: >- + ./mvnw + -B + -T8 + -U + -pl java-compiler-testing + --also-make + --no-transfer-progress + -Dmaven.test.skip=true + -Dcheckstyle.skip=true + -Dlicense.skip=true + -Dstyle.color=always + -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 + clean compile javadoc:jar diff --git a/.github/workflows/_publish_snapshot.yml b/.github/workflows/_publish_snapshot.yml new file mode 100644 index 000000000..9296a9ac1 --- /dev/null +++ b/.github/workflows/_publish_snapshot.yml @@ -0,0 +1,51 @@ +on: + workflow_call: {} + +jobs: + github: + name: "Deploy Snapshot to GitHub" + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + pages: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Initialize JDK + uses: actions/setup-java@v3 + with: + distribution: zulu + # Must use >= JDK 17 for Javadocs to generate correctly. + java-version: 17 + + - name: Build and deploy Maven artifacts + run: >- + ./mvnw + -B + -T4C + --no-transfer-progress + -pl java-compiler-testing + --also-make + -Dmaven.source.includePom=true + -Dmaven.test.skip=true + -Dstyle.color=always + -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 + clean install javadoc:jar source:jar deploy + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Upload JavaDocs as a build artifact + uses: actions/upload-pages-artifact@v1 + with: + path: java-compiler-testing/target/apidocs + + - name: Deploy JavaDocs build artifact to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/.github/workflows/_run-tests.yml b/.github/workflows/_run-tests.yml new file mode 100644 index 000000000..e8212502d --- /dev/null +++ b/.github/workflows/_run-tests.yml @@ -0,0 +1,123 @@ +on: + workflow_call: {} + workflow_dispatch: {} + +jobs: + run-tests: + strategy: + fail-fast: false + matrix: + os-name: + - ubuntu-latest + java-version: + - 11 + - 12 + - 13 + - 14 + - 15 + - 16 + - 17 + - 18 + - 19 + # Mockito currently does not support this distribution. + # - 20-ea + include: + - os-name: macos-latest + java-version: 11 + - os-name: windows-latest + java-version: 11 + + name: Tests - JDK ${{ matrix.java-version }} - ${{ matrix.os-name }} + runs-on: ${{ matrix.os-name }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Initialize JDK + uses: actions/setup-java@v3 + with: + cache: maven + check-latest: true + distribution: zulu + java-version: ${{ matrix.java-version }} + + - name: Compile and run tests + run: >- + ./mvnw + -B + -T8 + -U + --no-transfer-progress + '-Dcheckstyle.skip=true' + '-Dlicense.skip=true' + '-Dstyle.color=always' + '-Dmaven.wagon.httpconnectionManager.ttlSeconds=120' + clean verify + + - name: Annotate test reports with build environment info + if: always() + run: >- + scripts/prepare-test-outputs-for-merge.sh + ${{ matrix.java-version }} + ${{ matrix.os-name }} + + - name: Archive Surefire and Jacoco reports + uses: actions/upload-artifact@v3 + if: always() + with: + name: reports-java-${{ matrix.java-version }}-${{ matrix.os-name }} + path: |- + **/target/surefire-reports/*.xml + **/target/surefire-reports/*.txt + **/target/site/jacoco/jacoco*.xml + retention-days: 5 + + publish-test-reports: + name: Publish test reports + runs-on: ubuntu-latest + if: always() + needs: + - run-tests + + permissions: + checks: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + # Needed to keep actions working correctly. + fetch-depth: 2 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: 'artifacts/' + + - name: Publish to codecov + continue-on-error: true + if: always() + 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 + + - name: Publish unit test results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + continue-on-error: true + with: + json_test_case_results: true + json_thousands_separator: "," + junit_files: "artifacts/**/TEST-*.xml" + report_individual_runs: true + time_unit: "milliseconds" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb4f530e1..c95635204 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,223 +1,20 @@ -name: Latest +name: Build main branch on: push: branches: [ main ] - schedule: - # Run a build once per week on the main branch. - - cron: "0 0 * * 0" jobs: - build: - name: Build - JDK ${{ matrix.java-version }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }}-latest - - strategy: - fail-fast: false - matrix: - os: [ ubuntu ] - java-version: - - 11 - - 12 - - 13 - - 14 - - 15 - - 16 - - 17 - - 18 - - 19 - # Mockito currently does not support this distribution. - # - 20-ea - build-script: [ './mvnw' ] - include: - - os: windows - build-script: './mvnw.cmd' - java-version: '11' - - os: macos - build-script: './mvnw' - java-version: '11' - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - # Needed to keep actions working correctly. - fetch-depth: 2 - - - name: Initialize JDK - uses: actions/setup-java@v3 - with: - cache: 'maven' - check-latest: true - distribution: 'zulu' - java-version: '${{ matrix.java-version }}' - - - name: Compile and run tests - run: >- - ${{ matrix.build-script }} - -B - -T8 - -U - --no-transfer-progress - '-Dcheckstyle.skip=true' - '-Dlicense.skip=true' - '-Dstyle.color=always' - '-Dmaven.wagon.httpconnectionManager.ttlSeconds=120' - clean verify - - - name: Annotate test reports with build environment info - if: always() - run: >- - scripts/prepare-test-outputs-for-merge.sh - ${{ matrix.java-version }} - ${{ matrix.os }} - - - name: Archive Surefire and Jacoco reports - uses: actions/upload-artifact@v3 - if: always() - with: - name: reports-java-${{ matrix.java-version }}-${{ matrix.os }} - path: | - **/target/surefire-reports/*.xml - **/target/surefire-reports/*.txt - **/target/site/jacoco/jacoco*.xml - retention-days: 5 - - report-test-results-and-coverage: - name: Report test results and coverage - needs: [ build ] - runs-on: ubuntu-latest - if: always() - permissions: - checks: write - pull-requests: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - # Needed to keep actions working correctly. - fetch-depth: 2 - - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: 'artifacts/' - - - name: Publish to codecov - continue-on-error: true - if: always() - 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 - - - name: Publish unit test results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - continue-on-error: true - with: - json_test_case_results: true - json_thousands_separator: "," - junit_files: "artifacts/**/TEST-*.xml" - report_individual_runs: true - time_unit: "milliseconds" - + tests: + name: Tests + uses: ./.github/workflows/_run-tests.yml javadocs: - name: Generate JavaDocs - runs-on: ubuntu-latest - needs: [ report-test-results-and-coverage, compliance ] - if: github.event_name != 'schedule' - - permissions: - contents: read - pages: write - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Initialize Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - # We have to use >= 15 for now, as assertj causes JDK 14 and older to prevent linking - # documentation correctly. I have opened an issue on GitHub with AssertJ to discuss - # this being generated correctly: https://github.com/assertj/assertj-core/issues/2573. - java-version: '19' - cache: 'maven' - - - name: Generate JavaDocs - run: >- - ./mvnw - -B - -T8 - -U - -pl java-compiler-testing - --also-make - --no-transfer-progress - -Dmaven.test.skip=true - -Dcheckstyle.skip=true - -Dlicense.skip=true - -Dstyle.color=always - -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 - clean compile javadoc:jar - - - name: Upload JavaDocs to GitHub Pages - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - uses: actions/upload-pages-artifact@v1 - with: - path: java-compiler-testing/target/apidocs - - - name: Deploy JavaDocs to GitHub Pages - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - id: deployment - uses: actions/deploy-pages@v1 - + name: JavaDocs + uses: ./.github/workflows/_generate-javadocs.yml compliance: - name: Check Compliance - runs-on: ubuntu-latest - needs: [ build ] - if: ${{ github.event_name != 'schedule' }} - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Initialize Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '19' - cache: 'maven' - - - name: Run checks - run: >- - ./mvnw - -B - -Pdependency-scan - -T8 - -U - --no-transfer-progress - -DskipTests=true - -Dstyle.color=always - -Dmaven.main.skip - -Dmaven.jar.skip - -Dmaven.resources.skip - -Dmaven.test.skip - -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 - verify - - - name: Archive Dependency Scan reports - uses: actions/upload-artifact@v3 - if: always() - with: - name: dependency-scan-report - path: | - **/target/dependency-check-report.html - retention-days: 30 + name: Compliance + uses: ./.github/workflows/_check-compliance.yml + publish-snapshot: + name: Publish Snapshot + needs: [ compliance, javadocs, tests ] + uses: ./.github/workflows/_publish_snapshot.yml + secrets: inherit diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bf453d5a6..fbd9dc959 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,168 +1,16 @@ -name: PR +name: Build PR on: pull_request: branches: [ "**" ] types: [ opened, synchronize ] jobs: - build: - name: Build - JDK ${{ matrix.java-version }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }}-latest - - strategy: - fail-fast: false - matrix: - os: [ ubuntu ] - java-version: - - 11 - - 12 - - 13 - - 14 - - 15 - - 16 - - 17 - - 18 - - 19 - # Mockito currently does not support this distribution. - # - 20-ea - build-script: [ './mvnw' ] - include: - - os: windows - build-script: './mvnw.cmd' - java-version: '11' - - os: macos - build-script: './mvnw' - java-version: '11' - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - # Needed to keep actions working correctly. - fetch-depth: 2 - - - name: Initialize JDK - uses: actions/setup-java@v3 - with: - cache: 'maven' - check-latest: true - distribution: 'zulu' - java-version: '${{ matrix.java-version }}' - - - name: Compile and run tests - run: >- - ${{ matrix.build-script }} - -B - -T8 - -U - --no-transfer-progress - '-Dcheckstyle.skip=true' - '-Dlicense.skip=true' - '-Dstyle.color=always' - '-Dmaven.wagon.httpconnectionManager.ttlSeconds=120' - clean verify - - - name: Annotate test reports with build environment info - if: always() - run: >- - scripts/prepare-test-outputs-for-merge.sh - ${{ matrix.java-version }} - ${{ matrix.os }} - - - name: Archive Surefire and Jacoco reports - uses: actions/upload-artifact@v3 - if: always() - with: - name: reports-java-${{ matrix.java-version }}-${{ matrix.os }} - path: | - **/target/surefire-reports/*.xml - **/target/surefire-reports/*.txt - **/target/site/jacoco/jacoco*.xml - retention-days: 5 - - report-test-results-and-coverage: - name: Report test results and coverage - needs: [ build ] - runs-on: ubuntu-latest - if: always() - permissions: - checks: write - pull-requests: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - # Needed to keep actions working correctly. - fetch-depth: 2 - - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - path: 'artifacts/' - - - name: Publish to codecov - continue-on-error: true - if: always() - 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 - - - name: Publish unit test results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - continue-on-error: true - with: - json_test_case_results: true - json_thousands_separator: "," - junit_files: "artifacts/**/TEST-*.xml" - report_individual_runs: true - time_unit: "milliseconds" - + tests: + name: Tests + uses: ./.github/workflows/_run-tests.yml + javadocs: + name: JavaDocs + uses: ./.github/workflows/_generate-javadocs.yml compliance: - name: Check Compliance - runs-on: ubuntu-latest - needs: [ build ] - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Initialize Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '19' - cache: 'maven' - - - name: Run checks - run: >- - ./mvnw - -B - -Pdependency-scan - -T8 - -U - --no-transfer-progress - -DskipTests=true - -Dstyle.color=always - -Dmaven.main.skip - -Dmaven.jar.skip - -Dmaven.resources.skip - -Dmaven.test.skip - -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 - verify - - - name: Archive Dependency Scan reports - uses: actions/upload-artifact@v3 - if: always() - with: - name: dependency-scan-report - path: | - **/target/dependency-check-report.html - retention-days: 30 + name: Compliance + uses: ./.github/workflows/_check-compliance.yml diff --git a/acceptance-tests/pom.xml b/acceptance-tests/pom.xml index 70c995649..0fb824796 100644 --- a/acceptance-tests/pom.xml +++ b/acceptance-tests/pom.xml @@ -32,6 +32,7 @@ true + true true true true diff --git a/pom.xml b/pom.xml index e30e38037..4db0a758c 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ 2022 + https://github.com/${project-slug} @@ -23,10 +24,18 @@ + + + github + GitHub Packages + https://maven.pkg.github.com/${project-slug} + + + Apache License v2.0 - ${project.scm-url}/blob/main/LICENSE.txt + ${project.url}/blob/main/LICENSE.txt @@ -36,9 +45,9 @@ - scm:git:${project-scm-url} - scm:git:${project-scm-url} - scm:git:${project-scm-url} + scm:git:${project.url} + scm:git:${project.url} + scm:git:${project.url} HEAD @@ -63,6 +72,7 @@ 4.1 3.2.0 3.10.1 + 3.0.0 3.3.0 3.4.1 3.0.0-M7 @@ -99,8 +109,8 @@ 2022 - https://github.com/ascopes - ${project.organization.url}/java-compiler-testing + + ascopes/java-compiler-testing @@ -206,6 +216,16 @@ + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + true + + + org.apache.maven.plugins maven-jar-plugin