-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (53 loc) · 1.93 KB
/
run_tests.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
name: Run Tests
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.12
- name: Install dependencies
run: |
pip install --upgrade pip
pip install requests
pip install psycopg2-binary
pip install python-dotenv
pip install apache-airflow==2.8.1
pip install apache-airflow[cncf.kubernetes]
pip install pandas
pip install Flask-Session==0.5.0
- name: Initialize Airflow database
run: airflow db migrate
- name: Run tests
run: |
python -m unittest discover tests
python tests/dags_test.py
- name: Add label if failure
if: failure()
run: |
curl --request POST \
--url "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" \
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
--header "Content-Type: application/json" \
--data-raw '{"labels": ["Tests Failed"]}'
- name: Check and remove label if present
if: success()
run: |
labels=$(curl -s \
--request GET \
--url "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels" \
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}")
if [[ $labels == *"Tests Failed"* ]]; then
curl --request DELETE \
--url "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }}/labels/Tests%20Failed" \
--header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"
fi