Skip to content

Commit bff796e

Browse files
committed
ci: add github actions workflow
Signed-off-by: Mark Sagi-Kazar <[email protected]>
1 parent 360b8f9 commit bff796e

File tree

2 files changed

+131
-1
lines changed

2 files changed

+131
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
go: ["1.18", "1.19", "1.20"]
17+
18+
steps:
19+
- name: Set up Go
20+
uses: actions/setup-go@v3
21+
with:
22+
go-version: ${{ matrix.go }}
23+
24+
- name: Checkout code
25+
uses: actions/checkout@v3
26+
27+
- name: Test
28+
run: make test
29+
30+
integration-test:
31+
name: Integration test
32+
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
kube: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25", "1.26"]
37+
env:
38+
KUBECONFIG: ${{ github.workspace }}/.kube/config
39+
40+
steps:
41+
- name: Set up Go
42+
uses: actions/setup-go@v3
43+
with:
44+
go-version: '1.20'
45+
46+
- name: Checkout code
47+
uses: actions/checkout@v3
48+
49+
# See https://github.com/kubernetes-sigs/kind/releases/tag/v0.17.0
50+
- name: Determine KinD node image version
51+
id: node_image
52+
run: |
53+
case ${{ matrix.kube }} in
54+
1.19)
55+
NODE_IMAGE=kindest/node:v1.19.16@sha256:476cb3269232888437b61deca013832fee41f9f074f9bed79f57e4280f7c48b7 ;;
56+
1.20)
57+
NODE_IMAGE=kindest/node:v1.20.15@sha256:a32bf55309294120616886b5338f95dd98a2f7231519c7dedcec32ba29699394 ;;
58+
1.21)
59+
NODE_IMAGE=kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1 ;;
60+
1.22)
61+
NODE_IMAGE=kindest/node:v1.22.15@sha256:7d9708c4b0873f0fe2e171e2b1b7f45ae89482617778c1c875f1053d4cef2e41 ;;
62+
1.23)
63+
NODE_IMAGE=kindest/node:v1.23.13@sha256:ef453bb7c79f0e3caba88d2067d4196f427794086a7d0df8df4f019d5e336b61 ;;
64+
1.24)
65+
NODE_IMAGE=kindest/node:v1.24.7@sha256:577c630ce8e509131eab1aea12c022190978dd2f745aac5eb1fe65c0807eb315 ;;
66+
1.25)
67+
NODE_IMAGE=kindest/node:v1.25.3@sha256:f52781bc0d7a19fb6c405c2af83abfeb311f130707a0e219175677e366cc45d1 ;;
68+
1.26)
69+
NODE_IMAGE=kindest/node:v1.26.0@sha256:691e24bd2417609db7e589e1a479b902d2e209892a10ce375fab60a8407c7352 ;;
70+
esac
71+
echo "image=$NODE_IMAGE" >> $GITHUB_OUTPUT
72+
73+
- name: Create KinD cluster
74+
uses: helm/[email protected]
75+
with:
76+
version: v0.17.0
77+
node_image: ${{ steps.node_image.outputs.image }}
78+
79+
- name: Test
80+
run: make test-integration
81+
82+
lint:
83+
name: Lint
84+
runs-on: ubuntu-latest
85+
86+
steps:
87+
- name: Set up Go
88+
uses: actions/setup-go@v3
89+
with:
90+
go-version: '1.20'
91+
92+
- name: Checkout code
93+
uses: actions/checkout@v3
94+
95+
- name: Lint
96+
run: make lint
97+
env:
98+
LINTER_FLAGS: '--timeout 5m'
99+
100+
license-check:
101+
name: License check
102+
runs-on: ubuntu-latest
103+
104+
steps:
105+
- name: Set up Go
106+
uses: actions/setup-go@v3
107+
with:
108+
go-version: '1.20'
109+
110+
- name: Checkout code
111+
uses: actions/checkout@v3
112+
113+
- name: Cache licenses
114+
uses: actions/cache@v3
115+
with:
116+
key: licensei-v2-${{ hashFiles('go.sum') }}
117+
path: |
118+
.licensei.cache
119+
restore-keys: |
120+
licensei-v2
121+
122+
- name: Download license information for dependencies
123+
env:
124+
GITHUB_TOKEN: ${{ github.token }}
125+
run: make license-cache
126+
127+
- name: Check licenses
128+
env:
129+
GITHUB_TOKEN: ${{ github.token }}
130+
run: make license-check

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ bin/golangci-lint-${GOLANGCI_VERSION}:
4747

4848
.PHONY: lint
4949
lint: bin/golangci-lint ## Run linter
50-
bin/golangci-lint run
50+
bin/golangci-lint run $LINTER_FLAGS

0 commit comments

Comments
 (0)