-
Notifications
You must be signed in to change notification settings - Fork 2
149 lines (120 loc) · 3.79 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
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
140
141
142
143
144
145
146
147
148
149
name: Lint checks
on: # yamllint disable-line rule:truthy
pull_request: {}
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
unit-tests:
name: Run unit tests
runs-on: ubuntu-24.04
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Determine Go version
id: go_version
run: |
echo "version=$(go mod edit -json | jq -r '.Go')" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ steps.go_version.outputs.version }}
- name: Determine golang-ci version
run: make test
acceptance:
name: Run acceptance tests
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- proxy: dumb-proxy
- proxy: smart-proxy
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Determine Go version
id: go_version
run: |
echo "version=$(go mod edit -json | jq -r '.Go')" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ steps.go_version.outputs.version }}
- name: Run tests
env:
IMAGE_BUILDER: docker
IMG: namespace-lister:pr-${{ github.event.pull_request.number }}
run: |
echo "##[group] Preparing environment"
make -C "acceptance/test/${{ matrix.proxy }}" prepare
echo "##[endgroup]"
echo "##[group] Running tests"
make -C "acceptance/test/${{ matrix.proxy }}" test
echo "##[endgroup]"
go-tidy:
name: Tidy go mod
runs-on: ubuntu-24.04
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Determine Go version
id: go_version
run: |
echo "version=$(go mod edit -json | jq -r '.Go')" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ steps.go_version.outputs.version }}
- name: Ensure go.mod is tidy
env:
SHA_FILE: ${{ runner.temp }}/go_mod_shas.txt"
run: |
# generate sha512 for go mod files
sha512sum go.mod go.sum > "${SHA_FILE}"
# run go mod tidy
go mod tidy -v
# check files were left untouched
sha512sum -c "${SHA_FILE}"
if [ "$?" != 0 ]; then
printf "please run go mod tidy to tidy the go.mod\n\n%s\n" "${output}"
exit 1
fi
lint-go:
name: Lint code
runs-on: ubuntu-24.04
steps:
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Determine Go version
id: go_version
run: |
echo "version=$(go mod edit -json | jq -r '.Go')" >> $GITHUB_OUTPUT
- name: Determine golang-ci version
id: golangci_version
run: |
echo "version=$(go mod edit -json hack/tools/golang-ci/go.mod | \
jq -r '.Require | map(select(.Path == "github.com/golangci/golangci-lint"))[].Version')" \
>> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ steps.go_version.outputs.version }}
- name: Lint with golang-ci
uses: golangci/golangci-lint-action@v6
with:
version: ${{ steps.golangci_version.outputs.version }}
args: --timeout=5m
lint-yaml:
name: Lint yaml manifests
runs-on: ubuntu-24.04
steps:
- name: Install yamllint
run: |
pip install yamllint
- name: Checkout Git Repository
uses: actions/checkout@v4
- name: Lint with yamllint
run: make lint-yaml