Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 99
exclude =
.venv

68 changes: 68 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: main

on:
push:
branches: [main, develop]
pull_request:

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4.1.0
with:
python-version: 3.12

- name: Install flake8
run: pip --disable-pip-version-check install flake8

- name: Lint with flake8
run: flake8 --count

tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install -r requirements-test.txt

- name: Test with pytest
run: |
make test

# - name: Upload coverage reports to Codecov
# if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') && matrix.python-version == '3.12'
# uses: codecov/codecov-action@v4.0.1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}

build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4.1.0

- name: Build docker image
run: make docker-build

- name: Run tests
run: |
make docker-ci-test
169 changes: 169 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@

# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
.idea/

#OSX
.DS_Store

#Jupyter
.ipynb

#terraform
.terraform
.terraform.lock.hcl
terraform.tfstate
terraform.tfstate.backup

# project stuff
scripts/config.sh
test/
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-ast
- id: check-added-large-files
- id: check-yaml
args: [--unsafe]
- id: check-toml
- id: debug-statements
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: name-tests-test
args: [--pytest-test-first]
- id: mixed-line-ending
- id: trailing-whitespace

- repo: local
hooks:
- id: lint
name: check code standards (lint)
entry: make lint
types: [python]
language: system
pass_filenames: false

- id: codespell
name: check code for misspellings (codespell)
entry: codespell
types: [text]
language: python
pass_filenames: false
additional_dependencies:
- tomli

- id: typecheck
name: check static types (mypy)
entry: make typecheck
types: [python]
language: system
pass_filenames: false

#- repo: https://github.com/commitizen-tools/commitizen
# rev: v4.2.2
# hooks:
# - id: commitizen
69 changes: 69 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# ---------------------------------------------------------------------------------------
# BASE IMAGE
# ---------------------------------------------------------------------------------------
FROM python:3.12.10-slim-bookworm AS base

# Setup a volume for configuration and authtentication.
VOLUME ["/root/.config"]

# Update system and install build tools. Remove unneeded stuff afterwards.
# Upgrade PIP.
# Create working directory.
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc g++ build-essential && \
rm -rf /var/lib/apt/lists/* && \
pip install --upgrade pip && \
mkdir -p /opt/project

# Set working directory.
WORKDIR /opt/project

# ---------------------------------------------------------------------------------------
# DEPENDENCIES IMAGE (installed project dependencies)
# ---------------------------------------------------------------------------------------
# We do this first so when we modify code while development, this layer is reused
# from cache and only the layer installing the package executes again.
FROM base AS deps
COPY requirements.txt .
RUN pip install -r requirements.txt

# ---------------------------------------------------------------------------------------
# Apache Beam integration IMAGE
# ---------------------------------------------------------------------------------------
FROM deps AS beam
# Copy files from official SDK image, including script/dependencies.
# IMPORTANT: This version must match the one in requirements.txt
COPY --from=apache/beam_python3.12_sdk:2.64.0 /opt/apache/beam /opt/apache/beam

# Set the entrypoint to Apache Beam SDK launcher.
ENTRYPOINT ["/opt/apache/beam/boot"]

# ---------------------------------------------------------------------------------------
# PRODUCTION IMAGE
# ---------------------------------------------------------------------------------------
# If you need Apache Beam integration, replace "deps" base image with "beam".
FROM deps AS prod

COPY . /opt/project
RUN pip install . && \
rm -rf /root/.cache/pip && \
rm -rf /opt/project/*

# ---------------------------------------------------------------------------------------
# DEVELOPMENT IMAGE (editable install and development tools)
# ---------------------------------------------------------------------------------------
# If you need Apache Beam integration, replace "deps" base image with "beam".
FROM deps AS dev

COPY . /opt/project
RUN pip install -e .[lint,test,dev,build]

# ---------------------------------------------------------------------------------------
# TEST IMAGE (This checks that package is properly installed in prod image)
# ---------------------------------------------------------------------------------------
FROM prod AS test

COPY ./tests /opt/project/tests
COPY ./requirements-test.txt /opt/project/

RUN pip install -r requirements-test.txt
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include LICENSE
include README.md

recursive-include src/**/assets *
recursive-exclude * __pycache__
recursive-exclude * *.py[cod]
Loading
Loading