forked from backstage/community-plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
269 lines (237 loc) · 9.58 KB
/
Copy pathci.yml
File metadata and controls
269 lines (237 loc) · 9.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
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
name: CI
on:
pull_request:
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
find-changed-workspaces:
name: Detect workspace changes
runs-on: ubuntu-latest
outputs:
workspaces: ${{ steps.find-changed-workspaces.outputs.workspaces }}
workspaceNodeMatrix: ${{ steps.find-changed-workspaces.outputs.workspace_node_matrix }}
steps:
- name: Calculate number of commits in PR
id: calculate-commits
env:
COMMITS: ${{ github.event.pull_request.commits }}
run: echo "NUMBER_OF_COMMITS=$(($COMMITS + 1))" >> $GITHUB_ENV
- name: Checkout base branch for diff purposes
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 50 # TODO(awanlin): Temporary fix
- name: Checkout head branch
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
# Needed for diff
fetch-depth: ${{ env.NUMBER_OF_COMMITS }}
- name: Set up Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 22.x
registry-url: https://registry.npmjs.org/ # Needed for auth
- name: Find changed workspaces
id: find-changed-workspaces
run: node ./scripts/ci/list-workspaces-with-changes.js
env:
BASE_REF: origin/${{ github.event.pull_request.base.ref }}
ci:
name: Workspace ${{ matrix.workspaceNodeMatrix.workspace }}, CI step for node ${{ matrix.workspaceNodeMatrix.nodeVersion }}
runs-on: ubuntu-latest
needs: find-changed-workspaces
strategy:
matrix:
workspaceNodeMatrix: ${{ fromJSON(needs.find-changed-workspaces.outputs.workspaceNodeMatrix) }}
fail-fast: false
defaults:
run:
working-directory: ./workspaces/${{ matrix.workspaceNodeMatrix.workspace }}
env:
CI: true
NODE_OPTIONS: --max-old-space-size=8192
services:
postgres18:
image: postgres:18
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
postgres14:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
steps:
- name: Checkout main branch for tests purposes
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
ref: main
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Set up Node ${{ matrix.workspaceNodeMatrix.nodeVersion }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: ${{ matrix.workspaceNodeMatrix.nodeVersion }}
registry-url: https://registry.npmjs.org/ # Needed for auth
- name: yarn install
run: yarn install --immutable
- name: check for missing repo fixes
run: yarn fix --check
- name: validate config
if: ${{ hashFiles(format('workspaces/{0}/app-config.yaml', matrix.workspaceNodeMatrix.workspace)) != '' }}
run: yarn backstage-cli config:check --lax
- name: type checking and declarations
run: yarn tsc:full
- name: prettier
run: yarn prettier:check
- name: read knipReports flag from bcp.json
id: bcpKnipReports
run: |
echo "Checking for bcp.json in workspace: workspaces/${{ matrix.workspaceNodeMatrix.workspace }}"
if [ -f bcp.json ]; then
echo "Reading knipReports flag..."
KNIP_REPORTS=$(jq -r '.["knipReports"]' bcp.json)
echo "knipReports value: $KNIP_REPORTS"
echo "knip_reports=$KNIP_REPORTS" >> $GITHUB_OUTPUT
else
echo "bcp.json not found. Defaulting knip_reports to false."
echo "knip_reports=false" >> $GITHUB_OUTPUT
fi
- name: check knip reports
if: ${{ steps.bcpKnipReports.outputs.knip_reports == 'true' }}
run: yarn build:knip-reports --ci
- name: read listDeprecations flag from bcp.json
id: bcpListDeprecations
run: |
echo "Checking for bcp.json in workspace: workspaces/${{ matrix.workspaceNodeMatrix.workspace }}"
if [ -f bcp.json ]; then
echo "Reading listDeprecations flag..."
LIST_DEPRECATIONS=$(jq -r '.["listDeprecations"]' bcp.json)
echo "listDeprecations value: $LIST_DEPRECATIONS"
echo "list_deprecations=$LIST_DEPRECATIONS" >> $GITHUB_OUTPUT
else
echo "bcp.json not found. Defaulting list_deprecations to false."
echo "list_deprecations=false" >> $GITHUB_OUTPUT
fi
- name: check list deprecations
if: ${{ steps.bcpListDeprecations.outputs.list_deprecations == 'true' }}
run: yarn backstage-cli repo list-deprecations
- name: check api reports and generate API reference
run: yarn build:api-reports:only --ci
- name: build all packages
run: yarn backstage-cli repo build --all
- name: lint
run: yarn backstage-cli repo lint --since origin/main
- name: publish check
run: yarn backstage-cli repo fix --check --publish
- name: test changed packages
run: |
if node -e "const p = require('./package.json'); process.exit(p.devDependencies?.jest ? 0 : 1)"; then
echo "Using Jest 30"
./node_modules/.bin/backstage-cli repo test --coverage --maxWorkers=3
else
echo "Using Jest 29 from the Backstage CLI"
yarn backstage-cli repo test --coverage --maxWorkers=3
fi
env:
BACKSTAGE_TEST_DISABLE_DOCKER: 1
BACKSTAGE_TEST_DATABASE_POSTGRES18_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres18.ports[5432] }}
BACKSTAGE_TEST_DATABASE_POSTGRES14_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres14.ports[5432] }}
- name: read playwrightTests flag from bcp.json
id: bcpPlaywrightTests
run: |
echo "Checking for bcp.json in workspace: workspaces/${{ matrix.workspaceNodeMatrix.workspace }}"
if [ -f bcp.json ]; then
echo "Reading playwrightTests flag..."
PLAYWRIGHT_TESTS=$(jq -r '.["playwrightTests"]' bcp.json)
echo "playwrightTests value: $PLAYWRIGHT_TESTS"
echo "playwright_tests=$PLAYWRIGHT_TESTS" >> $GITHUB_OUTPUT
else
echo "bcp.json not found. Defaulting list_deprecations to false."
echo "playwright_tests=false" >> $GITHUB_OUTPUT
fi
- name: playwright tests
if: ${{ steps.bcpPlaywrightTests.outputs.playwright_tests == 'true' }}
run: |
yarn playwright install --with-deps chromium chrome
yarn playwright 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
- name: Read codecov flag from bcp.json
id: bcpCodecov
run: |
if [ -f bcp.json ]; then
CODECOV=$(jq -r '.["codecov"] // "false"' bcp.json)
echo "codecov=$CODECOV" >> $GITHUB_OUTPUT
else
echo "codecov=false" >> $GITHUB_OUTPUT
fi
- name: Upload coverage to Codecov
if: ${{ steps.bcpCodecov.outputs.codecov == 'true' }}
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
flags: ${{ matrix.workspaceNodeMatrix.workspace }}
directory: ./workspaces/${{ matrix.workspaceNodeMatrix.workspace }}/plugins
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verify:
name: Workspace ${{ matrix.workspace }}, Verify step
runs-on: ubuntu-latest
needs: find-changed-workspaces
strategy:
matrix:
workspace: ${{ fromJSON(needs.find-changed-workspaces.outputs.workspaces) }}
fail-fast: false
steps:
- name: Checkout head branch
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Set up Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 22.x
- name: Install root dependencies
run: yarn install --immutable
- name: Verify lockfile duplicates
run: node scripts/ci/verify-lockfile-duplicates.js workspaces/${{ matrix.workspace }}/yarn.lock
- name: Verify changesets
run: node scripts/ci/verify-changesets.js ${{ matrix.workspace }}
result:
if: ${{ always() }}
name: check all required jobs
runs-on: ubuntu-latest
needs: [ci, verify]
steps:
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}