Skip to content

Commit

Permalink
Merge branch 'master' into spring-mockito
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner authored Sep 20, 2023
2 parents 48ce4e2 + 70af259 commit e158336
Show file tree
Hide file tree
Showing 93 changed files with 3,457 additions and 841 deletions.
2 changes: 2 additions & 0 deletions .buildscript/check_git_clean.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh -eux

if [ -n "$(git status --porcelain)" ]; then
echo 'warning: source tree contains uncommitted changes; .gitignore patterns may need to be fixed'
git status
Expand Down
4 changes: 4 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
codecov:
# Disable report age checking since hits in the build cache can lead to an old timestamp
max_report_age: off

69 changes: 42 additions & 27 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,78 @@ jobs:
matrix:
include:
- os: ubuntu-latest
java: 8
java: 11
epVersion: 2.4.0
- os: ubuntu-latest
java: 11
java: 17
epVersion: 2.4.0
- os: macos-latest
java: 11
epVersion: 2.18.0
epVersion: 2.21.1
- os: ubuntu-latest
java: 11
epVersion: 2.18.0
epVersion: 2.21.1
- os: windows-latest
java: 11
epVersion: 2.18.0
epVersion: 2.21.1
- os: ubuntu-latest
java: 17
epVersion: 2.18.0
epVersion: 2.21.1
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Check out NullAway sources
uses: actions/checkout@v3
- name: 'Set up JDK 21 so it is available'
uses: actions/setup-java@v3
with:
java-version: '21-ea'
distribution: 'temurin'
- name: 'Set up JDK 17 on Windows'
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
if: matrix.os == 'windows-latest'
- name: 'Set up JDK ${{ matrix.java }}'
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Build and test using Java 8 and Error Prone ${{ matrix.epVersion }}
- name: Build and test using Java ${{ matrix.java }} and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
uses: gradle/gradle-build-action@v2
with:
arguments: build
if: matrix.java == '8'
- name: Build and test using Java 11 and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
- name: Run shellcheck
uses: gradle/gradle-build-action@v2
with:
arguments: verGJF build
if: matrix.java == '11'
- name: Build and test using Java 17 and Error Prone ${{ matrix.epVersion }}
arguments: shellcheck
if: runner.os == 'Linux'
- name: Aggregate jacoco coverage
id: jacoco_report
uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
uses: gradle/gradle-build-action@v2
with:
arguments: build -x :sample-app:build -x :jar-infer:jar-infer-lib:build -x :jar-infer:nullaway-integration-test:build -x :jar-infer:test-java-lib-jarinfer:build
if: matrix.java == '17'
- name: Report jacoco coverage
uses: gradle/gradle-build-action@v2
arguments: codeCoverageReport
continue-on-error: true
if: runner.os == 'Linux' && matrix.java == '11' && matrix.epVersion == '2.21.1' && github.repository == 'uber/NullAway'
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ./code-coverage-report/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml
if: steps.jacoco_report.outcome == 'success'
- name: Test publishToMavenLocal flow
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
ORG_GRADLE_PROJECT_VERSION_NAME: '0.0.0.1-LOCAL'
ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: 'false'
uses: gradle/gradle-build-action@v2
with:
arguments: coveralls
continue-on-error: true
if: runner.os == 'Linux' && matrix.java == '11' && matrix.epVersion == '2.18.0' && github.repository == 'uber/NullAway'
arguments: publishToMavenLocal
if: matrix.java == '11'
- name: Check that Git tree is clean after build and test
run: ./.buildscript/check_git_clean.sh
publish_snapshot:
Expand All @@ -81,15 +96,15 @@ jobs:
steps:
- name: 'Check out repository'
uses: actions/checkout@v3
- name: 'Set up JDK 8'
- name: 'Set up JDK 11'
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: 'temurin'
- name: 'Publish'
uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_mavenCentralRepositoryUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralRepositoryPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
with:
arguments: clean publish --no-daemon --no-parallel
11 changes: 11 additions & 0 deletions .github/workflows/gcloud_ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# This script is used to run commands on a Google Cloud instance via SSH

# Define the variables for Google Cloud project, zone, username, and instance
PROJECT_ID="ucr-ursa-major-sridharan-lab"
ZONE="us-central1-a"
USER="root"
INSTANCE="nullway-jmh"

gcloud compute ssh --project=$PROJECT_ID --zone=$ZONE $USER@$INSTANCE --command="$1"
20 changes: 20 additions & 0 deletions .github/workflows/get_repo_details.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# This script retrieves the repository and branch details of a GitHub pull request

# Assign command line arguments to variables
# GH_TOKEN is the GitHub authentication token
# PR_NUMBER is the number of the pull request
# REPO_NAME is the name of the repository
GH_TOKEN="$1"
PR_NUMBER="$2"
REPO_NAME="$3"

PR_DETAILS=$(curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/repos/$REPO_NAME/pulls/$PR_NUMBER")

REPO_FULL_NAME=$(echo "$PR_DETAILS" | jq -r .head.repo.full_name)
BRANCH_NAME=$(echo "$PR_DETAILS" | jq -r .head.ref)

# Export vars to GITHUB_ENV so they can be used by later scripts
echo "REPO_FULL_NAME=$REPO_FULL_NAME" >> "$GITHUB_ENV"
echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_ENV"
73 changes: 73 additions & 0 deletions .github/workflows/jmh-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This GitHub Actions workflow runs JMH benchmarks when a new comment is created on a pull request
name: Run JMH Benchmarks for Pull Request

on:
issue_comment: # This workflow triggers when a comment is created
types: [created]

# Only allow one instance of JMH benchmarking to be running at any given time
concurrency: all

jobs:
benchmarking:
# Only run this job if a comment on a pull request contains '/benchmark' and is a PR on the uber/NullAway repository
if: github.event.issue.pull_request && contains(github.event.comment.body, '/benchmark') && github.repository == 'uber/NullAway'
runs-on: ubuntu-latest
permissions: write-all

steps:
- name: Add reaction
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ github.event.comment.id }}
reactions: '+1'

- name: Checkout repository
uses: actions/checkout@v3

- name: Set branch name
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x ./.github/workflows/get_repo_details.sh
./.github/workflows/get_repo_details.sh "${{ secrets.GITHUB_TOKEN }}" "${{ github.event.issue.number }}" "${{ github.repository }}"
- id: 'auth'
name: Authenticating
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY_1 }}'

- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1

- name: Start VM
run: gcloud compute instances start nullway-jmh --zone=us-central1-a

- name: Run benchmarks
run: |
chmod +x ./.github/workflows/run_gcp_benchmarks.sh
./.github/workflows/run_gcp_benchmarks.sh
- name: Cleanup
# Delete the branch directory on the Google Cloud instance
if: always()
run: |
./.github/workflows/gcloud_ssh.sh " export BRANCH_NAME=${BRANCH_NAME} && rm -r -f $BRANCH_NAME"
- name: Formatting Benchmark # Create a text file containing the benchmark results
run: |
(echo 'Main Branch:'; echo '```' ; cat main_text.txt; echo '```'; echo 'With This PR:'; echo '```' ; cat pr_text.txt; echo '```') > benchmark.txt
- name: Comment Benchmark
uses: mshick/add-pr-comment@v2
if: always() # This step is for adding the comment
with:
message-path: benchmark.txt # The path to the message file to leave as a comment
message-id: benchmark
- name: Stop VM
if: always()
run: gcloud compute instances stop nullway-jmh --zone=us-central1-a



20 changes: 20 additions & 0 deletions .github/workflows/run_gcp_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# This script is responsible for running benchmarks for a GitHub pull request and the main branch on Google Cloud Compute Engine (GCCE).


chmod +x ./.github/workflows/gcloud_ssh.sh
./.github/workflows/gcloud_ssh.sh "export BRANCH_NAME=${BRANCH_NAME} && mkdir $BRANCH_NAME"

# Using gcloud compute scp to copy the bash scripts that will run the benchmarks onto the GCCE
gcloud compute scp ./.github/workflows/run_pr_benchmarks.sh root@nullway-jmh:"$BRANCH_NAME/" --zone=us-central1-a
gcloud compute scp ./.github/workflows/run_main_benchmarks.sh root@nullway-jmh:"$BRANCH_NAME/" --zone=us-central1-a

# Running the benchmark script for the pull request branch and main branch on GCCE
./.github/workflows/gcloud_ssh.sh " export BRANCH_NAME=${BRANCH_NAME} && export REPO_NAME=${REPO_FULL_NAME} && chmod +x $BRANCH_NAME/run_pr_benchmarks.sh && $BRANCH_NAME/run_pr_benchmarks.sh && cd && chmod +x $BRANCH_NAME/run_main_benchmarks.sh && $BRANCH_NAME/run_main_benchmarks.sh"

# Copying the benchmark results from GCCE back to the Github runner for the PR branch
gcloud compute scp root@nullway-jmh:"$BRANCH_NAME/pr/NullAway/jmh/build/results/jmh/results.txt" ./pr_text.txt --zone=us-central1-a

# Copying the benchmark results from GCCE back to the Github runner for the main branch
gcloud compute scp root@nullway-jmh:"$BRANCH_NAME/main/NullAway/jmh/build/results/jmh/results.txt" ./main_text.txt --zone=us-central1-a
9 changes: 9 additions & 0 deletions .github/workflows/run_main_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -eux

cd "$BRANCH_NAME/"
mkdir main
cd main/
git clone [email protected]:Uber/NullAway.git
cd NullAway/

./gradlew jmh --no-daemon
9 changes: 9 additions & 0 deletions .github/workflows/run_pr_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -eux

cd "$BRANCH_NAME/"
mkdir pr
cd pr/
git clone --branch "$BRANCH_NAME" --single-branch [email protected]:"$REPO_NAME".git NullAway
cd NullAway/

./gradlew jmh --no-daemon
83 changes: 83 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,88 @@
Changelog
=========
Version 0.10.14
---------------
IMPORTANT: This version introduces EXPERIMENTAL JDK21 support.
* Bump Checker Framework dependency to 3.38.0 (#819)
- Note: Not just an internal implementation change. Needed to support JDK 21!
* Treat parameter of generated Record.equals() methods as @Nullable (#825)
* Build / CI tooling for NullAway itself:
- Fixes Codecov Report Expired error (#821)
- Updated Readme.md with Codecov link (#823)
- Remove ASM-related hack in build config (#824)
- Run tests on JDK 21 (#826)

Version 0.10.13
---------------
* Allow library models to define custom stream classes (#807)
* Avoid suggesting castToNonNull fixes in certain cases (#799)
* Ensure castToNonNull insertion/removal suggested fixes do not remove comments (#815)
* Support for JSpecify's 0.3.0 annotation [experimental]
- Generics checks for method overriding (#755)
- Make GenericsChecks methods static (#805)
- Add visitors for handling different types in generic type invariance check (#806)
* Build / CI tooling for NullAway itself:
- Bump versions for some dependencies (#800)
- Update to WALA 1.6.2 (#798)
- Update to Error Prone 2.21.1 (#797)
- Enable contract checking when building NullAway (#802)
- Bump Error Prone Gradle Plugin version (#804)
- Modify JMH Benchmark Workflow For Shellcheck (#813)
- Bump gradle maven publish plugin from 0.21.0 to 0.25.3 (#810)
- Use Spotless to enforce consistent formatting for Gradle build scripts (#809)
- Remove unnecessary compile dependence for jar-infer-cli (#816)
- Added Codecov to CI Pipeline (#820)

Version 0.10.12
---------------
Note: This is the first release built with Java 11. In particular, running
JarInfer now requires a JDK 11 JVM. NullAway is still capable of analyzing JDK 8
source/target projects, and should be compatible with the Error Prone JDK 9 javac
just as the release before, but a JDK 11 javac is recommended.
* Update to WALA 1.6.1 and remove ability to build on JDK 8 (#777)
* Fix compatibility issue when building on JDK 17 but running on JDK 8 (#779)
* Fix JDK compatibility issue in LombokHandler (#795)
* Improve auto-fixing of unnecessary castToNonNull calls (#796)
* Support for JSpecify's 0.3.0 annotation [experimental]
- JSpecify: avoid crashes when encountering raw types (#792)
- Fix off-by-one error in JSpecify checking of parameter passing (#793)
* Build / CI tooling for NullAway itself:
- Fix Publish Snapshot CI job (#774)
- Add step to create release on GitHub (#775)
- Build the Android sample app on JDK 17 (#776)
- Update to Error Prone 2.20.0 (#772)
- Add tasks to run JDK 8 tests on JDK 11+ (#778)
- Switch to Spotless for formatting Java code (#780)
- Added GCP JMH Benchmark Workflow (#770)
- Set concurrency for JMH benchmarking workflow (#784)
- Disable daemon when running benchmarks (#786)
- Update to Gradle 8.2.1 (#781)

Version 0.10.11
---------------
* NULL_LITERAL expressions may always be null (#749)
* Fix error in Lombok generated code for @Nullable @Builder.Default (#765)
* Support for specific libraries/APIs:
- Added support for Apache Validate (#769)
- Introduce FluentFutureHandler as a workaround for Guava FluentFuture (#771)
* Internal code refactorings:
- [Refactor] Pass resolved Symbols into Handler methods (#729)
- Prepare for Nullable ASTHelpers.getSymbol (#733)
- Refactor: streamline mayBeNullExpr flow (#753)
- Refactor LibraryModelsHandler.onOverrideMayBeNullExpr (#754)
- Refactor simple onOverrideMayBeNullExpr handlers (#747)
* Support for JSpecify's 0.3.0 annotation [experimental]
- JSpecify generics checks for conditional expressions (#739)
- Generics checks for parameter passing (#746)
- Clearer printing of types in errors related to generics (#758)
* NullAwayInfer/Annotator data serialization support [experimental]
- Update path serialization for class files (#752)
* Build / CI tooling for NullAway itself:
- Update to Gradle 8.0.2 (#743)
- Fix CI on Windows (#759)
- Upgrade to Error Prone 2.19.1 (#763)
- Upgrade maven publish plugin to 0.21.0 (#773)

Version 0.10.10
---------------
* Add command line option to skip specific library models. (#741)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## NullAway: Fast Annotation-Based Null Checking for Java [![Build Status](https://github.com/uber/nullaway/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/uber/nullaway/actions/workflows/continuous-integration.yml) [![Coverage Status](https://coveralls.io/repos/github/uber/NullAway/badge.svg?branch=master)](https://coveralls.io/github/uber/NullAway?branch=master)
## NullAway: Fast Annotation-Based Null Checking for Java [![Build Status](https://github.com/uber/nullaway/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/uber/nullaway/actions/workflows/continuous-integration.yml) [![Coverage Status](https://codecov.io/github/uber/NullAway/coverage.svg?branch=master)](https://codecov.io/github/uber/NullAway?branch=master)

NullAway is a tool to help eliminate `NullPointerException`s (NPEs) in your Java code. To use NullAway, first add `@Nullable` annotations in your code wherever a field, method parameter, or return value may be `null`. Given these annotations, NullAway performs a series of type-based, local checks to ensure that any pointer that gets dereferenced in your code cannot be `null`. NullAway is similar to the type-based nullability checking in the Kotlin and Swift languages, and the [Checker Framework](https://checkerframework.org/) and [Eradicate](https://fbinfer.com/docs/checker-eradicate/) null checkers for Java.

Expand All @@ -23,7 +23,7 @@ plugins {
}
dependencies {
annotationProcessor "com.uber.nullaway:nullaway:0.10.10"
annotationProcessor "com.uber.nullaway:nullaway:0.10.13"
// Optional, some source of nullability annotations.
// Not required on Android if you use the support
Expand Down Expand Up @@ -75,7 +75,7 @@ The configuration for an Android project is very similar to the Java case, with

```gradle
dependencies {
annotationProcessor "com.uber.nullaway:nullaway:0.10.10"
annotationProcessor "com.uber.nullaway:nullaway:0.10.13"
errorprone "com.google.errorprone:error_prone_core:2.4.0"
errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}
Expand Down
Loading

0 comments on commit e158336

Please sign in to comment.