forked from backstage/backstage
-
Notifications
You must be signed in to change notification settings - Fork 3
280 lines (231 loc) · 9.46 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
name: CI
on:
# NOTE: If you change these you must update ci-noop.yml as well
pull_request:
paths-ignore:
- 'microsite/**'
- 'beps/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# This step only runs yarn install to make sure that an exact match is available
# in the cache. The two following verify and tests jobs then always install from cache.
install:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x]
env:
CI: true
NODE_OPTIONS: --max-old-space-size=8192
name: Install ${{ matrix.node-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/ # Needed for auth
- name: yarn install
uses: backstage/actions/yarn-install@25145dd4117d50e1da9330e9ed2893bc6b75373e # v0.6.15
with:
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }}
# The verify jobs runs all the verification that doesn't require a
# diff towards master, since it takes some time to fetch that.
verify:
runs-on: ubuntu-latest
needs: install
strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x]
env:
CI: true
NODE_OPTIONS: --max-old-space-size=8192
name: Verify ${{ matrix.node-version }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/ # Needed for auth
- name: yarn install
uses: backstage/actions/yarn-install@25145dd4117d50e1da9330e9ed2893bc6b75373e # v0.6.15
with:
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }}
- name: verify yarn dependency duplicates
run: node scripts/verify-lockfile-duplicates.js
- name: verify changesets
run: node scripts/verify-changesets.js
- name: verify local dependency ranges
run: node scripts/verify-local-dependencies.js
- name: verify peer dependency ranges
run: yarn lint:peer-deps
- name: check for missing repo fixes
run: yarn fix --check
- name: validate config
run: yarn backstage-cli config:check --lax
- name: type checking and declarations
run: yarn tsc:full
- name: prettier
run: yarn prettier:check
# We need to generate the API references as well, so that we can verify the doc links
- name: check api reports and generate API reference
run: yarn build:api-reports:only --ci --docs
- name: verify api reference
run: node scripts/verify-api-reference.js
- name: verify catalog-info.yaml consistency
run: yarn backstage-repo-tools generate-catalog-info --ci
- name: lint openapi yaml files
run: yarn backstage-repo-tools repo schema openapi lint
- name: verify openapi yaml file matches generated ts file
run: yarn backstage-repo-tools repo schema openapi verify
- name: verify doc links
run: node scripts/verify-links.js
- name: build all packages
run: yarn backstage-cli repo build --all
- name: verify type dependencies
run: yarn lint:type-deps
- name: ensure clean working directory
run: |
if files=$(git ls-files --exclude-standard --others --modified) && [[ -z "$files" ]]; then
exit 0
else
echo ""
echo "Working directory has been modified:"
echo ""
git status --short
echo ""
exit 1
fi
# The test job runs all tests as well as any verification step that
# requires a diff towards master.
test:
runs-on: ubuntu-latest
needs: install
strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x]
name: Test ${{ matrix.node-version }}
services:
postgres16:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
postgres12:
image: postgres:12
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
mysql8:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: root
options: >-
--health-cmd "mysqladmin ping -h localhost"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306/tcp
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379/tcp
env:
CI: true
NODE_OPTIONS: --max-old-space-size=8192 --no-node-snapshot
INTEGRATION_TEST_GITHUB_TOKEN: ${{ secrets.INTEGRATION_TEST_GITHUB_TOKEN }}
INTEGRATION_TEST_GITLAB_TOKEN: ${{ secrets.INTEGRATION_TEST_GITLAB_TOKEN }}
INTEGRATION_TEST_BITBUCKET_TOKEN: ${{ secrets.INTEGRATION_TEST_BITBUCKET_TOKEN }}
INTEGRATION_TEST_AZURE_TOKEN: ${{ secrets.INTEGRATION_TEST_AZURE_TOKEN }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: fetch master branch
run: git fetch origin master
# Need to fetch the base branch to be able to verify the release
- name: fetch base branch
if: github.event.pull_request.base.ref != 'master'
run: git fetch origin ${{ github.event.pull_request.base.ref }}
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/ # Needed for auth
- name: yarn install
uses: backstage/actions/yarn-install@25145dd4117d50e1da9330e9ed2893bc6b75373e # v0.6.15
with:
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }}
# This check is done here since it needs git history
- name: verify release
run: node scripts/verify-release.js
# Use the lower-level cache actions for the success cache, so that we can store the cache even on failed builds
- name: restore backstage-cli cache
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: .cache/backstage-cli
key: ${{ runner.os }}-v${{ matrix.node-version }}-backstage-cli-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-v${{ matrix.node-version }}-backstage-cli-
- name: lint changed packages
run: yarn backstage-cli repo lint --since origin/master --successCache --successCacheDir .cache/backstage-cli
- name: test changed packages
run: yarn backstage-cli repo test --maxWorkers=3 --workerIdleMemoryLimit=1300M --since origin/master --successCache --successCacheDir .cache/backstage-cli
env:
BACKSTAGE_TEST_DISABLE_DOCKER: 1
BACKSTAGE_TEST_DATABASE_POSTGRES16_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres16.ports[5432] }}
BACKSTAGE_TEST_DATABASE_POSTGRES12_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres12.ports[5432] }}
BACKSTAGE_TEST_DATABASE_MYSQL8_CONNECTION_STRING: mysql://root:root@localhost:${{ job.services.mysql8.ports[3306] }}/ignored
BACKSTAGE_TEST_CACHE_REDIS7_CONNECTION_STRING: redis://localhost:${{ job.services.redis.ports[6379] }}
# Always save success cache even if there were failures, that way it can be used in re-triggered builds
- name: save backstage-cli cache
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
if: always()
with:
path: .cache/backstage-cli
key: ${{ runner.os }}-v${{ matrix.node-version }}-backstage-cli-${{ github.run_id }}
# We run the test cases before verifying the specs to prevent any failing tests from causing errors.
- name: verify openapi specs against test cases
run: yarn backstage-repo-tools repo schema openapi test
- name: ensure clean working directory
run: |
if files=$(git ls-files --exclude-standard --others --modified) && [[ -z "$files" ]]; then
exit 0
else
echo ""
echo "Working directory has been modified:"
echo ""
git status --short
echo ""
exit 1
fi