-
Notifications
You must be signed in to change notification settings - Fork 6
213 lines (194 loc) · 6.58 KB
/
ci.yml
File metadata and controls
213 lines (194 loc) · 6.58 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: go.mod
- id: golangci-version
run: |
echo version="$(grep '^GOLANGCI_LINT_VERSION' Makefile | cut -d' ' -f3)" >> "$GITHUB_OUTPUT"
- uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
with:
version: ${{ steps.golangci-version.outputs.version }}
test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: go.mod
- run: make test
test-e2e:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: go.mod
- run: make test-e2e
docker:
needs: lint
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- image: resource-broker
dockerfile: Dockerfile
- image: resource-broker-kcp
dockerfile: contrib/kcp/Dockerfile
- image: resource-broker-operator
dockerfile: cmd/operator/Dockerfile
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6
with:
images: ghcr.io/platform-mesh/${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,format=long,prefix=sha-
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
file: ${{ matrix.dockerfile }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: |
type=image,push=${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
list-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- id: list-examples
run: |
{
echo -n 'examples=['
for example in $(find examples -mindepth 1 -maxdepth 1 -type d -printf '%f '); do
[[ -f "examples/$example/.noexample" ]] && continue
echo -n "\"$example\","
done
echo -n ']'
} > "$GITHUB_OUTPUT"
sed -i 's#,]#]#' "$GITHUB_OUTPUT"
outputs:
examples: ${{ steps.list-examples.outputs.examples }}
examples:
needs:
- docker
- list-examples
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example: ${{ fromJson(needs.list-examples.outputs.examples) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
with:
go-version-file: go.mod
- uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
- uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1
with:
# Only install kind without setting up any clusters. Clusters
# will be created as needed in the examples.
install_only: true
# use the gha cache to "transfer" the images built in the previous job to this job
- uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
file: Dockerfile
tags: resource-broker:dev
cache-from: type=gha
push: false
load: true
- uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
file: contrib/kcp/Dockerfile
tags: resource-broker-kcp:dev
cache-from: type=gha
push: false
load: true
- uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
file: cmd/operator/Dockerfile
tags: resource-broker-operator:dev
cache-from: type=gha
push: false
load: true
- uses: ntnn/mdextract@380b5ce9e585364ab79e3e8e8bb7bcb02cbfcecb # v0.4.1
with:
input: ./examples/${{ matrix.example }}/README.md
output: run.bash
tags: bash,ci
- run: bash -xe run.bash
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: failure()
with:
name: logs-${{ matrix.example }}
path: |
*.log
*.yaml
quality-gate:
if: always()
permissions: {}
needs: [lint, test, test-e2e, docker, examples]
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Check results
run: |
if [[ "${{ needs.lint.result }}" != "success" ]]; then
echo "lint failed"
exit 1
fi
if [[ "${{ needs.test.result }}" != "success" ]]; then
echo "test failed"
exit 1
fi
if [[ "${{ needs.test-e2e.result }}" != "success" ]]; then
echo "test-e2e failed"
exit 1
fi
if [[ "${{ needs.docker.result }}" != "success" ]]; then
echo "docker failed"
exit 1
fi
if [[ "${{ needs.examples.result }}" != "success" ]]; then
echo "examples failed"
exit 1
fi