diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000000..43550ffde1 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,74 @@ +on: + push: + branches: + - master + pull_request: +name: ci +jobs: + build: + runs-on: ubuntu-latest + container: gcr.io/gapic-images/googleapis-bazel:20210105 + # Dockerfile for this image: https://github.com/googleapis/googleapis-discovery/blob/master/Dockerfile + # If you update its version, please also update it below in + # 'Cache Bazel files' - unfortunately it cannot accept variables at this + # time. + + strategy: + matrix: + java: [8, 11] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - run: java -version + + - name: Bazel File Cache Setup + id: cache-bazel + uses: actions/cache@v2 + with: + path: ~/.cache/bazel + key: ${{ runner.os }}-bazel-20210105-${{ secrets.CACHE_VERSION }} + + - name: Bazel Cache Not Found + if: steps.cache-bazel.outputs.cache-hit != 'true' + run: | + echo "No cache found." + - name: Bazel Cache Found + if: steps.cache-bazel.outputs.cache-hit == 'true' + run: | + echo -n "Cache found. Cache size: " + du -sh ~/.cache/bazel + echo "If the cache seems broken, update the CACHE_VERSION secret in" + echo "https://github.com/googleapis/googleapis-discovery/settings/secrets/actions" + echo "(use any random string, any GUID will work)" + echo "and it will start over with a clean cache." + echo "The old one will disappear after 7 days." + + - name: Unit Tests + run: bazel --batch test $(bazel query "//src/test/..." | grep "Test$") --noshow_progress + + - name: Integration Tests + run: bazel --batch test //test/integration:asset //test/integration:logging //test/integration:redis //test/integration:credentials --noshow_progress + + - name: Java Linter + run: bazel --batch build //:google_java_format_verification + + - name: Save artifacts + uses: actions/upload-artifact@v2 + with: + name: artifacts + path: ~/artifacts + + license-header: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '^1.13.1' + - name: License Header Check + run: | + go get -u github.com/google/addlicense + addlicense -c "Google LLC" -l apache -check $(find $PWD -type f -name '*.java') +