-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
243 lines (203 loc) · 6.12 KB
/
ci.yml
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
---
name: CI
# yamllint disable-line rule:truthy
on:
pull_request:
branches:
- '*'
push:
branches:
- 'master'
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
INSTALL_DOCKER_REPO: 1
jobs:
check-commit:
runs-on: ubuntu-24.04
outputs:
skip: ${{ steps.check-commit.outputs.skip }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: check if message contain keywords ace scopeid
id: check-commit
run: |
# checking for "docs" or "[ci skip]" messages
message=$(git log -1 --pretty=format:'%s')
if [[ "$message" =~ "\[(ci skip)\]" ]]; then
echo "Skipping tests due to [ci skip] message"
echo "skip=true" >> $GITHUB_OUTPUT
elif [[ "$message" =~ "^docs:" ]]; then
echo "Skipping tests due to "docs:" prefix on message"
echo "skip=true" >> $GITHUB_OUTPUT
fi
build:
name: build
runs-on: ubuntu-24.04
needs: check-commit
if: ${{ needs.check-commit.outputs.skip != 'true' }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
strategy:
fail-fast: true
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- name: set up qemu
uses: docker/setup-qemu-action@v3
- name: set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: build package
run: ./tests/ci/setup.sh build
env:
SKIP_IMAGE_BUILD: true
- name: set matrix for build
id: set-matrix
run: |
json=$(python3 .github/commands/matrix)
echo $json
echo "matrix=$json" >> $GITHUB_OUTPUT
- name: upload packages
uses: actions/upload-artifact@v4
with:
name: build
path: build
build-image-amd64:
name: build-image.linux/amd64
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: build-image
uses: ./.github/actions/build-image
with:
architecture: linux/amd64
build-image-arm64:
name: build-image.linux/arm64
needs: build
runs-on: buildjet-4vcpu-ubuntu-2404-arm
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: build-image
uses: ./.github/actions/build-image
with:
architecture: linux/arm64
unit-tests:
name: unit.${{ matrix.index }}
needs: build
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix: ${{fromJson(needs.build.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- name: download packages
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: ci-setup
run: ./.github/commands/ci-setup
# - name: start ssh session
# uses: luchihoratiu/debug-via-ssh@main
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.NGROK_SSH_PASS }}
- name: run ci
timeout-minutes: 30
run: sudo -E ./.github/commands/ci-run ${{ matrix.index }}
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
SYNC_GITHUB_PASSWORD: ${{ secrets.SYNC_GITHUB_PASSWORD }}
SYNC_GITHUB_USERNAME: ${{ secrets.SYNC_GITHUB_USERNAME }}
- uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.index }}
path: test-results
docker-deploy-tests:
name: docker
needs: build
runs-on: ubuntu-24.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: download packages
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: ci-setup
run: ./.github/commands/ci-setup
- name: docker-container-setup
run: |
./tests/ci/setup.sh docker
- name: test docker deploys
shell: bash
timeout-minutes: 20
run: |
docker exec dokku bash -c "cat /etc/sudoers.d/dokku-nginx"
DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker
go-tests:
name: go.${{ matrix.index }}
needs: build
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
index: [0, 1, 2, 3]
env:
GITHUB_NODE_INDEX: ${{ matrix.index }}
steps:
- uses: actions/checkout@v4
- name: download packages
uses: actions/download-artifact@v4
with:
name: build
path: build
- name: ci-setup
run: ./.github/commands/ci-setup
- name: run go tests
run: |
export CIRCLE_SHA1=$GITHUB_SHA
echo "CODACY_TOKEN=$CODACY_TOKEN"
if [ "$CODACY_TOKEN" != "" ]; then
echo "Detected value for CODACY_TOKEN"
fi
case $GITHUB_NODE_INDEX in
0) sudo -E make -e lint-ci go-tests ci-go-coverage ;;
1) sudo -E make -e deploy-test-checks-root deploy-test-config ;;
2) sudo -E make -e deploy-test-multi ;;
3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;;
esac
- uses: actions/upload-artifact@v4
with:
name: coverage.${{ matrix.index }}
path: test-results/coverage
publish-test-results:
name: publish-test-results
needs: unit-tests
runs-on: ubuntu-24.04
permissions:
checks: write
# the build-and-test job might be skipped, we don't need to run this job then
if: success() || failure()
steps:
- name: download test-results
uses: actions/download-artifact@v4
with:
path: test-results
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: Unit Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
junit_files: test-results/**/*.xml
comment_mode: "off"