From 79e75bace40cea7e4be72e7dcd1f41c3ad6ee857 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 17 Jun 2021 13:32:56 -0700 Subject: [PATCH] Port from Travis-CI to GitHub Actions Travis-CI no longer has a free tier (only a free trial). That was a major reason we used Travis-CI, so that external contributors would be able to run the CI on their forks. Iterating on a Travis config in a personal repo was also quite convenient. The other reason was that Travis-CI was safe to run even with untrusted code. Since the introduction of the permissions field in workflows, GitHub Actions appears safe to run untrusted code and has a free tier for external contributors. GitHub Actions and Google Cloud Build are the main contenders for a Kokoro replacement, but Cloud Build isn't safe for untrusted code. Instead of migrating to Travis-CI.com from Travis-CI.org, let's migrate to GitHub Actions and gain some familiarity. I've really appreciated Travis-CI.org and have wanted to pay for it for years but wasn't about to give it write permission to the repo. I'm disappointed to migrate off it, now that the permissions issues have been sorted out. --- .github/workflows/testing.yml | 63 +++++++++++++++++++++++++++++++++ .gitignore | 3 ++ .travis.yml | 65 ----------------------------------- buildscripts/kokoro/unix.sh | 5 ++- 4 files changed, 70 insertions(+), 66 deletions(-) create mode 100644 .github/workflows/testing.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000000..0bcced9889c --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,63 @@ +name: GitHub Actions Linux Testing + +on: + push: + branches: + - master + - 'v1.*' + pull_request: + schedule: + - cron: '54 19 * * SUN' # weekly at a "random" time + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + jre: [8, 11] + fail-fast: false # Should swap to true if we grow a large matrix + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + java-version: ${{ matrix.jre }} + distribution: 'adopt' + + - name: Gradle cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Maven cache + uses: actions/cache@v2 + with: + path: | + ~/.m2/repository + !~/.m2/repository/io/grpc + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'build.gradle') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Protobuf cache + uses: actions/cache@v2 + with: + path: /tmp/protobuf-cache + key: ${{ runner.os }}-maven-${{ hashFiles('buildscripts/make_dependencies.sh') }} + + - name: Build + run: buildscripts/kokoro/unix.sh + - name: Check for modified codegen + run: test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false) + + - name: Coveralls + if: matrix.jre == 8 # Upload once, instead of for each job in the matrix + run: ./gradlew :grpc-all:coveralls -x compileJava + - name: Codecov + uses: codecov/codecov-action@v1 diff --git a/.gitignore b/.gitignore index f12cbdfe51f..9fd0d7fb574 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ bin # ARM tests qemu-arm-static + +# Temporary output dir for artifacts +mvn-artifacts diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4a37defdafb..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,65 +0,0 @@ -language: java - -env: - global: - - GRADLE_OPTS=-Xmx512m - - LDFLAGS=-L/tmp/protobuf/lib - - CXXFLAGS=-I/tmp/protobuf/include - - LD_LIBRARY_PATH=/tmp/protobuf/lib - -before_install: - - rm ~/.m2/settings.xml || true # Avoid repository.apache.org, which has QPS limits and is useless - - mkdir -p $HOME/.gradle/caches && - ln -s /tmp/gradle-caches-modules-2 $HOME/.gradle/caches/modules-2 - - mkdir -p $HOME/.gradle && - ln -s /tmp/gradle-wrapper $HOME/.gradle/wrapper - - buildscripts/make_dependencies.sh # build protoc into /tmp/protobuf - - mkdir -p $HOME/.gradle - - echo "checkstyle.ignoreFailures=false" >> $HOME/.gradle/gradle.properties - - echo "failOnWarnings=true" >> $HOME/.gradle/gradle.properties - - echo "errorProne=true" >> $HOME/.gradle/gradle.properties - - echo "skipAndroid=true" >> $HOME/.gradle/gradle.properties - -install: - - ./gradlew assemble syncGeneratedSources publishToMavenLocal - - pushd examples && ./gradlew build && popd - - pushd examples && mvn verify && popd - - pushd examples/example-alts && ../gradlew build && popd - - pushd examples/example-hostname && ../gradlew build && popd - - pushd examples/example-hostname && mvn verify && popd - - pushd examples/example-tls && ../gradlew clean build && popd - - pushd examples/example-xds && ../gradlew build && popd - -before_script: - - test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false) - -script: - - ./gradlew check :grpc-all:jacocoTestReport - -after_success: - # Upload to coveralls once, instead of for each job in the matrix - - if [[ "$TRAVIS_JOB_NUMBER" == *.1 ]]; then ./gradlew :grpc-all:coveralls; fi - - bash <(curl -s https://codecov.io/bash) - -os: - - linux - -dist: xenial - -jdk: - - openjdk8 - - openjdk11 - -notifications: - email: false - -cache: - directories: - - /tmp/protobuf-cache - - /tmp/gradle-caches-modules-2 - - /tmp/gradle-wrapper - -before_cache: - # The lock changes based on folder name; normally $HOME/.gradle/caches/modules-2/modules-2.lock - - rm /tmp/gradle-caches-modules-2/gradle-caches-modules-2.lock - - find $HOME/.gradle/wrapper -not -name "*-all.zip" -and -not -name "*-bin.zip" -delete diff --git a/buildscripts/kokoro/unix.sh b/buildscripts/kokoro/unix.sh index faa9a6afe1d..1de35827809 100755 --- a/buildscripts/kokoro/unix.sh +++ b/buildscripts/kokoro/unix.sh @@ -57,13 +57,16 @@ if [[ -z "${SKIP_TESTS:-}" ]]; then exit 1 fi # Run tests - ./gradlew build $GRADLE_FLAGS + ./gradlew build :grpc-all:jacocoTestReport $GRADLE_FLAGS pushd examples ./gradlew clean $GRADLE_FLAGS ./gradlew build $GRADLE_FLAGS # --batch-mode reduces log spam mvn verify --batch-mode popd + pushd examples/example-alts + ../gradlew build $GRADLE_FLAGS + popd pushd examples/example-hostname ../gradlew build $GRADLE_FLAGS mvn verify --batch-mode