-
Notifications
You must be signed in to change notification settings - Fork 4
155 lines (148 loc) · 5.59 KB
/
test_cornflow_client.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: cornflow-client tests
on:
pull_request:
types: [ opened, edited, synchronize, reopened ]
paths:
- 'libs/client/**'
- '.github/workflows/test_cornflow_client.yml'
- '!libs/client/README.rst'
- '!libs/client/setup.py'
push:
branches:
- master
- develop
paths:
- 'libs/client/**'
- '.github/workflows/test_cornflow_client.yml'
- '!libs/client/README.rst'
- '!libs/client/setup.py'
jobs:
unit:
runs-on: ${{ matrix.os }}
name: Run unit test on cornflow-client
defaults:
run:
working-directory: ./libs/client
strategy:
max-parallel: 21
matrix:
python-version: [ 3.9, '3.10', '3.11', '3.12' ]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install .
- name: Test
run: |
coverage run --source=./cornflow_client/ --rcfile=./.coveragerc -m unittest discover -s cornflow_client/tests/unit
coverage report -m
integration:
name: Run all test suites on cornflow-client
needs: unit
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./libs/client
strategy:
max-parallel: 21
matrix:
python-version: [3.9, '3.10', '3.11', '3.12']
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: Copy DAG files
run: |
cd ..
cd ..
cp -r cornflow-dags/DAG/* cornflow-server/airflow_config/dags/
cp cornflow-dags/requirements.txt cornflow-server/airflow_config/
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install .
- name: Install airflow
run: |
cd ..
cd ..
cd cornflow-server
python -m venv afvenv
source afvenv/bin/activate
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"
python -m pip install -U -r airflow_config/requirements.txt
airflow db init
airflow users create -u admin -f admin -l admin -r Admin -p admin -e [email protected]
airflow webserver -p 8080 &
airflow scheduler &
deactivate
sleep 5s
env:
AIRFLOW__SCHEDULER__CATCHUP_BY_DEFAULT: 0
AIRFLOW_HOME: "${GITHUB_WORKSPACE}/cornflow-server/airflow_config"
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: http://airflow:Airflow_test_password1@localhost:5050
- name: Run cornflow
run: |
cd ..
cd ..
cd cornflow-server
python -m venv cfvenv
source cfvenv/bin/activate
python -m pip install -U -r requirements.txt
CLIENT_BRANCH="${{ github.head_ref || github.ref_name }}"
python -m pip install -U "git+https://github.com/baobabsoluciones/cornflow@${CLIENT_BRANCH}#subdirectory=libs/client"
flask db upgrade -d cornflow/migrations/
flask access_init
flask register_deployed_dags -r http://127.0.0.1:8080 -u admin -p admin
flask create_admin_user -u admin -e [email protected] -p Adminpassword1!
flask create_service_user -u airflow -e [email protected] -p Airflow_test_password1
flask create_base_user -u user -e [email protected] -p UserPassword1!
flask register_dag_permissions -o 1
flask run -p 5050 &
deactivate
sleep 5s
env:
FLASK_ENV: testing
FLASK_APP: cornflow.app
AIRFLOW_URL: http://127.0.0.1:8080
AIRFLOW_USER: admin
AIRFLOW_PWD: admin
SECRET_KEY: THISNEEDSTOBECHANGED
OPEN_DEPLOYMENT: 1
AUTH_TYPE: 1
LOG_LEVEL: 10
CORNFLOW_SERVICE_USER: airflow
- name: Run unit tests
run: |
coverage run --source=./cornflow_client/ --rcfile=./.coveragerc -m unittest discover -s cornflow_client/tests/unit
coverage report -m
- name: Run integration tests
run: |
coverage run -a --source=./cornflow_client/ --rcfile=./.coveragerc -m unittest discover -s cornflow_client/tests/integration
coverage report -m
coverage xml
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
flags: client-tests
token: ${{secrets.CODECOV_TOKEN}}