Skip to content

feature/implement-unit-testing #12

feature/implement-unit-testing

feature/implement-unit-testing #12

Workflow file for this run

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