Skip to content

Feature/test deployed dags #214

Feature/test deployed dags

Feature/test deployed dags #214

name: cornflow-dags tests
on:
pull_request:
types: [ opened, edited, synchronize, reopened ]
paths:
- 'cornflow-dags/**'
- '.github/workflows/test_cornflow_dags.yml'
- '!cornflow-dags/README.rst'
push:
branches:
- master
- development
paths:
- 'cornflow-dags/**'
- '!cornflow-dags/README.rst'
jobs:
testing:
name: Run all test suites on cornflow-dags
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./cornflow-dags
strategy:
max-parallel: 21
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install cbc
run: |
sudo apt-get install -y coinor-cbc
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U -r requirements-dev.txt
CLIENT_BRANCH="${{ github.head_ref || github.ref_name }}"
python -m pip uninstall cornflow-client -y
python -m pip install -U "git+https://github.com/baobabsoluciones/cornflow@${CLIENT_BRANCH}#subdirectory=libs/client"
- name: Install airflow
run: |
AIRFLOW_VERSION=2.7.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CLIENT_BRANCH="${{ github.head_ref || github.ref_name }}"
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
python -m pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
python -m pip install -U orloge pulp
python -m pip install -U "git+https://github.com/baobabsoluciones/cornflow@${CLIENT_BRANCH}#subdirectory=libs/client"
airflow db init
airflow users create \
--username admin \
--firstname admin \
--lastname admin \
--role Admin \
--password admin \
--email [email protected]
airflow webserver -p 8080 &
airflow scheduler &
sleep 5s
env:
AIRFLOW__SCHEDULER__CATCHUP_BY_DEFAULT: 0
AIRFLOW_HOME: "${GITHUB_WORKSPACE}"
AIRFLOW__CORE__DAGS_FOLDER: "${GITHUB_WORKSPACE}/cornflow-dags/DAG"
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 0
AIRFLOW__API__AUTH_BACKEND: airflow.api.auth.backend.basic_auth
AIRFLOW__WEBSERVER__SECRET_KEY: e9adafa751fd35adfc1fdd3285019be15eea0758f76e38e1e37a1154fb36
AIRFLOW__CORE__LOAD_EXAMPLES: 0
AIRFLOW_CONN_CF_URI: cornflow://[email protected]:airflow_test_password@localhost:5000
- name: Run unit tests
run: |
coverage run --source=. -m unittest tests/test_dags.py
coverage report -m
- name: Run integration tests
run: |
coverage run -a --source=. -m unittest tests/test_dags_af.py
coverage report -m
coverage xml
- name: Upload coverage to codecov
uses : codecov/codecov-action@v3
with:
flags: dags-tests