From 150e41ca1fc13c0ec5390bdfe37b5567d0b26d5b Mon Sep 17 00:00:00 2001 From: Christian Wygoda Date: Wed, 17 Apr 2024 10:43:28 +0200 Subject: [PATCH] Add PR CI workflow --- .github/workflows/pr.yml | 22 ++++++++++++++++++++++ .pre-commit-config.yaml | 6 ++++-- README.md | 2 +- pyproject.toml | 1 + scripts/test | 4 ++-- 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..9d0dccf --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,22 @@ +name: PR Checks + +on: + pull_request: + branches: ["main"] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: pipx install poetry==1.7.1 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: poetry + - name: Install dependencies + run: poetry install --with=dev + - name: Run commit checks + run: poetry run pre-commit run -a + - name: Run tests + run: ./scripts/test diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8cead38..2a82db7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,16 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.5.0 hooks: - id: check-merge-conflict - id: end-of-file-fixer + - id: mixed-line-ending - id: check-toml - id: check-yaml - id: trailing-whitespace + - id: no-commit-to-branch - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.1.5" + rev: "v0.3.7" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/README.md b/README.md index 9ae0054..59d2200 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,4 @@ a minimal demo with `uvicorn` to run the full app. Start it with `./scripts/serv - The test suite assumes the backend can be instantiated without any paramters required by the constructor. -[poetry]: https://python-poetry.org/ \ No newline at end of file +[poetry]: https://python-poetry.org/ diff --git a/pyproject.toml b/pyproject.toml index 98bce44..858281c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,6 +56,7 @@ omit = [ ] [tool.pytest.ini_options] +addopts="--cov=stat_fastapi" filterwarnings = [ "ignore:The 'app' shortcut is now deprecated.:DeprecationWarning", ] diff --git a/scripts/test b/scripts/test index 45b340a..97a3a26 100755 --- a/scripts/test +++ b/scripts/test @@ -12,5 +12,5 @@ Start the application including the backend. if [ "${1:-}" = "--help" ]; then usage else - poetry run pytest --cov=stat_fastapi "$@" -fi \ No newline at end of file + poetry run pytest "$@" +fi