-
Notifications
You must be signed in to change notification settings - Fork 40
191 lines (173 loc) · 7.84 KB
/
ci.yml
File metadata and controls
191 lines (173 loc) · 7.84 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: CI
on:
push:
branches:
- main
- release-*
workflow_dispatch: {}
pull_request:
branches:
- main
- release-*
paths-ignore: [docs/**, "**.md", "**.mdx", "**.png", "**.jpg"]
env:
GO_VERSION: '1.25.10'
CERT_MANAGER_VERSION: 'v1.16.2'
jobs:
detect-noop:
runs-on: ubuntu-latest
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
- name: Detect No-op Changes
id: noop
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
do_not_skip: '["workflow_dispatch", "schedule", "push"]'
concurrent_skipping: false
unit-and-integration-tests:
runs-on: ubuntu-latest
needs: detect-noop
if: needs.detect-noop.outputs.noop != 'true'
steps:
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Check out code into the Go module directory
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Ginkgo CLI
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.19.1
- name: Prepare necessary environment variables
run: |
echo "CGO_ENABLED=1" >> $GITHUB_ENV
KUBEBUILDER_ASSETS=$(make --silent kubebuilder-assets-path)
echo "KUBEBUILDER_ASSETS="$KUBEBUILDER_ASSETS"" >> $GITHUB_ENV
# Certain tests that require special setup (e.g., those that should be run with Ginkgo CLI only) will
# be skipped in this step.
#
# Note that the skipping only applies to the CI environment.
- name: Run unit and integration tests with default setup & generate coverage
run: |
make test
env:
KUBEFLEET_CI_TEST_RUNNER_NAME: 'default'
# The work applier integration tests use in-memory Kubernetes environment setup; due to resource constraints
# and the way the tests are organized, running the suite with as many parallel Ginkgo processes as possible (i.e.,
# the number of all CPU cores) might not lead to the optimal outcome.
#
# Note (chenyu1): switch to test matrices if we need to test with more configuration combos in the future.
- name: Run work applier unit and integration tests with Ginkgo CLI & generate coverage
run: |
ginkgo -v -p --procs=4 --race --cover -coverprofile=work-applier-it-coverage.out ./pkg/controllers/workapplier/
KUBEFLEET_CI_WORK_APPLIER_RUN_WITH_PRIORITY_QUEUE=true ginkgo -v -p --procs=4 --race --cover -coverprofile=work-applier-it-no-pri-q-coverage.out ./pkg/controllers/workapplier/
env:
KUBEFLEET_CI_TEST_RUNNER_NAME: 'ginkgo'
- name: Upload Codecov report
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
## Repository upload token - get it from codecov.io. Required only for private repositories
token: ${{ secrets.CODECOV_TOKEN }}
# The codecov action will auto-search all coverage files by default. All uploaded coverage will be
# merged automatically.
e2e-tests:
strategy:
fail-fast: false
matrix:
customized-settings: [default, resourceplacement, joinleave, custom]
include:
- customized-settings: default
# to shorten the test duration, set the resource snapshot creation interval to 0
resource-snapshot-creation-minimum-interval: 0m
resource-changes-collection-duration: 0m
- customized-settings: resourceplacement
# to shorten the test duration, set the resource snapshot creation interval to 0
resource-snapshot-creation-minimum-interval: 0m
resource-changes-collection-duration: 0m
- customized-settings: joinleave
# to shorten the test duration, set the resource snapshot creation interval to 0
resource-snapshot-creation-minimum-interval: 0m
resource-changes-collection-duration: 0m
- customized-settings: custom
resource-snapshot-creation-minimum-interval: 30s
resource-changes-collection-duration: 15s
runs-on: ubuntu-latest
needs: [
detect-noop,
]
if: needs.detect-noop.outputs.noop != 'true'
steps:
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Check out code into the Go module directory
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Move Docker data directory to /mnt
# The default storage device on GitHub-hosted runners is running low during e2e tests.
# Moving Docker data directory to /mnt which has more space and is backed by a larger
# storage device.
# Upstream kubefleet repo has a much bigger default storage device and no secondary
# storage device to use.
run: |
echo "=== Moving Docker to /mnt for more disk space ==="
df -h
sudo systemctl stop docker
echo '{"data-root": "/mnt/docker"}' | sudo tee /etc/docker/daemon.json
sudo mkdir -p /mnt/docker
if [ -d "/var/lib/docker" ]; then
sudo mv /var/lib/docker/* /mnt/docker/ || true
fi
sudo systemctl start docker
echo "=== Docker moved to /mnt, verifying ==="
docker info | grep "Docker Root Dir" || true
- name: Install Ginkgo CLI
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
- name: Install Kind
# Before updating the kind version to use, verify that the current kind image
# is still supported by the version.
run: |
go install sigs.k8s.io/kind@v0.30.0
- name: Run e2e tests
run: |
if [ "${{ matrix.customized-settings }}" = "default" ]; then
make e2e-tests LABEL_FILTER="!custom && !joinleave && !resourceplacement"
elif [ "${{ matrix.customized-settings }}" = "resourceplacement" ]; then
make e2e-tests LABEL_FILTER="!custom && resourceplacement"
elif [ "${{ matrix.customized-settings }}" = "joinleave" ]; then
make e2e-tests LABEL_FILTER="!custom && joinleave"
else
make e2e-tests-custom
fi
env:
KUBECONFIG: '/home/runner/.kube/config'
HUB_SERVER_URL: 'https://172.19.0.2:6443'
# Temporarily enable the AKS property provider for the E2E tests, in order
# to verify the property-based scheduling experience.
#
# TO-DO (chenyu1): to ensure a vendor-neutral experience, switch to a dummy
# property provider once the AKS one is split out.
PROPERTY_PROVIDER: 'azure'
RESOURCE_SNAPSHOT_CREATION_MINIMUM_INTERVAL: ${{ matrix.resource-snapshot-creation-minimum-interval }}
RESOURCE_CHANGES_COLLECTION_DURATION: ${{ matrix.resource-changes-collection-duration }}
CERT_MANAGER_VERSION: ${{ env.CERT_MANAGER_VERSION }}
- name: Collect logs
if: always()
# Wait for a bit before log collection; this gives the agent pods some time to shut down
# gracefully and flush their logs.
run: |
sleep 30
make collect-e2e-logs
env:
KUBECONFIG: '/home/runner/.kube/config'
LOG_DIR: 'logs-${{ matrix.customized-settings }}'
- name: Upload logs
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: e2e-logs-${{ matrix.customized-settings }}
path: test/e2e/logs-${{ matrix.customized-settings }}/
retention-days: 3