Skip to content

Commit

Permalink
feat: add dags ci and cd github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bibliotechy committed Jul 27, 2023
1 parent aa897f6 commit 7afa804
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/dags_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Sync DAGs

on:
workflow_run:
workflows:
- 'DAGs Check'
types:
- completed
pull_request:
types:
- closed

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@master
- uses: jakejarvis/s3-sync-action@master
with:
args: --exclude "*" --include "*dags.py"
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-2'
SOURCE_DIR: 'dags'
DEST_DIR: 'dags'
36 changes: 36 additions & 0 deletions .github/workflows/dags_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dags Check
on:
push:
paths:
- 'dags/**'
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements.txt
pip check
- name: Lint with Flake8
run: |
pip install flake8
flake8 dags --benchmark -v
- name: Confirm Black code compliance
run: |
pip install black
black dags -v
- name: Test with Pytest
run: |
pip install pytest
cd tests || exit
pytest tests.py -v
2 changes: 2 additions & 0 deletions dags/.airflowignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests.py
README.md
Empty file added dags/README.md
Empty file.
Empty file added dags/requirements.txt
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions dags/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from unittest import TestCase

from airflow.models import DagBag

from . import rikolti_harvest_collection_dag as harvest_dag

Check failure on line 5 in dags/tests.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F401)

dags/tests.py:5:49: F401 `.rikolti_harvest_collection_dag` imported but unused

DAGS_FOLDER = "."


class HarvestDagsTest(TestCase):
def dag_bag(self):
return DagBag(dag_folder=DAGS_FOLDER, include_examples=False)

def test_no_import_errors(dag_bag):
assert not dag_bag.import_errors

0 comments on commit 7afa804

Please sign in to comment.