-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (121 loc) · 4.17 KB
/
ci.yml
File metadata and controls
139 lines (121 loc) · 4.17 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
check:
name: Check source and configs (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per run.
disk-cache: ${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
# Share repository cache between workflows.
repository-cache: true
bazelrc: |
common --lockfile_mode=error
- name: Set up Go
id: setup-go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
check-latest: true
cache: true
- run: |
set -e
bazel run @rules_go//go -- tool fix -go=go${{ steps.setup-go.outputs.go-version }} -force true .
git diff --exit-code
bazel run //:gazelle -- fix
git diff --exit-code
bazel run @rules_go//go -- run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test -fix .
git diff --exit-code
bazel mod deps
git diff --exit-code
bazel mod tidy
git diff --exit-code
bazel run @rules_go//go -- mod tidy
git diff --exit-code
shell: bash
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per run.
disk-cache: ${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
# Share repository cache between workflows.
repository-cache: true
bazelrc: |
common --lockfile_mode=error
- name: Run tests (${{ runner.os }})
run: |
set -e
if [ "${{ runner.os }}" = "Windows" ]; then
bazel test //...
else
bazel coverage --combined_report=lcov //...
cp bazel-out/_coverage/_coverage_report.dat coverage.txt
fi
shell: bash
- name: Upload coverage
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
if: runner.os != 'Windows'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
fail_ci_if_error: true
verbose: true
lint:
name: Lint (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: bazel-contrib/setup-bazel@083175551ceeceebc757ebee2127fde78840ca77 # 0.18.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per run.
disk-cache: ${{ github.workflow }}-${{ github.job }}-${{ runner.os }}
# Share repository cache between workflows.
repository-cache: true
bazelrc: |
common --lockfile_mode=error
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
check-latest: true
cache: true
- name: Print Go version
run: go version
shell: bash
- name: Run linter
run: bazel run //:golangci-lint -- run
shell: bash
- name: Run buildifier
if: runner.os != 'Windows'
run: |
bazel run //:buildifier.check
shell: bash