-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[temp] Implement best practices (poetry, pre-commit, GH checks)
- Loading branch information
Showing
28 changed files
with
2,426 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Code checks | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
static_code_checks: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11.10' | ||
cache: 'poetry' | ||
- name: Install dependencies | ||
run: poetry install | ||
- name: Ruff check | ||
run: poetry run ruff check . | ||
- name: Ruff format check | ||
run: poetry run ruff format --check . | ||
- name: Mypy check | ||
run: poetry run mypy . | ||
tests: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install poetry | ||
run: pipx install poetry | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11.10' | ||
cache: 'poetry' | ||
- name: Install dependencies | ||
run: poetry install | ||
- name: configure AWS | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.TESTS_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.TESTS_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-central-1 | ||
- name: Run tests | ||
run: | | ||
poetry run pytest -m "aws or not(aws)" --junitxml=pytest.xml --cov-report=term-missing --cov=cli --cov=fetcher | tee pytest-coverage.txt | ||
echo "test_exit_code=${PIPESTATUS[0]}" >> $GITHUB_ENV | ||
- name: Coverage comment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
pytest-coverage-path: ./pytest-coverage.txt | ||
junitxml-path: ./pytest.xml | ||
- name: Fail on test failure | ||
run: exit ${{ env.test_exit_code }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: ruff-check | ||
name: ruff check | ||
entry: poetry run ruff check --fix . | ||
language: system | ||
types: [python] | ||
- id: ruff-format | ||
name: ruff format | ||
entry: poetry run ruff format --check . | ||
language: system | ||
types: [python] | ||
|
||
- repo: local | ||
hooks: | ||
- id: mypy | ||
name: mypy | ||
entry: poetry run mypy | ||
language: system | ||
types: [python] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
# see README.md for usage | ||
FROM python:3.10 | ||
# Limitation: | ||
# - Big image size: uses poetry, gets the whole repo, ... | ||
# - No caching/multi-stage build: the whole image is rebuilt every time | ||
# Done this way for easier mapping AWS AppRunner from GitHub source <-> Dockerfile | ||
|
||
WORKDIR /app | ||
ARG PYTHON_VERSION | ||
|
||
COPY requirements.txt /app | ||
RUN pip install -r requirements.txt | ||
FROM python:${PYTHON_VERSION}-slim as builder | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
CMD ["python", "-m", "cli.main"] | ||
COPY . /app/ | ||
RUN chmod +x /app/scripts/setup.sh && /app/scripts/setup.sh | ||
CMD ["poetry", "run", "run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.