-
Notifications
You must be signed in to change notification settings - Fork 4
169 lines (164 loc) · 6.07 KB
/
test_cornflow_server.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: cornflow-server tests
on:
pull_request:
types: [ opened, edited, synchronize, reopened ]
paths:
- 'cornflow-server/**'
- '.github/workflows/test_cornflow_server.yml'
- '!cornflow-server/docs/**'
- '!cornflow-server/README.rst'
push:
branches:
- master
- develop
paths:
- 'cornflow-server/**'
- '.github/workflows/test_cornflow_server.yml'
- '!cornflow-server/docs/**'
- '!cornflow-server/README.rst'
jobs:
testing:
name: Run all test suites on cornflow-server
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./cornflow-server
strategy:
max-parallel: 21
matrix:
python-version: [3.9, '3.10', '3.11', '3.12']
os: [ubuntu-latest]
services:
postgres:
image: postgres
env:
POSTGRES_DB: cornflow-test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgresadmin
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Copy DAG files
run: |
cd ..
cp -r cornflow-dags/DAG/* cornflow-server/airflow_config/dags/
cp cornflow-dags/requirements.txt cornflow-server/airflow_config/
- name: Install dependencies
run: |
docker run --volume $GITHUB_WORKSPACE/cornflow-server/airflow_config:/etc/ldap.dist/prepopulate \
-e SLAPD_DOMAIN=example.org \
-e SLAPD_PASSWORD=admin \
-d -p 389:389 dinkel/openldap
CLIENT_BRANCH="${{ github.head_ref || github.ref_name }}"
python -m pip install --upgrade pip
python -m pip install -U -r requirements-dev.txt
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: |
python -m venv afvenv
source afvenv/bin/activate
AIRFLOW_VERSION=2.9.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 uninstall cornflow-client -y
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 \
--username admin \
--firstname admin \
--lastname admin \
--role Admin \
--password admin \
--email [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 unit tests
run: |
coverage run --source=./cornflow/ --rcfile=./.coveragerc -m unittest discover -s cornflow/tests/unit
coverage report -m
env:
FLASK_ENV: testing
OPEN_DEPLOYMENT: 1
DATABASE_URL: sqlite:///cornflow_test.db
LOG_LEVEL: 30
AIRFLOW_USER: notadmin
AIRFLOW_PWD: notadmin
CF_ALARMS_ENDPOINT: 1
- name: Run ldap unit tests
run: |
coverage run -a --source=./cornflow/ --rcfile=./.coveragerc -m unittest discover -s cornflow/tests/ldap
coverage report -m
env:
FLASK_ENV: testing
DATABASE_URL: sqlite:///cornflow_test.db
AUTH_TYPE: 2
OPEN_DEPLOYMENT: 1
LDAP_HOST: ldap://localhost:389
LDAP_BIND_PASSWORD: admin
LDAP_GROUP_BASE: dc=example,dc=org
LDAP_GROUP_OBJECT_CLASS: groupOfNames
LDAP_PROTOCOL_VERSION: 3
LDAP_BIND_DN: cn=admin,dc=example,dc=org
LDAP_USE_TLS: False
LDAP_USERNAME_ATTRIBUTE: cn
LDAP_USER_BASE: ou=users,dc=example,dc=org
LDAP_SERVICE_BASE: ou=service,dc=example,dc=org
LDAP_EMAIL_ATTRIBUTE: mail
LDAP_USER_OBJECT_CLASS: inetOrgPerson
LDAP_GROUP_ATTRIBUTE: cn
LDAP_GROUP_TO_ROLE_SERVICE: services
LDAP_GROUP_TO_ROLE_ADMIN: administrators
LDAP_GROUP_TO_ROLE_VIEWER: viewers
LDAP_GROUP_TO_ROLE_PLANNER: planners
LOG_LEVEL: 30
CORNFLOW_SERVICE_USER: cornflow
- name: Run postgres unit tests
run: |
coverage run -a --source=./cornflow/ --rcfile=./.coveragerc -m unittest cornflow/tests/unit/test_commands.py
coverage report -m
env:
FLASK_ENV: testing
OPEN_DEPLOYMENT: 1
DATABASE_URL: postgresql://postgres:[email protected]:5432/cornflow-test
LOG_LEVEL: 30
CF_ALARMS_ENDPOINT: 1
- name: Run integration tests
run: |
coverage run -a --source=./cornflow/ --rcfile=./.coveragerc -m unittest discover -s cornflow/tests/integration
coverage report -m
coverage xml
env:
FLASK_ENV: testing
OPEN_DEPLOYMENT: 1
DATABASE_URL: sqlite:///cornflow_test.db
LOG_LEVEL: 30
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
flags: server-tests
token: ${{secrets.CODECOV_TOKEN}}