-
Notifications
You must be signed in to change notification settings - Fork 179
149 lines (120 loc) · 4.59 KB
/
openapi-ci.yaml
File metadata and controls
149 lines (120 loc) · 4.59 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
name: OpenAPI checks
on:
pull_request:
push:
branches:
- master
jobs:
lint:
name: Lint specification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: "npm"
cache-dependency-path: "package-lock.json"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: npm ci --force
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Lint with Redocly
run: npm run openapi:lint:redocly -- --format=github-actions
- name: Lint with Spectral
run: npm run openapi:lint:spectral -- --format=github-actions
- name: Lint YAML style
run: npm run openapi:lint:yaml
build:
name: Build bundled specification
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: "npm"
cache-dependency-path: "package-lock.json"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: npm ci --force
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build bundles
run: npm run openapi:build
- name: Upload bundles
uses: actions/upload-artifact@v6
with:
name: openapi-bundles
path: |
static/api/openapi.json
static/api/openapi.yaml
retention-days: 1
validate:
name: Validate bundled specification
runs-on: ubuntu-latest
needs: [lint, build]
steps:
- uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: "npm"
cache-dependency-path: "package-lock.json"
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: npm ci --force
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Download bundles
uses: actions/download-artifact@v7
with:
name: openapi-bundles
path: static/api/
- name: Validate YAML bundle
run: npx redocly lint static/api/openapi.yaml
- name: Validate JSON bundle
run: npx redocly lint static/api/openapi.json
- name: Check bundle sizes
run: |
JSON_SIZE=$(stat -f%z static/api/openapi.json 2>/dev/null || stat -c%s static/api/openapi.json)
YAML_SIZE=$(stat -f%z static/api/openapi.yaml 2>/dev/null || stat -c%s static/api/openapi.yaml)
echo "Bundle sizes:"
echo " JSON: $JSON_SIZE bytes"
echo " YAML: $YAML_SIZE bytes"
if [ "$JSON_SIZE" -lt 1000 ] || [ "$YAML_SIZE" -lt 1000 ]; then
echo "Error: Bundle files are suspiciously small"
exit 1
fi
echo "✓ Bundles have valid sizes"
trigger-client-model-regeneration:
name: Trigger Python client model regeneration
runs-on: ubuntu-latest
needs: [validate]
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
- name: Check if OpenAPI files changed
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
openapi:
- 'apify-api/openapi/**'
- name: Trigger apify-client-python model regeneration
if: steps.filter.outputs.openapi == 'true'
run: |
gh workflow run regenerate_models.yaml \
--repo apify/apify-client-python \
--field docs_pr_number=${{ github.event.pull_request.number }} \
--field docs_pr_branch=${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}