| name: Continuous integration | |
| on: | |
| merge_group: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| # Cancel in-progress runs for pull requests, but not for master branch pushes or merge queue | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: "Build and test on ${{ matrix.os }}" | |
| strategy: | |
| matrix: | |
| include: | |
| - os: macos-latest | |
| - os: windows-latest | |
| - os: ubuntu-latest | |
| fail-fast: false | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Check out NullAway sources | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: 'Set up JDK 28 EA from jdk.java.net' | |
| uses: oracle-actions/setup-java@fff43251af9936a0e6a4d5d0946e14f1680e9b6b # v1.5.0 | |
| with: | |
| website: jdk.java.net | |
| release: 28 | |
| - name: 'Set up JDKs' | |
| uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 | |
| with: | |
| java-version: | | |
| 17 | |
| 21 | |
| 25 | |
| distribution: 'temurin' | |
| check-latest: 'true' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 | |
| - name: List toolchains | |
| run: ./gradlew javaToolchains | |
| - name: Check formatting | |
| run: ./gradlew spotlessCheck | |
| - name: Check compilation | |
| run: ./gradlew assemble compileTestJava | |
| - name: Build and test | |
| # The preceding Spotless and compilation tasks are up to date, while build still guarantees | |
| # that every lifecycle and custom verification task runs. | |
| run: ./gradlew build | |
| env: | |
| # The Linux build produces the execution data consumed by the Codecov aggregation step. | |
| # Keep ordinary macOS and Windows test runs free of JaCoCo instrumentation overhead. | |
| ORG_GRADLE_PROJECT_enableJacoco: ${{ matrix.os == 'ubuntu-latest' && 'true' || 'false' }} | |
| ORG_GRADLE_PROJECT_cribro.diffCoverageEnabled: ${{ matrix.os == 'ubuntu-latest' && 'true' || 'false' }} | |
| - name: Run shellcheck | |
| run: ./gradlew shellcheck | |
| if: runner.os == 'Linux' | |
| - name: Aggregate jacoco coverage | |
| id: jacoco_report | |
| run: ./gradlew codeCoverageReport | |
| env: | |
| # Use the same test-task configuration as the preceding Linux build so its JaCoCo | |
| # execution data remains up-to-date and is included in the aggregate XML report. | |
| ORG_GRADLE_PROJECT_enableJacoco: 'true' | |
| continue-on-error: true | |
| if: runner.os == 'Linux' && github.repository == 'uber/NullAway' | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 | |
| with: | |
| files: ./code-coverage-report/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml | |
| # Each module also writes a jacocoTestReport.xml for diff coverage; upload the aggregate only. | |
| disable_search: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| if: steps.jacoco_report.outcome == 'success' | |
| - name: Cleanup Codecov temporary files | |
| run: | | |
| # See https://github.com/codecov/codecov-action/issues/1851 | |
| rm -rf codecov codecov.SHA256SUM codecov.SHA256SUM.sig | |
| if: steps.jacoco_report.outcome == 'success' | |
| - name: Test publishToMavenLocal flow | |
| env: | |
| ORG_GRADLE_PROJECT_VERSION_NAME: '0.0.0.1-LOCAL' | |
| ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: 'false' | |
| run: ./gradlew publishToMavenLocal | |
| - name: Check that Git tree is clean after build and test | |
| run: ./.buildscript/check_git_clean.sh | |
| suppression-remover-regression-tests: | |
| name: "Suppression remover regression tests" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out NullAway sources | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 | |
| with: | |
| python-version: '3.15' | |
| cache: 'pip' | |
| cache-dependency-path: scripts/nullaway-suppression-remover/pyproject.toml | |
| - name: Install suppression remover test dependencies | |
| working-directory: scripts/nullaway-suppression-remover | |
| run: python -m pip install --editable '.[test]' | |
| - name: Run suppression remover regression tests | |
| working-directory: scripts/nullaway-suppression-remover | |
| run: python -m pytest | |
| test-with-error-prone-snapshot: | |
| name: "Test with Error Prone snapshot" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout this repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: 'Set up Default JDK' | |
| uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 | |
| with: | |
| java-version: 25 | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 | |
| - name: Test with Error Prone snapshot | |
| run: ./gradlew testErrorProneLatestSnapshot | |
| compile-other-projects: | |
| name: "Build ${{ matrix.project }} with snapshot" | |
| strategy: | |
| fail-fast: false | |
| # Each project builds at a pinned commit, so a change upstream cannot fail an unrelated | |
| # NullAway PR. Renovate moves sha to the tip of branch; .github/third-party/README.md explains | |
| # how to patch a project whose fix upstream has not merged yet. | |
| # build runs in the project checkout, with use-snapshot.gradle.kts copied there and | |
| # NULLAWAY_VERSION set to the snapshot that publishToMavenLocal installed. A Gradle build takes | |
| # the snapshot through the init script; a Maven build passes NULLAWAY_VERSION to the property | |
| # its pom.xml reads the NullAway version from. Renovate's regex expects project, url, branch, | |
| # and sha in that order, so build goes after sha. | |
| matrix: | |
| include: | |
| - project: caffeine | |
| url: https://github.com/ben-manes/caffeine.git | |
| branch: master | |
| sha: 10646b00c14a7837fe16a16a2a7b1f82e5fa3155 | |
| build: JAVA_VERSION=26 ./gradlew --init-script use-snapshot.gradle.kts compileAllJava | |
| - project: spring-framework | |
| url: https://github.com/spring-projects/spring-framework.git | |
| branch: main | |
| sha: 9f642a3937adb5606412b90e9a5c18907e7d9387 | |
| build: ./gradlew --init-script use-snapshot.gradle.kts compileAllJava | |
| - project: junit-framework | |
| url: https://github.com/junit-team/junit-framework.git | |
| branch: main | |
| sha: 12f007f531867169baefe4483b7d7e5dd15acc77 | |
| build: ./gradlew --init-script use-snapshot.gradle.kts compileAllJava | |
| - project: spring-boot | |
| url: https://github.com/spring-projects/spring-boot.git | |
| branch: main | |
| sha: 8552ac1799bd5b889a48ce858ba1d744f8fe0348 | |
| build: ./gradlew --init-script use-snapshot.gradle.kts compileAllJava | |
| - project: reactor-core | |
| url: https://github.com/reactor/reactor-core.git | |
| branch: main | |
| sha: 8f7ab9da896298cd7a9a2fd9deb7bada68bb3688 | |
| build: ./gradlew --init-script use-snapshot.gradle.kts compileAllJava | |
| - project: spring-batch | |
| url: https://github.com/spring-projects/spring-batch.git | |
| branch: main | |
| sha: 84bc35860494ae34d1236c995bc504c3798a96d5 | |
| build: ./mvnw -B -ntp -nsu -Dnullaway.version="$NULLAWAY_VERSION" -Dspring-javaformat.skip=true test-compile | |
| - project: vavr | |
| url: https://github.com/vavr-io/vavr.git | |
| branch: main | |
| sha: ca7ed065129bea815f57cfae16e28985741d8d69 | |
| build: JAVA_HOME="$JAVA_HOME_21_X64" ./mvnw -B -ntp -nsu -Pnullaway -Dnullaway.version="$NULLAWAY_VERSION" -Dspotless.skip=true compile | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout this repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: 'Set up JDKs' | |
| uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 | |
| with: | |
| java-version: | # JDK 26 needed for Caffeine | |
| 21 | |
| 26 | |
| 25 | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 | |
| - name: Publish to Maven Local | |
| env: | |
| ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: 'false' | |
| run: ./gradlew publishToMavenLocal | |
| - name: Check out ${{ matrix.project }} at the pinned commit | |
| env: | |
| PROJECT: ${{ matrix.project }} | |
| URL: ${{ matrix.url }} | |
| SHA: ${{ matrix.sha }} | |
| run: | | |
| git init "/tmp/$PROJECT" | |
| git -C "/tmp/$PROJECT" fetch --depth 1 "$URL" "$SHA" | |
| git -C "/tmp/$PROJECT" checkout --detach FETCH_HEAD | |
| - name: Apply patches to ${{ matrix.project }} | |
| env: | |
| PROJECT: ${{ matrix.project }} | |
| run: .github/third-party/apply-patches.sh ".github/third-party/$PROJECT" "/tmp/$PROJECT" | |
| - name: Run ${{ matrix.project }} build | |
| env: | |
| PROJECT: ${{ matrix.project }} | |
| BUILD: ${{ matrix.build }} | |
| run: | | |
| cp .github/workflows/use-snapshot.gradle.kts "/tmp/$PROJECT" | |
| NULLAWAY_VERSION="$(sed -n 's/^VERSION_NAME=//p' gradle.properties)" | |
| export NULLAWAY_VERSION | |
| cd "/tmp/$PROJECT" | |
| eval "$BUILD" | |
| publish-snapshot: | |
| name: Publish snapshot to Maven Central | |
| needs: | |
| - build | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'uber/NullAway' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out NullAway sources | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Set up JDK | |
| uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 | |
| with: | |
| java-version: 25 | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0 | |
| - name: Verify snapshot version | |
| run: grep -Eq '^VERSION_NAME=.*-SNAPSHOT$' gradle.properties | |
| - name: Publish snapshot | |
| env: | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USER_TOKEN_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_USER_TOKEN_PASSWORD }} | |
| ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: 'false' | |
| run: ./gradlew publishToMavenCentral |