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.
This commit is contained in:
Eric Anderson 2021-06-17 13:32:56 -07:00 committed by GitHub
parent 6201db2d96
commit 79e75bace4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 66 deletions

63
.github/workflows/testing.yml vendored Normal file
View File

@ -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

3
.gitignore vendored
View File

@ -39,3 +39,6 @@ bin
# ARM tests
qemu-arm-static
# Temporary output dir for artifacts
mvn-artifacts

View File

@ -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

View File

@ -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