-
Notifications
You must be signed in to change notification settings - Fork 4
232 lines (199 loc) · 8.42 KB
/
release-cd-builder-images-centos7.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
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
name: Publish CD builder images - CentOS7
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "dockerfiles/cd/builders/*/centos7/Dockerfile"
- "dockerfiles/cd/builders/*/centos7/*.Dockerfile"
- "dockerfiles/cd/builders/*/skaffold-centos7.yaml"
jobs:
define-matrix:
name: Define building matrix - CentOS7
runs-on: ubuntu-24.04
outputs:
changed_folders: ${{ steps.changed.outputs.folders }}
changed_go_builder_folders: ${{ steps.changed.outputs.go_builder_folders }}
changed_rust_builder_folders: ${{ steps.changed.outputs.rust_builder_folders }}
changed_cpp_builder_folders: ${{ steps.changed.outputs.cpp_builder_folders }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Parse changed scopes
id: changed
run: |
# Determine the base SHA depending on the event
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA=${{ github.event.pull_request.base.sha }}
HEAD_SHA=${{ github.event.pull_request.head.sha }}
elif [ "${{ github.event_name }}" = "push" ]; then
# For push events, compare with the previous commit
BASE_SHA=$(git rev-parse HEAD^)
HEAD_SHA=$(git rev-parse HEAD)
else
echo "Unsupported event: ${{ github.event_name }}"
exit 1
fi
echo "Base SHA: $BASE_SHA"
echo "Head SHA: $HEAD_SHA"
# Get list of changed files with status
git diff --name-status $BASE_SHA $HEAD_SHA > changed_files.txt
echo "Changed Files with Status:"
cat changed_files.txt
# Filter out deleted files and get only filenames and select the files in dockerfiles/cd/builders with `centos7` matched.
CHANGED_FILES=$(grep -v '^D' changed_files.txt | cut -f2- | grep -E '^dockerfiles/cd/builders/(.*Dockerfile|skaffold.*.yaml)' | grep centos7)
CHANGED_FOLDERS=$(echo "$CHANGED_FILES" | xargs -n1 dirname | sort --unique)
# Convert the lists to JSON arrays
JSON_CHANGED_FILES=$(echo "$CHANGED_FILES" | jq -R -s -c 'split("\n") | map(select(length > 0))')
JSON_CHANGED_FOLDERS=$(echo "$CHANGED_FOLDERS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
# trim the prefix substring "dockerfiles/cd/builders/" from the JSON_CHANGED_FOLDERS
JSON_CHANGED_BUILDERS=$(echo "$JSON_CHANGED_FOLDERS" | jq -c 'map(sub("/centos7"; "")) | map(sub("dockerfiles/cd/builders/"; "")) | map(select(length > 0)) | unique')
# golang type builders
JSON_ALL_GO_BUILDERS='["ng-monitoring", "pd","ticdc", "tidb", "tidb-dashboard", "tiflow"]'
JSON_ALL_RUST_BUILDERS='["tikv"]'
JSON_ALL_CPP_BUILDERS='["tiflash"]'
### Compute the building matrix on builder axies.
# Get intersection of arrays: JSON_ALL_GO_BUILDERS, JSON_CHANGED_BUILDERS
JSON_CHANGED_FOLDERS_GO_TYPE=$(jq --null-input --argjson changed "$JSON_CHANGED_BUILDERS" --argjson ALL "$JSON_ALL_GO_BUILDERS" -R -s -c '$changed - ($changed - $ALL)' )
# Get intersection of arrays: JSON_ALL_RUST_BUILDERS, JSON_CHANGED_BUILDERS
JSON_CHANGED_FOLDERS_RUST_TYPE=$(jq --null-input --argjson changed "$JSON_CHANGED_BUILDERS" --argjson ALL "$JSON_ALL_RUST_BUILDERS" -R -s -c '$changed - ($changed - $ALL)' )
# Get intersection of arrays: JSON_ALL_CPP_BUILDERS, JSON_CHANGED_BUILDERS
JSON_CHANGED_FOLDERS_CPP_TYPE=$(jq --null-input --argjson changed "$JSON_CHANGED_BUILDERS" --argjson ALL "$JSON_ALL_CPP_BUILDERS" -R -s -c '$changed - ($changed - $ALL)' )
# Set the output variable
echo "files=$JSON_CHANGED_FILES" | tee -a $GITHUB_OUTPUT
echo "folders=$JSON_CHANGED_FOLDERS" | tee -a $GITHUB_OUTPUT
echo "go_builder_folders=$JSON_CHANGED_FOLDERS_GO_TYPE" | tee -a $GITHUB_OUTPUT
echo "rust_builder_folders=$JSON_CHANGED_FOLDERS_RUST_TYPE" | tee -a $GITHUB_OUTPUT
echo "cpp_builder_folders=$JSON_CHANGED_FOLDERS_CPP_TYPE" | tee -a $GITHUB_OUTPUT
skaffold-golang:
name: push golang builders - base CentOS7
runs-on: ubuntu-24.04
needs: define-matrix
permissions:
contents: read
packages: write
strategy:
matrix:
module: [builder-go]
profile: [go-1.23, go-1.22, go-1.21, go-1.20, go-1.19]
builder: ${{ fromJSON(needs.define-matrix.outputs.changed_go_builder_folders) }}
exclude:
- builder: ticdc
profile: go-1.22
- builder: ticdc
profile: go-1.21
- builder: ticdc
profile: go-1.20
- builder: ticdc
profile: go-1.19
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: "0"
fetch-tags: "true"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.13.2/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Publish images
working-directory: dockerfiles/cd/builders/${{ matrix.builder }}
run: |
skaffold build \
--filename=skaffold-centos7.yaml \
--build-concurrency=1 \
--cache-artifacts \
--default-repo=ghcr.io/pingcap-qe/cd/builders \
--profile=${{ matrix.profile }}
skaffold-rust:
name: push rust builders - base CentOS7
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
strategy:
matrix:
module: [builder-tikv]
builder: ${{ fromJSON(needs.define-matrix.outputs.changed_rust_builder_folders) }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: "0"
fetch-tags: "true"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.13.2/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Publish images
working-directory: dockerfiles/cd/builders/${{ matrix.builder }}
run: |
skaffold build \
--filename=skaffold-centos7.yaml \
--build-concurrency=1 \
--cache-artifacts \
--default-repo=ghcr.io/pingcap-qe/cd/builders \
--module=${{ matrix.module }}
skaffold-cpp:
name: build cpp builders - base CentOS7
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
strategy:
matrix:
builder: ${{ fromJSON(needs.define-matrix.outputs.changed_cpp_builder_folders) }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: "0"
fetch-tags: "true"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.13.2/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Build images
working-directory: dockerfiles/cd/builders/${{ matrix.builder }}
run: |
skaffold build \
--filename=skaffold-centos7.yaml \
--build-concurrency=1 \
--cache-artifacts \
--default-repo=ghcr.io/pingcap-qe/cd/builders