94 lines (82 loc) · 3 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
on:
push:
branches:
- main
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/main/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 --test_output=errors
- name: Integration Tests
run: bazel --batch test //test/integration/...
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: test-artifacts
path: ~/.cache/bazel/*/*/*/gapic_generator_java/bazel-out/*/testlogs/*
retention-days: 5
- name: Java Linter
run: bazel --batch build //:google_java_format_verification
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
java-version: 8
- run: java -version
- name: Generate Code Coverage Report
# Run only test targets, and not golden_update targets.
run: bazel coverage $(bazel query "src/test/..." | grep "Test$") --combined_report=lcov
- name: Upload Code Coverage Report
uses: codecov/codecov-action@v1
with:
name: actions ${{ matrix.java }}
files: ./bazel-out/_coverage/_coverage_report.dat
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' ! -iname '*PlaceholderFile.java')