Skip to content

Commit 0b75b60

Browse files
Merge pull request #58 from cisco-open/github-integration-tests
ci: add github actions workflow
2 parents 360b8f9 + 896dba4 commit 0b75b60

File tree

3 files changed

+135
-3
lines changed

3 files changed

+135
-3
lines changed

.github/workflows/ci.yaml

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

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
LICENSEI_VERSION = 0.5.0
2-
GOLANGCI_VERSION = 1.44.0
2+
GOLANGCI_VERSION = 1.51.1
33

44
all: license fmt vet test
55

@@ -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}

tests/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,

0 commit comments

Comments
 (0)