Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable running all integration tests against Kind in the CI #95

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: test
on:
push:
branches: [ "main" ]
branches: [ "main", "issue-81-enable-integration-tests" ]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
branches: [ "main", "issue-81-enable-integration-tests" ]
branches: [ "main" ]

pull_request_target:
branches: ["main"]

Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
path: .coverage
include-hidden-files: true

Run-Integration-Tests:
Run-GKE-Integration-Tests:
needs: Authorize
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -136,24 +136,76 @@ jobs:
run: |
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-integration
env:
RAY_SPEC_FILENAME: "ray-gke.yaml"
RAY_SPEC_FILENAME: "ray-linux.yaml"
USE_GKE: 1

- name: Upload coverage to Github
uses: actions/upload-artifact@v4
with:
name: coverage-integration-test-${{ matrix.python-version }}-${{ matrix.airflow-version }}
path: .coverage
include-hidden-files: true

- name: Delete GKE cluster
if: always()
run: |
gcloud container clusters delete ${{ steps.cluster-name.outputs.name }} --zone us-central1-a --quiet

Run-Kind-Integration-Tests:
needs: Authorize
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10" ]
airflow-version: [ "2.9" ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
.local/share/hatch/
key: coverage-integration-kubernetes-test-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('cosmos/__init__.py') }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Create KinD cluster
uses: container-tools/kind-action@v1
#with:
# config: dev/kind-config.yaml

- name: Install packages and dependencies
run: |
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 integration tests in Kind
run: |
hatch run tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }}:test-integration
env:
RAY_SPEC_FILENAME: "ray-linux.yaml"
AIRFLOW_HOME: /home/runner/work/astro-provider-ray/astro-provider-ray/
KUBECONFIG: /home/runner/.kube/config

- name: Upload coverage to Github
uses: actions/upload-artifact@v4
with:
name: coverage-integration-kubernetes-test-${{ matrix.python-version }}-${{ matrix.airflow-version }}
path: .coverage
include-hidden-files: true

Code-Coverage:
if: github.event.action != 'labeled'
needs:
- Run-Unit-Tests
- Run-Integration-Tests
- Run-GKE-Integration-Tests
- Run-Kind-Integration-Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion dev/dags/ray_single_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ray_provider.operators import SubmitRayJob

CONN_ID = "ray_conn"
RAY_SPEC = Path(__file__).parent / "scripts/ray.yaml"
RAY_SPEC = Path(__file__).parent / "scripts/ray-macos.yaml"
FOLDER_PATH = Path(__file__).parent / "ray_scripts"
RAY_RUNTIME_ENV = {"working_dir": str(FOLDER_PATH)}

Expand Down
2 changes: 1 addition & 1 deletion dev/dags/ray_taskflow_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ray_provider.decorators import ray

CONN_ID = "ray_conn"
RAY_SPEC_FILENAME = os.getenv("RAY_SPEC_FILENAME", "ray.yaml")
RAY_SPEC_FILENAME = os.getenv("RAY_SPEC_FILENAME", "ray-macos.yaml")
RAY_SPEC = Path(__file__).parent / "scripts" / RAY_SPEC_FILENAME

FOLDER_PATH = Path(__file__).parent / "ray_scripts"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dev/dags/setup-teardown.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ray_provider.operators import DeleteRayCluster, SetupRayCluster, SubmitRayJob

CONN_ID = "ray_conn"
RAY_SPEC = Path(__file__).parent / "scripts/ray.yaml"
RAY_SPEC = Path(__file__).parent / "scripts/ray-macos.yaml"
FOLDER_PATH = Path(__file__).parent / "ray_scripts"

with DAG(
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/dags/test_dag_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def test_dag_retries(dag_id, dag, fileloc):
"""
test if a DAG has retries set
"""
assert dag.default_args.get("retries", None) >= 2, f"{dag_id} in {fileloc} must have task retries >= 2."
assert dag.default_args.get("retries", 2) >= 2, f"{dag_id} in {fileloc} must have task retries >= 2."
14 changes: 6 additions & 8 deletions tests/test_dag_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ def test_dag_runs(setup_airflow_db, dag_id, dag, fileloc):
print(f"Testing DAG: {dag_id}, located at: {fileloc}")
assert dag is not None, f"DAG {dag_id} not found!"

if dag_id != "Ray_Taskflow_Example":
pytest.skip(f"Currently untested {dag_id}")
return
if os.getenv("USE_GKE", ""):
if dag_id != "Ray_Taskflow_Example":
pytest.skip(f"Currently untested {dag_id}")
return

try:
dr = dag.test()
assert dr.state == "success"
except Exception as e:
pytest.fail(f"Error running DAG {dag_id}: {e}")
dr = dag.test()
assert dr.state == "success"
Loading