-
Notifications
You must be signed in to change notification settings - Fork 183
121 lines (115 loc) · 4.55 KB
/
workflow-integration-tests.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
on:
workflow_call:
env:
KIND_VERSION: 0.22.0
jobs:
setup-integration-tests:
runs-on: ubuntu-22.04
outputs:
kind_images: ${{ steps.set_kind_images.outputs.kind_images }}
default_kind_image: ${{ steps.set_kind_images.outputs.default_kind_image }}
test_names_onlylatest: ${{ steps.set_test_names.outputs.test_names_onlylatest }}
test_names_allversions: ${{ steps.set_test_names.outputs.test_names_allversions }}
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache-dependency-path: "**/go.sum"
- id: set_kind_images
name: Set kind images
working-directory: ./tests/integration/
run: |
echo "kind_images=$(jq -cM '.supported' kind_images.json)" >> $GITHUB_OUTPUT
echo "default_kind_image=$(jq -cM '.default' kind_images.json)" >> $GITHUB_OUTPUT
- name: Print kind images
run: echo "Kind images ${{ steps.set_kind_images.outputs.kind_images }}"
- id: set_test_names
name: Set test names
working-directory: ./tests/integration/
run: |
echo "test_names_allversions=$(make list-tests-allversions | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
echo "test_names_onlylatest=$(make list-tests-onlylatest | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT
- name: Print test names
run: |
echo "Test names running on all K8s versions ${{ steps.set_test_names.outputs.test_names_allversions }}"
echo "Test names running only on latest K8s version ${{ steps.set_test_names.outputs.test_names_onlylatest }}"
lint-integration-tests:
name: Lint integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.57.1
working-directory: ./tests/integration/
# Optional: golangci-lint command line arguments.
args: --timeout=10m --verbose
integration-tests-onlylatest:
runs-on: ubuntu-22.04
name: IT - ${{ matrix.test_name }} - ${{ needs.setup-integration-tests.outputs.default_kind_image }}
needs:
- setup-integration-tests
strategy:
matrix:
kind_image:
- ${{ needs.setup-integration-tests.outputs.default_kind_image }}
test_name: ${{ fromJSON(needs.setup-integration-tests.outputs.test_names_onlylatest) }}
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache-dependency-path: "**/go.sum"
- name: Setup kind
run: |
curl --retry 10 --retry-max-time 120 --retry-delay 5 -Lo ./kind https://kind.sigs.k8s.io/dl/v${{env.KIND_VERSION}}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Run integration test - ${{ matrix.test_name }}
working-directory: ./tests/integration/
run: make test TEST_NAME=^${{matrix.test_name}}$ KIND_NODE_IMAGE=${{matrix.kind_image}}
integration-tests-allversions:
runs-on: ubuntu-22.04
name: IT - ${{ matrix.test_name }} - ${{ matrix.kind_image }}
needs:
- setup-integration-tests
strategy:
matrix:
kind_image: ${{ fromJSON(needs.setup-integration-tests.outputs.kind_images) }}
test_name: ${{ fromJSON(needs.setup-integration-tests.outputs.test_names_allversions) }}
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache-dependency-path: "**/go.sum"
- name: Setup kind
run: |
curl --retry 10 --retry-max-time 120 --retry-delay 5 -Lo ./kind https://kind.sigs.k8s.io/dl/v${{env.KIND_VERSION}}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Run integration test - ${{ matrix.test_name }}
working-directory: ./tests/integration/
run: make test TEST_NAME=^${{matrix.test_name}}$ KIND_NODE_IMAGE=${{matrix.kind_image}}
integration-test-status:
runs-on: ubuntu-22.04
if: ${{ always() }}
needs:
- integration-tests-allversions
- integration-tests-onlylatest
steps:
- name: Tests passed
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1