-
Notifications
You must be signed in to change notification settings - Fork 34
92 lines (82 loc) · 3.4 KB
/
Copy pathapi-reference.yml
File metadata and controls
92 lines (82 loc) · 3.4 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
name: API reference acceptance
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
changes:
runs-on: ubuntu-latest
outputs:
relevant: ${{ steps.filter.outputs.relevant }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- id: filter
name: Detect API reference changes
env:
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
run: |
relevant=false
if [[ -z "$BASE_SHA" || "$BASE_SHA" == "0000000000000000000000000000000000000000" ]]; then
relevant=true
else
changed_files="$RUNNER_TEMP/api-reference-changed-files.txt"
if ! git diff --name-only "$BASE_SHA" "$GITHUB_SHA" > "$changed_files"; then
echo "Could not determine changed files from $BASE_SHA to $GITHUB_SHA."
exit 1
fi
while IFS= read -r file; do
case "$file" in
apps/www/package.json|apps/www/registry/manifests.ts|apps/www/registry/features/api-reference.md|apps/www/scripts/generate-registry.ts|apps/www/scripts/serve-registry.mjs|packages/nimbus-docs/*|packages/nimbus-docs/**|packages/nimbus-starter-source/*|packages/nimbus-starter-source/**|packages/create-nimbus-docs/*|packages/create-nimbus-docs/**|scripts/api-reference-check.mjs|scripts/fixtures/api-reference/*|scripts/fixtures/api-reference/**|package.json|pnpm-lock.yaml|pnpm-workspace.yaml|.npmrc|tsconfig.base.json|.github/workflows/api-reference.yml)
relevant=true
break
;;
esac
done < "$changed_files"
fi
echo "relevant=$relevant" >> "$GITHUB_OUTPUT"
acceptance:
needs: changes
if: needs.changes.outputs.relevant == 'true'
runs-on: ubuntu-latest
timeout-minutes: 50
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Install pinned Chromium
run: pnpm exec playwright install --with-deps chromium
- name: Run generated-consumer acceptance check
run: pnpm api-reference:check
required:
name: API reference required
needs: [changes, acceptance]
if: always()
runs-on: ubuntu-latest
steps:
- name: Require acceptance when relevant
env:
CHANGES_RESULT: ${{ needs.changes.result }}
RELEVANT: ${{ needs.changes.outputs.relevant }}
RESULT: ${{ needs.acceptance.result }}
run: |
if [[ "$CHANGES_RESULT" != "success" ]]; then
echo "API reference change detection failed (result: $CHANGES_RESULT)."
exit 1
fi
if [[ "$RELEVANT" != "true" && "$RELEVANT" != "false" ]]; then
echo "API reference change detection returned an invalid value: $RELEVANT"
exit 1
fi
if [[ "$RELEVANT" == "true" && "$RESULT" != "success" ]]; then
echo "API reference acceptance did not pass (result: $RESULT)."
exit 1
fi