Skip to content

Commit 539402e

Browse files
authored
Add JSON API data check to CI (#459)
#SkipVersionBump
1 parent adc72d5 commit 539402e

File tree

6 files changed

+35
-95
lines changed

6 files changed

+35
-95
lines changed

.github/workflows/cps-shared-ui-checkers.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,30 @@ jobs:
8282
start: npm run start
8383
browser: chrome
8484
wait-on: http://localhost:4200
85+
86+
generate-api-data:
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout code
90+
uses: actions/checkout@v4
91+
92+
- name: Setup Node.js
93+
uses: actions/setup-node@v4
94+
with:
95+
node-version: 20.x
96+
cache: npm
97+
98+
- name: Install dependencies
99+
run: npm ci
100+
101+
- name: Generate API data and check for changes
102+
id: generate-api
103+
run: |
104+
npm run generate-json-api
105+
if [[ -n "$(git status --porcelain projects/composition/src/assets/api-data/)" ]]; then
106+
echo "API data has changed. Please commit the updated API data.";
107+
git --no-pager diff projects/composition/src/assets/api-data/
108+
exit 1;
109+
else
110+
echo "No changes in API data.";
111+
fi

.github/workflows/cps-ui-kit-publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
with:
2020
ssh-key: ${{ secrets.DEPLOY_KEY }}
2121

22-
- name: Use Node.js v20.x
22+
- name: Use Node.js v22.x
2323
uses: actions/setup-node@v3
2424
with:
25-
node-version: 20.x
25+
node-version: 22.x
2626
registry-url: 'https://registry.npmjs.org'
2727

2828
- name: Bump version
@@ -55,10 +55,10 @@ jobs:
5555
- name: Fetch latest commits
5656
run: git pull origin master
5757

58-
- name: Use Node.js v20.x
58+
- name: Use Node.js v22.x
5959
uses: actions/setup-node@v3
6060
with:
61-
node-version: 20.x
61+
node-version: 22.x
6262
registry-url: 'https://registry.npmjs.org'
6363

6464
- name: Cache node_modules

.github/workflows/publish-documentation.yml

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -14,96 +14,9 @@ on:
1414
- '.github/**'
1515

1616
jobs:
17-
# Generate api data
18-
generate-api-data:
19-
if: "!contains(github.event.head_commit.message, 'Update autogenerated JSON files')"
20-
runs-on: ubuntu-latest
21-
# Permissions needed to create PR and write content
22-
permissions:
23-
contents: write
24-
pull-requests: write
25-
26-
steps:
27-
- name: Checkout code
28-
uses: actions/checkout@v4
29-
with:
30-
token: ${{ secrets.GITHUB_TOKEN }}
31-
32-
- name: Use Node.js v20.x
33-
uses: actions/setup-node@v4
34-
with:
35-
node-version: 20.x
36-
registry-url: 'https://registry.npmjs.org'
37-
38-
- name: Install dependencies
39-
run: npm ci
40-
41-
- name: Generate API data
42-
working-directory: ./projects/composition
43-
run: |
44-
npm run generate-json-api
45-
46-
# Instead of direct commit/push, create a PR
47-
- name: Create Pull Request
48-
id: cpr
49-
uses: peter-evans/create-pull-request@v6
50-
with:
51-
token: ${{ secrets.GITHUB_TOKEN }}
52-
# More descriptive commit message
53-
commit-message: 'chore: Update API documentation JSON files'
54-
# Use bot account for better tracking
55-
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
56-
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
57-
# Unique branch name using run number to avoid conflicts
58-
branch: api-docs-update-${{ github.run_number }}
59-
# Auto-delete branch after merge
60-
delete-branch: true
61-
title: 'chore: Update API documentation JSON files'
62-
# Detailed PR description with context
63-
body: |
64-
## Auto-generated API Documentation Update
65-
66-
This PR contains automatically generated API documentation files.
67-
68-
### Changes
69-
- Updated JSON API files based on latest component changes
70-
71-
### Workflow Run
72-
- Triggered by commit: ${{ github.sha }}
73-
- Run ID: ${{ github.run_id }}
74-
75-
---
76-
77-
🤖 This PR was automatically created by the documentation workflow.
78-
# Labels for organization and to skip changelog
79-
labels: |
80-
documentation
81-
automated
82-
skip-changelog
83-
84-
# Auto-merge the PR (requires repo settings to allow auto-merge)
85-
- name: Enable Pull Request Automerge
86-
if: steps.cpr.outputs.pull-request-operation == 'created'
87-
uses: peter-evans/enable-pull-request-automerge@v3
88-
with:
89-
token: ${{ secrets.GITHUB_TOKEN }}
90-
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
91-
merge-method: squash
92-
93-
# Auto-approve the PR so it can be merged
94-
- name: Auto approve PR
95-
if: steps.cpr.outputs.pull-request-operation == 'created'
96-
uses: hmarr/auto-approve-action@v4
97-
with:
98-
github-token: ${{ secrets.GITHUB_TOKEN }}
99-
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
100-
10117
# Build job
10218
build:
10319
runs-on: ubuntu-latest
104-
needs: generate-api-data
105-
# Only run if generate-api-data succeeded or was skipped (not failed)
106-
if: always() && (needs.generate-api-data.result == 'success' || needs.generate-api-data.result == 'skipped')
10720

10821
steps:
10922
- name: Checkout code

projects/composition/src/app/api-data/cps-datepicker.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
"name": "value",
152152
"optional": false,
153153
"readonly": false,
154-
"type": "null | Date",
154+
"type": "Date | null",
155155
"default": "null",
156156
"description": "Value of the datepicker."
157157
}
@@ -165,7 +165,7 @@
165165
"parameters": [
166166
{
167167
"name": "value",
168-
"type": "null | Date"
168+
"type": "Date | null"
169169
}
170170
],
171171
"description": "Callback to invoke on value change."

projects/composition/src/app/api-data/cps-radio-group.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"values": [
88
{
99
"name": "option",
10-
"optional": false,
10+
"optional": true,
1111
"readonly": false,
1212
"type": "CpsRadioOption",
1313
"description": "An option."

projects/composition/src/app/api-data/cps-timepicker.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"name": "value",
106106
"optional": false,
107107
"readonly": false,
108-
"type": "undefined | CpsTime",
108+
"type": "CpsTime | undefined",
109109
"description": "Value of the timepicker."
110110
}
111111
]

0 commit comments

Comments
 (0)