Skip to content

Commit d21506d

Browse files
rikublockpsychedelicious
authored andcommitted
feat(ci): add typegen check workflow
1 parent a498949 commit d21506d

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.github/workflows/typegen-checks.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Runs typegen schema quality checks.
2+
# Frontend types should match the server.
3+
#
4+
# Checks for changes to files before running the checks.
5+
# If always_run is true, always runs the checks.
6+
7+
name: 'typegen checks'
8+
9+
on:
10+
push:
11+
branches:
12+
- 'main'
13+
pull_request:
14+
types:
15+
- 'ready_for_review'
16+
- 'opened'
17+
- 'synchronize'
18+
merge_group:
19+
workflow_dispatch:
20+
inputs:
21+
always_run:
22+
description: 'Always run the checks'
23+
required: true
24+
type: boolean
25+
default: true
26+
workflow_call:
27+
inputs:
28+
always_run:
29+
description: 'Always run the checks'
30+
required: true
31+
type: boolean
32+
default: true
33+
34+
jobs:
35+
typegen-checks:
36+
runs-on: ubuntu-22.04
37+
timeout-minutes: 15 # expected run time: <5 min
38+
steps:
39+
- name: checkout
40+
uses: actions/checkout@v4
41+
42+
- name: check for changed files
43+
if: ${{ inputs.always_run != true }}
44+
id: changed-files
45+
uses: tj-actions/changed-files@v42
46+
with:
47+
files_yaml: |
48+
src:
49+
- 'pyproject.toml'
50+
- 'invokeai/**'
51+
52+
- name: setup python
53+
if: ${{ steps.changed-files.outputs.src_any_changed == 'true' || inputs.always_run == true }}
54+
uses: actions/setup-python@v5
55+
with:
56+
python-version: '3.10'
57+
cache: pip
58+
cache-dependency-path: pyproject.toml
59+
60+
- name: install python dependencies
61+
if: ${{ steps.changed-files.outputs.src_any_changed == 'true' || inputs.always_run == true }}
62+
run: pip3 install --use-pep517 --editable="."
63+
64+
- name: install frontend dependencies
65+
if: ${{ steps.changed-files.outputs.src_any_changed == 'true' || inputs.always_run == true }}
66+
uses: ./.github/actions/install-frontend-deps
67+
68+
- name: copy schema
69+
if: ${{ steps.changed-files.outputs.src_any_changed == 'true' || inputs.always_run == true }}
70+
run: cp invokeai/frontend/web/src/services/api/schema.ts invokeai/frontend/web/src/services/api/schema_orig.ts
71+
shell: bash
72+
73+
- name: generate schema
74+
if: ${{ steps.changed-files.outputs.src_any_changed == 'true' || inputs.always_run == true }}
75+
run: make frontend-typegen
76+
shell: bash
77+
78+
- name: compare files
79+
if: ${{ steps.changed-files.outputs.src_any_changed == 'true' || inputs.always_run == true }}
80+
run: |
81+
if ! diff invokeai/frontend/web/src/services/api/schema.ts invokeai/frontend/web/src/services/api/schema_orig.ts; then
82+
echo "Files are different!";
83+
exit 1;
84+
fi
85+
shell: bash

0 commit comments

Comments
 (0)