-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change CI to run coverage after tests pass (#461)
There are two benefits to this change: 1. The CI will wait for all the coverage to be collected, avoiding failing a build incorrectly because of code coverage that was not collected yet 2. Fewer requests to the third-party `codecov` service - we only worry about code coverage when/if tests pass
- Loading branch information
Showing
1 changed file
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,10 +55,11 @@ jobs: | |
run: | | ||
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-cov | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
- name: Upload coverage to Github | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
name: coverage-unit-test-${{ matrix.python-version }}-${{ matrix.airflow-version }} | ||
path: .coverage | ||
|
||
Run-Integration-Tests: | ||
needs: Authorize | ||
|
@@ -115,10 +116,11 @@ jobs: | |
DATABRICKS_CLUSTER_ID: ${{ secrets.DATABRICKS_CLUSTER_ID }} | ||
COSMOS_CONN_POSTGRES_PASSWORD: ${{ secrets.COSMOS_CONN_POSTGRES_PASSWORD }} | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
- name: Upload coverage to Github | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
name: coverage-integration-test-${{ matrix.python-version }}-${{ matrix.airflow-version }} | ||
path: .coverage | ||
|
||
|
||
|
||
|
@@ -154,9 +156,6 @@ jobs: | |
.nox | ||
key: integration-expensive-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('cosmos/__init__.py') }} | ||
|
||
- name: Checkout pull/${{ github.event.number }} | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
|
@@ -182,7 +181,50 @@ jobs: | |
DATABRICKS_CLUSTER_ID: ${{ secrets.DATABRICKS_CLUSTER_ID }} | ||
COSMOS_CONN_POSTGRES_PASSWORD: ${{ secrets.COSMOS_CONN_POSTGRES_PASSWORD }} | ||
|
||
- name: Upload coverage to Github | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: coverage-integration-expensive-test-${{ matrix.python-version }}-${{ matrix.airflow-version }} | ||
path: .coverage | ||
|
||
env: | ||
AIRFLOW_HOME: /home/runner/work/astronomer-cosmos/astronomer-cosmos/ | ||
AIRFLOW_CONN_AIRFLOW_DB: postgres://postgres:[email protected]:5432/postgres | ||
PYTHONPATH: /home/runner/work/astronomer-cosmos/astronomer-cosmos/:$PYTHONPATH | ||
AIRFLOW_CONN_DATABRICKS_DEFAULT: ${{ secrets.AIRFLOW_CONN_DATABRICKS_DEFAULT }} | ||
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }} | ||
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }} | ||
DATABRICKS_WAREHOUSE_ID: ${{ secrets.DATABRICKS_WAREHOUSE_ID }} | ||
DATABRICKS_CLUSTER_ID: ${{ secrets.DATABRICKS_CLUSTER_ID }} | ||
|
||
Code-Coverage: | ||
if: github.event.action != 'labeled' | ||
needs: | ||
- Run-Unit-Tests | ||
- Run-Integration-Tests | ||
- Run-Integration-Tests-Expensive | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.10' | ||
- name: Install coverage | ||
run: | | ||
pip3 install coverage | ||
- name: Download all coverage artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
path: ./coverage | ||
- name: Combine coverage | ||
run: | | ||
coverage combine ./coverage/coverage*/.coverage | ||
coverage report | ||
coverage xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
fail_ci_if_error: true | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: coverage.xml |