@@ -12,11 +12,13 @@ permissions:
1212 contents : read
1313
1414jobs :
15+ # Determine which tests to run based on changed files
1516 detect-changes :
1617 runs-on : ubuntu-latest
1718 outputs :
1819 single-parser : ${{ steps.detect-parser.outputs.parser }}
1920 run-all-tests : ${{ steps.detect-parser.outputs.run-all }}
21+ schema-generation : ${{ steps.filter.outputs.schema-generation }}
2022 steps :
2123 - uses : actions/checkout@v4
2224 - uses : dorny/paths-filter@v3
3335 - 'pyproject.toml'
3436 - 'scripts/**'
3537 - '.github/**'
38+ schema-generation:
39+ - 'src/allotropy/allotrope/schemas/**'
40+ - 'src/allotropy/allotrope/schema_parser/**'
41+ - 'src/allotropy/allotrope/models/**'
42+ - 'src/allotropy/allotrope/schemas.py'
43+ - 'src/allotropy/exceptions.py'
44+ - 'scripts/generate_schemas.py'
45+ - 'scripts/download_schema.py'
46+ - 'tests/allotrope/schema_parser/**'
47+ - 'pyproject.toml'
3648 - name : Detect single parser changes
3749 id : detect-parser
3850 run : |
@@ -93,11 +105,11 @@ jobs:
93105 run : pip install "hatch>=1.13.0"
94106 - name : Install click
95107 run : pip install click!=8.3.0
96- - name : Run Tests
108+ - name : Run Tests (excluding schema generation)
97109 run : |
98110 if [[ "${{ needs.detect-changes.outputs.run-all }}" == "true" ]]; then
99111 echo "Running all tests"
100- hatch run test_all.py3.10:pytest -n 2 tests
112+ hatch run test_all.py3.10:pytest -n 2 tests --ignore=tests/allotrope/schema_parser/generate_schemas_test.py
101113 else
102114 echo "Running tests for parser: ${{ needs.detect-changes.outputs.single-parser }}"
103115 hatch run test_all.py3.10:pytest -n 2 tests/parsers/${{ needs.detect-changes.outputs.single-parser }} tests/parser_factory_test.py::test_table_contents
@@ -121,11 +133,11 @@ jobs:
121133 # NOTE: due to bug: https://github.com/pallets/click/issues/3066
122134 - name : Install click
123135 run : pip install click!=8.3.0
124- - name : Run Tests
136+ - name : Run Tests (excluding schema generation)
125137 run : |
126138 if [[ "${{ needs.detect-changes.outputs.run-all }}" == "true" ]]; then
127139 echo "Running all tests"
128- hatch run test_all.py3.11:pytest -n 2 tests
140+ hatch run test_all.py3.11:pytest -n 2 tests --ignore=tests/allotrope/schema_parser/generate_schemas_test.py
129141 else
130142 echo "Running tests for parser: ${{ needs.detect-changes.outputs.single-parser }}"
131143 hatch run test_all.py3.11:pytest -n 2 tests/parsers/${{ needs.detect-changes.outputs.single-parser }} tests/parser_factory_test.py::test_table_contents
@@ -148,17 +160,43 @@ jobs:
148160 run : pip install "hatch>=1.13.0"
149161 - name : Install click
150162 run : pip install click!=8.3.0
151- - name : Run Tests
163+ - name : Run Tests (excluding schema generation)
152164 run : |
153165 if [[ "${{ needs.detect-changes.outputs.run-all }}" == "true" ]]; then
154166 echo "Running all tests"
155- hatch run test_all.py3.12:pytest -n 2 tests
167+ hatch run test_all.py3.12:pytest -n 2 tests --ignore=tests/allotrope/schema_parser/generate_schemas_test.py
156168 else
157169 echo "Running tests for parser: ${{ needs.detect-changes.outputs.single-parser }}"
158170 hatch run test_all.py3.12:pytest -n 2 tests/parsers/${{ needs.detect-changes.outputs.single-parser }} tests/parser_factory_test.py::test_table_contents
159171 fi
160172 timeout-minutes : 15
161173
174+ # Schema generation test - only runs when relevant files change or on main branch
175+ schema_generation_test :
176+ needs : detect-changes
177+ # Always run on main branch, otherwise only when schema files change
178+ if : ${{ github.ref == 'refs/heads/main' || needs.detect-changes.outputs.schema-generation == 'true' }}
179+ runs-on : ubuntu-latest
180+ name : Schema Generation Test
181+ strategy :
182+ matrix :
183+ python-version : ["3.10"] # Only run on one Python version since output is the same
184+
185+ steps :
186+ - uses : actions/checkout@v4
187+ with :
188+ lfs : true
189+ - uses : actions/setup-python@v5
190+ with :
191+ python-version : ${{ matrix.python-version }}
192+ - name : Install hatch
193+ run : pip install "hatch>=1.13.0"
194+ - name : Install click
195+ run : pip install click!=8.3.0
196+ - name : Run Schema Generation Test
197+ run : hatch run test_all.py${{ matrix.python-version }}:pytest tests/allotrope/schema_parser/generate_schemas_test.py -v
198+ timeout-minutes : 5
199+
162200 lint :
163201 runs-on : ubuntu-latest
164202 name : Quality Checks
0 commit comments