Release: v0.1.0b1 🎉 #37
This file contains hidden or 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
| name: Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.9', '3.10', '3.11', '3.12'] | |
| django-version: ['3.2', '4.1', '4.2', '5.0'] | |
| exclude: | |
| # Django 5.0 requires Python 3.10+ | |
| - python-version: '3.9' | |
| django-version: '5.0' | |
| # We'll use a custom setup approach instead of services | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Setup PostgreSQL with Anonymizer Extension | |
| run: | | |
| # Pull the official PostgreSQL Anonymizer Docker image | |
| docker pull registry.gitlab.com/dalibo/postgresql_anonymizer:stable | |
| # Run the PostgreSQL container with anonymizer extension | |
| docker run -d \ | |
| --name postgres-anon \ | |
| -e POSTGRES_PASSWORD=postgres \ | |
| -e POSTGRES_USER=postgres \ | |
| -e POSTGRES_DB=test_db \ | |
| -p 5432:5432 \ | |
| registry.gitlab.com/dalibo/postgresql_anonymizer:stable | |
| # Wait for PostgreSQL to be ready (with timeout) | |
| echo "Waiting for PostgreSQL to be ready..." | |
| for i in {1..30}; do | |
| if docker exec postgres-anon pg_isready -U postgres; then | |
| echo "PostgreSQL is ready!" | |
| break | |
| fi | |
| echo "Attempt $i/30: PostgreSQL not ready yet, waiting..." | |
| sleep 2 | |
| done | |
| # Final check | |
| docker exec postgres-anon pg_isready -U postgres | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install Django==${{ matrix.django-version }} | |
| pip install -e . | |
| pip install -r requirements.txt | |
| pip install coverage pytest pytest-django pytest-cov | |
| - name: Setup test database | |
| run: | | |
| # Install PostgreSQL client for local psql commands | |
| sudo apt-get update && sudo apt-get install -y postgresql-client | |
| # Create the anonymizer extension | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d test_db -c "CREATE EXTENSION IF NOT EXISTS anon CASCADE;" | |
| # Verify extension was created | |
| PGPASSWORD=postgres psql -h localhost -U postgres -d test_db -c "SELECT name, installed_version FROM pg_available_extensions WHERE name = 'anon';" | |
| - name: Run tests | |
| env: | |
| DATABASE_URL: postgres://postgres:postgres@localhost:5432/test_db | |
| DJANGO_SETTINGS_MODULE: tests.settings | |
| run: | | |
| # Run all tests with PostgreSQL anonymizer extension available | |
| pytest tests/ -v --cov=django_postgres_anon --cov-report=xml --cov-report=term-missing --cov-fail-under=87 --junitxml=junit.xml -o junit_family=legacy | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/test-results-action@v1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run ruff format check (replaces black) | |
| run: ruff format --check . | |
| - name: Run ruff lint check (replaces flake8, isort, etc.) | |
| run: ruff check django_postgres_anon tests | |
| security: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install bandit safety | |
| pip install -e . | |
| - name: Run bandit | |
| run: bandit -r django_postgres_anon/ | |
| - name: Run safety | |
| run: safety check |