-
Notifications
You must be signed in to change notification settings - Fork 3
268 lines (226 loc) · 9.9 KB
/
Copy pathci.yml
File metadata and controls
268 lines (226 loc) · 9.9 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
name: ForgeRock Pull Request CI
on:
pull_request:
env:
NX_CLOUD_ENCRYPTION_KEY: ${{ secrets.NX_CLOUD_ENCRYPTION_KEY }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.PR_NX_CLOUD_ACCESS_TOKEN }} # Read Only
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CI: true
# recommended to set a concurrency group
concurrency:
group: preview-pages-${{ github.ref }}
cancel-in-progress: true
jobs:
pr:
if: ${{github.event.pull_request.head.repo.full_name == github.repository}}
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Setup Project
uses: ./.github/actions/setup
with:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Lint dependency versions
run: pnpm syncpack:lint
- run: pnpm nx fix-ci
if: always()
- uses: codecov/codecov-action@v5
with:
directory: ./packages/
token: ${{ secrets.CODECOV_TOKEN }}
- name: Ensure builds run
run: pnpm nx run-many -t build --no-agents
- run: pnpm pkg-pr-new publish './packages/*' './packages/sdk-effects/*' --pnpm --packageManager=pnpm
- name: build docs
run: pnpm generate-docs
- name: preview-docs
uses: rajyan/preview-pages@v1
with:
source-dir: docs
pr-comment: 'none'
- name: Update comment
uses: marocchino/sticky-pull-request-comment@v2
with:
message: Deployed ${{ github.sha }} to https://ForgeRock.github.io/ping-javascript-sdk/pr-${{ github.event.number }}/${{github.sha}} branch gh-pages in ForgeRock/ping-javascript-sdk
- name: Validate interface mapping
id: interface-mapping
continue-on-error: true
run: |
set +e
OUTPUT=$(pnpm exec tsx tools/interface-mapping-validator/src/main.ts 2>&1)
EXIT_CODE=$?
set -e
echo "$OUTPUT"
echo 'report<<MAPPING_EOF' >> "$GITHUB_OUTPUT"
echo "$OUTPUT" >> "$GITHUB_OUTPUT"
echo 'MAPPING_EOF' >> "$GITHUB_OUTPUT"
exit $EXIT_CODE
- name: Find interface mapping comment
id: find-mapping-comment
if: always()
uses: peter-evans/find-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: <!-- interface-mapping-check -->
- name: Update interface mapping comment
if: always() && steps.interface-mapping.outcome == 'failure'
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-mapping-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- interface-mapping-check -->
## Interface Mapping Out of Date
The `interface_mapping.md` document is out of sync with the SDK exports.
<details>
<summary>Drift report</summary>
```
${{ steps.interface-mapping.outputs.report }}
```
</details>
**To fix**, run:
```bash
pnpm mapping:generate
```
Then commit the updated `interface_mapping.md`.
- name: Update interface mapping comment (passing)
if: always() && steps.interface-mapping.outcome == 'success' && steps.find-mapping-comment.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-mapping-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- interface-mapping-check -->
## Interface Mapping Up to Date
The `interface_mapping.md` document is in sync with the SDK exports.
- name: Download baseline bundle sizes
uses: dawidd6/action-download-artifact@v3
with:
workflow: publish.yml
branch: main
name: bundle-size-baseline
path: .
if_no_artifact_found: warn
continue-on-error: true
- name: Calculate bundle sizes
id: bundle-analysis
run: |
# Make script executable
chmod +x ./scripts/bundle-sizes.sh
# Check if baseline exists
if [ -f "previous_sizes.json" ]; then
echo "✅ Using baseline size data from main branch"
echo "Baseline data preview:"
cat previous_sizes.json | head -5
else
echo "⚠️ No baseline size data found - this will be the first measurement"
fi
# Run the bundle size calculation
./scripts/bundle-sizes.sh
- name: Upload current stats as artifact
uses: actions/upload-artifact@v5
with:
name: bundle-size-stats-pr-${{ github.event.pull_request.number }}
path: |
stats.txt
bundle_size_report.md
retention-days: 7
- name: Find bundle size comment
id: find-comment
uses: peter-evans/find-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: <!-- This comment was auto-generated by GitHub Actions to display bundle size statistics -->
- name: Create or update bundle size comment
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- This comment was auto-generated by GitHub Actions to display bundle size statistics -->
## 📦 Bundle Size Analysis
${{ steps.bundle-analysis.outputs.stats }}
### Legend
🆕 New package
🔺 Size increased
🔻 Size decreased
➖ No change
<details>
<summary>ℹ️ How bundle sizes are calculated</summary>
- **Current Size**: Total gzipped size of all files in the package's `dist` directory
- **Baseline**: Comparison against the latest build from the `main` branch
- **Files included**: All build outputs except source maps and TypeScript build cache
- **Exclusions**: `.map`, `.tsbuildinfo`, and `.d.ts.map` files
</details>
---
<sub>🔄 Updated automatically on each push to this PR</sub>
# Coverage Matrix (non-blocking)
# Runs the full pipeline: analyze exports, collect V8 unit coverage,
# merge into final matrix, and build the Svelte dashboard.
# Zero manual path maintenance — discovers packages and exports automatically.
- name: Generate coverage matrix and build dashboard
continue-on-error: true
run: NX_CLOUD_DISTRIBUTED_EXECUTION=false pnpm nx run @forgerock/coverage-matrix:coverage-report
- name: Generate coverage matrix summary
continue-on-error: true
id: coverage-matrix-summary
run: |
node -e "
const fs = require('fs');
try {
const data = JSON.parse(fs.readFileSync('tools/coverage-matrix/data/coverage-matrix.json', 'utf-8'));
const rows = data.packages.map(p => {
const s = p.summary;
const uPct = s.totalExports > 0 ? Math.round(s.unitCovered / s.totalExports * 100) : 0;
const ePct = s.totalExports > 0 ? Math.round(s.e2eCovered / s.totalExports * 100) : 0;
const fPct = s.totalSourceFiles > 0 ? Math.round(s.unitTestedFiles / s.totalSourceFiles * 100) : 0;
return '| ' + p.name + ' | ' + s.totalExports + ' | ' + fPct + '% (' + s.unitTestedFiles + '/' + s.totalSourceFiles + ') | ' + uPct + '% | ' + ePct + '% | ' + s.uncovered + ' |';
});
const table = '| Package | Exports | Unit Files | Unit Exports | E2E | Uncovered |\n|---------|---------|------------|--------------|-----|-----------|' + '\n' + rows.join('\n');
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'table<<EOF\n' + table + '\nEOF\n');
} catch (e) {
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'table=Coverage matrix data not available.\n');
}
"
- name: Find coverage matrix comment
continue-on-error: true
if: github.event_name == 'pull_request'
id: find-coverage-comment
uses: peter-evans/find-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: <!-- coverage-matrix -->
- name: Post coverage matrix PR comment
continue-on-error: true
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-coverage-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- coverage-matrix -->
## Coverage Matrix
${{ steps.coverage-matrix-summary.outputs.table }}
[Full dashboard](https://forgerock.github.io/ping-javascript-sdk/coverage-matrix/) · [PR preview](https://ForgeRock.github.io/ping-javascript-sdk/pr-${{ github.event.number }}/${{ github.sha }}/coverage-matrix/)
- name: Preview coverage dashboard
continue-on-error: true
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./tools/coverage-matrix/dist
destination_dir: pr-${{ github.event.number }}/${{ github.sha }}/coverage-matrix
keep_files: true