Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Dec 29, 2024
1 parent 655d2af commit 2640e2c
Show file tree
Hide file tree
Showing 63 changed files with 2,755 additions and 3,164 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ jobs:
name: Building the image
command: |
docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
docker pull unicef/donor-reporting-portal-backend:2.0-base
# docker build -t unicef/donor-reporting-portal-backend:${CIRCLE_BRANCH} .
docker pull unicef/donor-reporting-portal-backend:3.0-base
- run:
name: Pushing to Docker Hub
command: |
Expand Down
9 changes: 0 additions & 9 deletions .flake8

This file was deleted.

30 changes: 30 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This is used by the action https://github.com/dorny/paths-filter
dependencies: &dependencies
- 'uv.lock'
- 'pyproject.toml'

python: &python
- added|modified: 'src/**'
- added|modified: 'tests/**'
- 'manage.py'

changelog:
- added|modified: 'changes/**'
- 'CHANGELOG.md'

mypy:
- *python
- 'mypy.ini'

run_tests:
- *python
- *dependencies
- 'pytest.ini'

migrations:
- added|modified: 'src/**/migrations/*'

lint:
- *python
- '.flake8'
- 'pyproject.toml'
112 changes: 112 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Test

on:
push:
branches:
- '**' # matches every branch

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

defaults:
run:
shell: bash

permissions:
id-token: write
attestations: write


jobs:
changes:
runs-on: ubuntu-latest
concurrency:
group: changes-group
cancel-in-progress: true
timeout-minutes: 1
defaults:
run:
shell: bash
outputs:
run_tests: ${{steps.changes.outputs.run_tests }}
lint: ${{steps.changes.outputs.lint }}
steps:
- name: Checkout code
uses: actions/[email protected]
- id: changes
name: Check for file changes
uses: dorny/[email protected]
with:
base: ${{ github.ref }}
token: ${{ github.token }}
filters: .github/file-filters.yml

ci:
runs-on: ubuntu-latest
name: Test py${{ matrix.python-version }}/dj${{matrix.django-version}}
defaults:
run:
shell: bash
strategy:
max-parallel: 1
matrix:
python-version: [ "3.13" ]
django-version: [ "5.1" ]
fail-fast: true
needs: [ changes ]
if: needs.changes.outputs.run_tests || needs.changes.outputs.lint
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'

- name: Cache virtualenv
uses: actions/cache@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('uv.lock') }}
path: .venv

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install the project
run: |
uv sync --all-extras --dev
uv pip install .
- name: lint
if: needs.changes.outputs.lint
run: |
uv pip install ruff
uv run ruff check src tests
uv run ruff format --check src tests
- name: Test
if: needs.changes.outputs.run_tests
run: |
uv run pytest tests --create-db --junit-xml junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml
- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}-${{matrix.django-version}}
path: junit-${{ matrix.python-version }}-${{matrix.django-version}}.xml
if: ${{ always() }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: ${{ always() }}
continue-on-error: true
with:
env_vars: OS,PYTHON
fail_ci_if_error: true
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: false
name: codecov-${{env.GITHUB_REF_NAME}}
12 changes: 0 additions & 12 deletions .isort.cfg

This file was deleted.

27 changes: 10 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: isort
stages: [commit]
- repo: https://github.com/ambv/black
rev: 23.1.0
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: black
args: [--config=backend/pyproject.toml]
exclude: "migrations|snapshots"
stages: [commit]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--config=backend/.flake8]
additional_dependencies: [flake8-bugbear==22.9.23]
stages: [ commit ]
- id: ruff
- id: ruff-format
args:
- --check
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

76 changes: 0 additions & 76 deletions Pipfile

This file was deleted.

Loading

0 comments on commit 2640e2c

Please sign in to comment.