@@ -119,7 +119,7 @@ jobs:
119
119
lint :
120
120
needs : determine-test-scope
121
121
if : ( needs.determine-test-scope.outputs.local_tests == 'true' ) || ( needs.determine-test-scope.outputs.remote_tests == 'true' )
122
- name : Run linting
122
+ name : verify- linting
123
123
runs-on : ubuntu-latest
124
124
container : ghcr.io/astral-sh/uv:debian
125
125
steps :
@@ -134,7 +134,102 @@ jobs:
134
134
run : ruff format --check --diff
135
135
- name : Run ruff check
136
136
run : ruff check tidy3d
137
-
137
+
138
+ verify-schema-change :
139
+ name : verify-schema-change
140
+ needs : determine-test-scope
141
+ if : (( needs.determine-test-scope.outputs.local_tests == 'true' ) || ( needs.determine-test-scope.outputs.remote_tests == 'true' )) && (github.event_name == 'pull_request')
142
+ runs-on : ubuntu-latest
143
+ container : ghcr.io/astral-sh/uv:debian
144
+ defaults :
145
+ run :
146
+ shell : bash
147
+ steps :
148
+ - name : checkout-pr-branch
149
+ uses : actions/checkout@v4
150
+ with :
151
+ path : ' pr'
152
+
153
+ - name : checkou-develop-branch
154
+ uses : actions/checkout@v4
155
+ with :
156
+ ref : ' develop'
157
+ path : ' develop'
158
+
159
+ - name : install-depedencies
160
+ run : |
161
+ uv venv $GITHUB_WORKSPACE/.venv -p 3.11
162
+ source $GITHUB_WORKSPACE/.venv/bin/activate
163
+ uv pip install -e "$GITHUB_WORKSPACE/pr"
164
+
165
+ - name : get-tidy3d-version
166
+ id : get-version
167
+ run : |
168
+ source $GITHUB_WORKSPACE/.venv/bin/activate
169
+ version=$(python -c "import tidy3d; print(tidy3d.__version__)")
170
+ echo "tidy3d version is $version"
171
+ echo "version=$version" >> $GITHUB_OUTPUT
172
+
173
+ - name : verify-committed-schema
174
+ run : |
175
+ echo "Regenerating schema to check if committed files are up-to-date..."
176
+ source $GITHUB_WORKSPACE/.venv/bin/activate
177
+ python $GITHUB_WORKSPACE/pr/scripts/regenerate_schema.py
178
+
179
+ echo "Checking for differences..."
180
+ cd pr
181
+ git diff --exit-code -- tidy3d/schemas
182
+ echo "✅ Committed schema is up-to-date."
183
+
184
+ - name : run-schema-diff
185
+ id : schema-diff
186
+ run : |
187
+ # Use git diff to compare the two directories and get a list of changes
188
+ # The command exits with 0 if no changes, 1 if changes are found.
189
+ # We use '|| true' to prevent the workflow from stopping here on failure.
190
+ diff_output=$(git diff --no-index --name-status ./develop/tidy3d/schemas ./pr/tidy3d/schemas || true)
191
+
192
+ # Check if there are any changes
193
+ if [ -z "$diff_output" ]; then
194
+ echo "✅ Schemas are up-to-date."
195
+ echo "changed=false" >> $GITHUB_OUTPUT
196
+ exit 0
197
+ fi
198
+
199
+ # If there are changes, create a Markdown table
200
+ echo "❌ Schema has changed! Please regenerate and commit the changes."
201
+ echo "changed=true" >> $GITHUB_OUTPUT
202
+
203
+ # Write the report to the GitHub Step Summary
204
+ echo "### Schema Change Summary" >> $GITHUB_STEP_SUMMARY
205
+ echo "| Status | File |" >> $GITHUB_STEP_SUMMARY
206
+ echo "|:---:|:---|" >> $GITHUB_STEP_SUMMARY
207
+
208
+ echo "$diff_output" | while read -r line; do
209
+ status_code=$(echo "$line" | cut -f1)
210
+ file_path=$(echo "$line" | cut -f2 | sed 's#pr/tidy3d/schemas/##') # Clean up path
211
+
212
+ case $status_code in
213
+ "A") status="Added 🟢";;
214
+ "M") status="Modified 🟡";;
215
+ "D") status="Removed 🔴";;
216
+ *) status="Unknown";;
217
+ esac
218
+
219
+ echo "| $status | \`$file_path\` |" >> $GITHUB_STEP_SUMMARY
220
+ done
221
+
222
+ - name : verify-allowed-changes
223
+ if : steps.schema-diff.outputs.changed == 'true'
224
+ run : |
225
+ version="${{ steps.get-version.outputs.version }}"
226
+ if [[ "$version" == *rc* ]]; then
227
+ echo "✅ Passing: Schema changed on a release candidate version ($version), which is permitted."
228
+ else
229
+ echo "❌ Failing: Schema changed on a non-rc release version ($version)."
230
+ exit 1
231
+ fi
232
+
138
233
local-tests :
139
234
# Run on open PRs OR when manually triggered with local_tests=true
140
235
needs : determine-test-scope
@@ -332,7 +427,7 @@ jobs:
332
427
( needs.determine-test-scope.outputs.pr_approval_state == 'true' ) &&
333
428
( needs.determine-test-scope.outputs.local_tests == 'true' ) ||
334
429
( needs.determine-test-scope.outputs.remote_tests == 'true' )
335
- needs : [local-tests, remote-tests, lint]
430
+ needs : [local-tests, remote-tests, lint, verify-schema-change ]
336
431
runs-on : ubuntu-latest
337
432
steps :
338
433
- name : check-passing-remote-tests
@@ -343,6 +438,9 @@ jobs:
343
438
if [[ "${{ needs.lint.result }}" != 'success' ]]; then
344
439
echo "❌ Linting failed or was skipped."
345
440
exit 1
441
+ elif [[ "${{ needs.verify-schema-change.result }}" != 'success' ]]; then
442
+ echo "❌ verify-schema-change failed or was skipped."
443
+ exit 1
346
444
elif [[ "${{ needs.remote-tests.result }}" != 'success' ]]; then
347
445
echo "❌ remote-tests failed or were skipped."
348
446
exit 1 # Given remote-tests always run after a PR is approved
0 commit comments