Skip to content

Commit

Permalink
Airflow setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnestaP committed Mar 5, 2024
1 parent 40548d5 commit 58811cb
Show file tree
Hide file tree
Showing 11 changed files with 2,327 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Python application test with pytest
on:
push:
branches: [main]
pull_request:
branches: [main]

env:
AIRFLOW_HOME: /home/runner/work/bi-dags/bi-dags
REGISTRY: registry.cern.ch
IMAGE: cern-sis/bi-dags

jobs:
build_test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Python 3
uses: actions/setup-python@v4
with:
python-version: 3.10.11

- name: Build Image
id: build
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6
with:
registry: ${{ env.REGISTRY }}
image: ${{ env.IMAGE }}
tags: type=ref,event=pr
cache: false
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}

- name: Run tests with pytest and generate report
run: >
docker run
--name biproject
--network=host
-v "$(pwd)"/tests:/opt/airflow/tests
--entrypoint pytest
$REGISTRY/$IMAGE@${{ steps.build.outputs.image-digest }}
tests
--cov=./
--cov-report=xml
- name: Copy test coverage file to host machine
run: docker cp biproject:/opt/airflow/coverage.xml .

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
verbose: true
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Local Dev
*.log
*.err
*.pid
*.out
.DS_Store

# Airflow
logs
airflow.db
airflow.cfg
standalone_admin_password.txt
webserver_config.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/psf/black
rev: "22.8.0"
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
hooks:
- id: prettier
- repo: https://github.com/pycqa/isort
rev: "5.12.0"
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: "3.9.2"
hooks:
- id: flake8
args: ["--config=setup.cfg"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM apache/airflow:2.8.2-python3.8

ENV PYTHONBUFFERED=0
ENV AIRFLOW__LOGGING__LOGGING_LEVEL=INFO

# install your pip packages
COPY requirements.txt ./requirements.txt
COPY requirements-test.txt ./requirements-test.txt

COPY dags ./dags

RUN pip install --no-cache-dir --user -r requirements-test.txt -r requirements.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# bi-dags
# bi-dags
Loading

0 comments on commit 58811cb

Please sign in to comment.