Skip to content

Commit 30b2e6c

Browse files
authored
Separate CI Job to run Pytest collection check (#29923)
Before we attempt to run tests in parallel, we quickly check once if Pytest collection works. This is in order to avoid costly parallel test execution if that makes no sense to initialize all the parallel machines. This check used to be done in "Wait for CI Inages" step, but running it there has the undesireable side effect that it is not obvious that it's the collection that fails, also it prevents other jobs (for example static checks and docs building) from running. This means that the contributor does not get all the feedback that could be given immediately. This PR separates the collection into separate job and only makes "test" jobs depend on it - all the other jobs that need CI image depend on "wait for CI image" one and should continue running even if pytest collection fails. CI diagrams are also updated to reflect a bit better optionality and parallelism of the CI jobs.
1 parent c2acd1d commit 30b2e6c

File tree

3 files changed

+158
-97
lines changed

3 files changed

+158
-97
lines changed

β€Ž.github/workflows/ci.yml

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,6 @@ jobs:
540540
env:
541541
PYTHON_VERSIONS: ${{ needs.build-info.outputs.python-versions-list-as-string }}
542542
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
543-
- name: "Tests Pytest collection: ${{matrix.python-version}}"
544-
run: breeze shell "python /opt/airflow/scripts/in_container/test_pytest_collection.py"
545543
- name: "Fix ownership"
546544
run: breeze ci fix-ownership
547545
if: always()
@@ -834,13 +832,43 @@ jobs:
834832
- name: "Post Helm Tests"
835833
uses: ./.github/actions/post_tests
836834

835+
test-pytest-collection:
836+
timeout-minutes: 5
837+
name: "Test Pytest collection"
838+
runs-on: "${{needs.build-info.outputs.runs-on}}"
839+
needs: [build-info, wait-for-ci-images]
840+
if: needs.build-info.outputs.image-build == 'true'
841+
env:
842+
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
843+
BACKEND: sqlite
844+
PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}"
845+
steps:
846+
- name: Cleanup repo
847+
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
848+
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
849+
uses: actions/checkout@v3
850+
with:
851+
persist-credentials: false
852+
- name: "Install Breeze"
853+
uses: ./.github/actions/breeze
854+
- name: Wait for CI images ${{ env.PYTHON_VERSIONS }}:${{ env.IMAGE_TAG }}
855+
id: wait-for-images
856+
run: breeze ci-image pull --wait-for-image --tag-as-latest
857+
env:
858+
DEBUG_RESOURCES: ${{needs.build-info.outputs.debug-resources}}
859+
- name: "Tests Pytest collection"
860+
run: breeze shell "python /opt/airflow/scripts/in_container/test_pytest_collection.py"
861+
- name: "Fix ownership"
862+
run: breeze ci fix-ownership
863+
if: always()
864+
837865
tests-postgres:
838866
timeout-minutes: 130
839867
name: >
840868
Postgres${{matrix.postgres-version}},Py${{matrix.python-version}}:
841869
${{needs.build-info.outputs.test-types}}
842870
runs-on: "${{needs.build-info.outputs.runs-on}}"
843-
needs: [build-info, wait-for-ci-images]
871+
needs: [build-info, test-pytest-collection]
844872
strategy:
845873
matrix:
846874
python-version: "${{fromJson(needs.build-info.outputs.python-versions)}}"
@@ -884,7 +912,7 @@ jobs:
884912
name: >
885913
MySQL${{matrix.mysql-version}}, Py${{matrix.python-version}}: ${{needs.build-info.outputs.test-types}}
886914
runs-on: "${{needs.build-info.outputs.runs-on}}"
887-
needs: [build-info, wait-for-ci-images]
915+
needs: [build-info, test-pytest-collection]
888916
strategy:
889917
matrix:
890918
python-version: "${{fromJson(needs.build-info.outputs.python-versions)}}"
@@ -928,7 +956,7 @@ jobs:
928956
name: >
929957
MSSQL${{matrix.mssql-version}}, Py${{matrix.python-version}}: ${{needs.build-info.outputs.test-types}}
930958
runs-on: "${{needs.build-info.outputs.runs-on}}"
931-
needs: [build-info, wait-for-ci-images]
959+
needs: [build-info, test-pytest-collection]
932960
strategy:
933961
matrix:
934962
python-version: "${{fromJson(needs.build-info.outputs.python-versions)}}"
@@ -970,7 +998,7 @@ jobs:
970998
name: >
971999
Sqlite Py${{matrix.python-version}}: ${{needs.build-info.outputs.test-types}}
9721000
runs-on: "${{needs.build-info.outputs.runs-on}}"
973-
needs: [build-info, wait-for-ci-images]
1001+
needs: [build-info, test-pytest-collection]
9741002
strategy:
9751003
matrix:
9761004
python-version: ${{ fromJson(needs.build-info.outputs.python-versions) }}
@@ -1011,7 +1039,7 @@ jobs:
10111039
timeout-minutes: 130
10121040
name: Integration Tests Postgres
10131041
runs-on: "${{needs.build-info.outputs.runs-on}}"
1014-
needs: [build-info, wait-for-ci-images]
1042+
needs: [build-info, test-pytest-collection]
10151043
env:
10161044
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
10171045
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
@@ -1071,7 +1099,7 @@ jobs:
10711099
timeout-minutes: 130
10721100
name: Integration Tests MySQL
10731101
runs-on: "${{needs.build-info.outputs.runs-on}}"
1074-
needs: [build-info, wait-for-ci-images]
1102+
needs: [build-info, test-pytest-collection]
10751103
env:
10761104
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
10771105
TEST_TYPES: "${{needs.build-info.outputs.test-types}}"
@@ -1112,7 +1140,7 @@ jobs:
11121140
name: "Quarantined tests"
11131141
runs-on: "${{needs.build-info.outputs.runs-on}}"
11141142
continue-on-error: true
1115-
needs: [build-info, wait-for-ci-images]
1143+
needs: [build-info, test-pytest-collection]
11161144
env:
11171145
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
11181146
TEST_TYPES: "Quarantined"

β€ŽCI.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ This workflow is a regular workflow that performs all checks of Airflow code.
382382
+---------------------------------+----------------------------------------------------------+----------+----------+-----------+-------------------+
383383
| Build docs | Builds documentation | Yes | Yes | Yes | Yes |
384384
+---------------------------------+----------------------------------------------------------+----------+----------+-----------+-------------------+
385+
| Test Pytest collection | Tests if pytest collection works | Yes | Yes | Yes | Yes |
386+
+---------------------------------+----------------------------------------------------------+----------+----------+-----------+-------------------+
385387
| Tests | Run the Pytest unit tests (Backend/Python matrix) | Yes | Yes | Yes | Yes (8) |
386388
+---------------------------------+----------------------------------------------------------+----------+----------+-----------+-------------------+
387389
| Integration tests | Runs integration tests (Postgres/Mysql) | Yes | Yes | Yes | Yes (9) |

0 commit comments

Comments
 (0)