-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Reduce the amount taking to run tests in the CI from 5h to 11min (…
…#1297) **Context** Closes: #1299 Some CI jobs took an outrageous amount of time to run. One of our CI test pipeline jobs was taking over five hours to run: <img width="1624" alt="Screenshot 2024-11-05 at 14 52 58" src="https://github.com/user-attachments/assets/8d8264c9-70f7-4381-b2dd-847244e58a98"> https://github.com/astronomer/astronomer-cosmos/actions/runs/11505558596 More recently, this same job started taking over 6 hours to run and started timing out in the CI, making Cosmos' main branch red for both unit and integration tests for Airflow 2.6. The underlying reason is that it took a long time to resolve dependencies. This seems to have happened since October 29, as seen on the commit 84c5fbd to main. Example: https://github.com/astronomer/astronomer-cosmos/actions/runs/11594745046/job/32330864858 **About this change** This PR solves the original issue by changing where and how we install Airflow dependencies, simplifying the previous setup. We manage Airflow test dependencies in the `pre-install-airflow.sh` file, not in `pyproject.toml`, other `sh`, or the Github action. We are also being strict as we can dependent on the Airflow version. Where possible, we use constraints. Where different providers' dependencies conflict with previous versions of Airflow, we just ensure the expected version remains being used after the installation. Example of a successful run: <img width="1624" alt="Screenshot 2024-11-05 at 14 52 48" src="https://github.com/user-attachments/assets/7e16c8fc-0357-43e1-9ad9-e033d9d1a3b5"> https://github.com/astronomer/astronomer-cosmos/actions/runs/11685652312 **Bonus** I realised with this change that users who use K8s and want to define different paths for their dbt projects in Airflow and K8s were facing an issue. This problem was evident when running the k8s example DAG. I've fixed the problem as part of this PR. **Follow-up actions** Since this has been taking a long time to solve and our main branch is still red, I commented out two tasks that were failing tests - and I've logged a follow-up issue for us to address this: #1304
- Loading branch information
Showing
9 changed files
with
109 additions
and
78 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 |
---|---|---|
|
@@ -309,6 +309,7 @@ jobs: | |
AIRFLOW_CONN_AZURE_ABFS_CONN: ${{ secrets.AIRFLOW_CONN_AZURE_ABFS_CONN }} | ||
AIRFLOW__CORE__DAGBAG_IMPORT_TIMEOUT: 90.0 | ||
PYTHONPATH: /home/runner/work/astronomer-cosmos/astronomer-cosmos/:$PYTHONPATH | ||
AIRFLOW__COSMOS__ENABLE_CACHE: 0 | ||
COSMOS_CONN_POSTGRES_PASSWORD: ${{ secrets.COSMOS_CONN_POSTGRES_PASSWORD }} | ||
DATABRICKS_CLUSTER_ID: mock | ||
DATABRICKS_HOST: mock | ||
|
@@ -388,6 +389,7 @@ jobs: | |
AIRFLOW_CONN_AZURE_ABFS_CONN: ${{ secrets.AIRFLOW_CONN_AZURE_ABFS_CONN }} | ||
AIRFLOW__CORE__DAGBAG_IMPORT_TIMEOUT: 90.0 | ||
PYTHONPATH: /home/runner/work/astronomer-cosmos/astronomer-cosmos/:$PYTHONPATH | ||
AIRFLOW__COSMOS__ENABLE_CACHE: 0 | ||
COSMOS_CONN_POSTGRES_PASSWORD: ${{ secrets.COSMOS_CONN_POSTGRES_PASSWORD }} | ||
DATABRICKS_CLUSTER_ID: mock | ||
DATABRICKS_HOST: mock | ||
|
@@ -489,7 +491,7 @@ jobs: | |
strategy: | ||
matrix: | ||
python-version: [ "3.11" ] | ||
airflow-version: [ "2.9" ] | ||
airflow-version: [ "2.10" ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
|
@@ -511,21 +513,14 @@ jobs: | |
|
||
- name: Install packages and dependencies | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
pip install --upgrade pip | ||
pip install -e ".[tests]" | ||
pip install apache-airflow-providers-cncf-kubernetes | ||
pip install dbt-postgres==1.8.2 psycopg2==2.9.3 pytz | ||
pip install apache-airflow==${{ matrix.airflow-version }} | ||
# hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze | ||
python -m pip install uv | ||
uv pip install --system hatch | ||
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze | ||
- name: Run kubernetes tests | ||
run: | | ||
source venv/bin/activate | ||
sh ./scripts/test/kubernetes-setup.sh | ||
cd dev && sh ../scripts/test/integration-kubernetes.sh | ||
# hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-kubernetes | ||
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-kubernetes-setup | ||
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-kubernetes | ||
env: | ||
AIRFLOW_HOME: /home/runner/work/astronomer-cosmos/astronomer-cosmos/ | ||
AIRFLOW_CONN_EXAMPLE_CONN: postgres://postgres:[email protected]:5432/postgres | ||
|
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
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
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
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
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
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
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
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