-
Notifications
You must be signed in to change notification settings - Fork 19
159 lines (136 loc) · 4.95 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
name: CI
on:
pull_request:
concurrency:
group: ${{ 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 }}
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: 20
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.workspace }}, CI step for node ${{ matrix.node-version }}
runs-on: ubuntu-latest
needs: find-changed-workspaces
strategy:
matrix:
workspace: ${{ fromJSON(needs.find-changed-workspaces.outputs.workspaces) }}
node-version: [20.x]
fail-fast: false
defaults:
run:
working-directory: ./workspaces/${{ matrix.workspace }}
env:
CI: true
NODE_OPTIONS: --max-old-space-size=8192
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.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: ${{ matrix.node-version }}
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('app-config.yaml') != '' }}
run: yarn backstage-cli config:check --lax
- name: type checking and declarations
run: yarn tsc:full
- name: prettier
run: yarn prettier:check
- 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: yarn backstage-cli repo test --coverage --maxWorkers=3
- 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
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: Setup node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: 20.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')
}}