Implementation:Astronomer Astronomer cosmos CI Test Workflow
| Knowledge Sources | |
|---|---|
| Domains | CI/CD, Testing, GitHub Actions |
| Last Updated | 2026-02-07 17:00 GMT |
Overview
GitHub Actions CI/CD workflow that orchestrates the full test suite for the astronomer-cosmos project, including type checking, unit tests, integration tests, performance tests, and Kubernetes tests across multiple Python, Airflow, and dbt version matrices.
Description
The test workflow is the primary continuous integration pipeline for the astronomer-cosmos repository. It is triggered on pushes to the main branch and on pull_request_target events (including forked PRs). The workflow uses concurrency groups keyed on the workflow name and head ref to cancel in-progress runs when new commits arrive.
The workflow begins with an Authorize job that acts as a security guardrail. For pull requests originating from forks, this job requires manual approval from an external environment before any downstream jobs can proceed. Internal PRs use the internal environment which does not require explicit approval.
All subsequent jobs depend on the Authorize gate and run in parallel across configurable strategy matrices. The build tool hatch (version >= 1.14.2) is used to manage Python environments and run test commands. uv is used as the pip installer for faster dependency resolution.
Key jobs in the workflow:
- Type-Check -- Runs mypy type checking using Python 3.10 against Airflow 2.10 and dbt 1.9.
- Run-Unit-Tests -- Executes the unit test suite across Python 3.10-3.13, Airflow 2.9-3.1, and dbt 1.10. Python 3.13 is excluded from Airflow versions prior to 3.1.0. Coverage artifacts are uploaded.
- Run-Integration-Tests -- Runs integration tests with a PostgreSQL 14.18 service container. Tests against Python 3.10-3.13, Airflow 2.9-3.1, and dbt 1.11. Configures connections for Postgres, AWS S3, GCP GS, Azure ABFS, Databricks (mock), and DuckDB.
- Run-Integration-Tests-Expensive -- A smaller matrix (Python 3.11, Airflow 2.9, dbt 1.9) for expensive integration tests that exercise Databricks connectivity using real credentials.
- Run-Integration-Tests-DBT-1-5-4 -- Tests backward compatibility with dbt 1.5 using the altered_jaffle_shop project and a single DAG (basic_cosmos_task_group.py).
- Run-Integration-Tests-DBT-Async -- Tests async dbt execution across dbt versions 1.6 through 1.11, Airflow 2.11 and 3.0. Uses the altered_jaffle_shop project with dataset alias disabled.
- Run-Integration-dbt-fusion-Tests -- Tests dbt Fusion (version 2.0) integration with Snowflake. Includes resource cleanup that drops Snowflake resources after each run.
- Run-Performance-Tests -- Benchmarks DAG parsing performance with model counts of 1, 10, 50, 100, and 500 across Airflow 2.10 and 3.0. Writes results to
/tmp/performance_results.txtand publishes them as a GitHub step summary. - Run-Kubernetes-Tests -- Spins up a KinD (Kubernetes in Docker) cluster and runs Kubernetes operator integration tests using Python 3.12, Airflow 2.10 and 3.0, dbt 1.11.
- Code-Coverage -- Aggregates all coverage artifacts from unit, integration, expensive, and Kubernetes test jobs. Combines them using the coverage tool and uploads the final report to Codecov.
Usage
This workflow runs automatically on every push to main and on every pull request targeting main. Contributors do not invoke it manually. For forked PRs, a maintainer must approve the workflow run from the GitHub Actions UI before tests execute.
Code Reference
Source Location
- Repository: Astronomer_Astronomer_cosmos
- File: .github/workflows/test.yml
- Lines: 1-712
Signature
name: test
on:
push:
branches: [main]
pull_request_target:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
SCARF_NO_ANALYTICS: "true"
Import
# Not applicable -- this is a GitHub Actions workflow triggered by push/PR events.
# Referenced internally by GitHub Actions CI infrastructure.
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| push event | GitHub event | No | Triggered on pushes to the main branch |
| pull_request_target event | GitHub event | No | Triggered on pull requests targeting main (including forks) |
| AIRFLOW_CONN_AWS_S3_CONN | secret | No | AWS S3 connection string for remote cache integration tests |
| AIRFLOW_CONN_GCP_GS_CONN | secret | No | GCP Google Storage connection string for integration tests |
| AIRFLOW_CONN_AZURE_ABFS_CONN | secret | No | Azure ABFS connection string for integration tests |
| COSMOS_CONN_POSTGRES_PASSWORD | secret | No | Postgres password for cosmos integration tests |
| AIRFLOW_CONN_DATABRICKS_DEFAULT | secret | No | Databricks connection for expensive integration tests |
| DATABRICKS_CLUSTER_ID | secret | No | Databricks cluster ID for expensive integration tests |
| SNOWFLAKE_ACCOUNT | secret | No | Snowflake account identifier for dbt Fusion tests |
| SNOWFLAKE_USER | secret | No | Snowflake username for dbt Fusion tests |
| SNOWFLAKE_PASSWORD | secret | No | Snowflake password for dbt Fusion tests |
| CODECOV_TOKEN | secret | No | Token for uploading coverage reports to Codecov |
Outputs
| Name | Type | Description |
|---|---|---|
| coverage artifacts | GitHub Artifact | Per-job .coverage files uploaded as artifacts
|
| coverage.xml | Codecov report | Combined coverage report uploaded to Codecov |
| performance_results.txt | Step summary | Performance benchmark results published as a GitHub step summary |
Usage Examples
Basic Example
# This workflow is triggered automatically. To run tests locally
# using the same hatch environments, use:
#
# Install hatch:
pip install "hatch>=1.14.2"
# Run type checking:
hatch run tests.py3.10-2.10-1.9:type-check
# Run unit tests with coverage:
hatch run tests.py3.12-2.10-1.10:test-cov
# Run integration tests (requires Postgres service):
hatch run tests.py3.12-2.10-1.11:test-integration-setup
hatch run tests.py3.12-2.10-1.11:test-integration
Matrix Configuration Example
# The unit test matrix covers these combinations:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
airflow-version: ["2.9", "2.10", "2.11", "3.0", "3.1"]
dbt-version: ["1.10"]
exclude:
# Python 3.13 is only tested with Airflow 3.1
- python-version: "3.13"
airflow-version: "2.9"
- python-version: "3.13"
airflow-version: "2.10"
- python-version: "3.13"
airflow-version: "2.11"
- python-version: "3.13"
airflow-version: "3.0"
Related Pages
- Astronomer_Astronomer_cosmos_Package_Exports -- The package entry point tested by this workflow
- hatch -- Hatch is used as the Python project and environment manager
- uv -- Used as a faster pip alternative for dependency installation
- Codecov -- Coverage reports are uploaded to Codecov