@@ -11,51 +11,56 @@ jobs:
1111 runs-on : ubuntu-latest
1212 strategy :
1313 matrix :
14- python-version : ['3.8 ', '3.9 ', '3.10 ', '3.11 ']
15- django-version : ['3.2', '4.0 ', '4.1 ', '4.2 ']
14+ python-version : ['3.9 ', '3.10 ', '3.11 ', '3.12 ']
15+ django-version : ['3.2', '4.1 ', '4.2 ', '5.0 ']
1616 exclude :
17- - python-version : ' 3.8'
18- django-version : ' 4.0'
19- - python-version : ' 3.8'
20- django-version : ' 4.1'
21- - python-version : ' 3.8'
22- django-version : ' 4.2'
23-
24- services :
25- postgres :
26- image : postgres:13
27- env :
28- POSTGRES_PASSWORD : postgres
29- POSTGRES_USER : postgres
30- POSTGRES_DB : test_db
31- options : >-
32- --health-cmd pg_isready
33- --health-interval 10s
34- --health-timeout 5s
35- --health-retries 5
36- ports :
37- - 5432:5432
17+ # Django 5.0 requires Python 3.10+
18+ - python-version : ' 3.9'
19+ django-version : ' 5.0'
20+
21+ # We'll use a custom setup approach instead of services
3822
3923 steps :
40- - uses : actions/checkout@v3
24+ - uses : actions/checkout@v4
4125
4226 - name : Set up Python ${{ matrix.python-version }}
43- uses : actions/setup-python@v4
27+ uses : actions/setup-python@v5
4428 with :
4529 python-version : ${{ matrix.python-version }}
4630
47- - name : Install PostgreSQL Anonymizer Extension
31+ - name : Setup PostgreSQL with Anonymizer Extension
4832 run : |
49- sudo apt-get update
50- sudo apt-get install -y postgresql-client
51- # Install postgresql_anonymizer extension
52- sudo apt-get install -y postgresql-13-postgresql-anonymizer || echo "Extension not available in apt, will build from source"
33+ # Pull the official PostgreSQL Anonymizer Docker image
34+ docker pull registry.gitlab.com/dalibo/postgresql_anonymizer:stable
35+
36+ # Run the PostgreSQL container with anonymizer extension
37+ docker run -d \
38+ --name postgres-anon \
39+ -e POSTGRES_PASSWORD=postgres \
40+ -e POSTGRES_USER=postgres \
41+ -e POSTGRES_DB=test_db \
42+ -p 5432:5432 \
43+ registry.gitlab.com/dalibo/postgresql_anonymizer:stable
44+
45+ # Wait for PostgreSQL to be ready (with timeout)
46+ echo "Waiting for PostgreSQL to be ready..."
47+ for i in {1..30}; do
48+ if docker exec postgres-anon pg_isready -U postgres; then
49+ echo "PostgreSQL is ready!"
50+ break
51+ fi
52+ echo "Attempt $i/30: PostgreSQL not ready yet, waiting..."
53+ sleep 2
54+ done
55+
56+ # Final check
57+ docker exec postgres-anon pg_isready -U postgres
5358
5459 - name : Cache pip dependencies
55- uses : actions/cache@v3
60+ uses : actions/cache@v4
5661 with :
5762 path : ~/.cache/pip
58- key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py ') }}
63+ key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/pyproject.toml ') }}
5964 restore-keys : |
6065 ${{ runner.os }}-pip-
6166
@@ -69,20 +74,27 @@ jobs:
6974
7075 - name : Setup test database
7176 run : |
72- export PGPASSWORD=postgres
73- psql -h localhost -U postgres -d test_db -c "CREATE EXTENSION IF NOT EXISTS anon CASCADE;"
77+ # Install PostgreSQL client for local psql commands
78+ sudo apt-get update && sudo apt-get install -y postgresql-client
79+
80+ # Create the anonymizer extension
81+ PGPASSWORD=postgres psql -h localhost -U postgres -d test_db -c "CREATE EXTENSION IF NOT EXISTS anon CASCADE;"
82+
83+ # Verify extension was created
84+ PGPASSWORD=postgres psql -h localhost -U postgres -d test_db -c "SELECT name, installed_version FROM pg_available_extensions WHERE name = 'anon';"
7485
7586 - name : Run tests
7687 env :
7788 DATABASE_URL : postgres://postgres:postgres@localhost:5432/test_db
89+ DJANGO_SETTINGS_MODULE : tests.settings
7890 run : |
79- coverage run --source='.' -m pytest tests/ -v
80- coverage report
81- coverage xml
91+ # Run all tests with PostgreSQL anonymizer extension available
92+ pytest tests/ -v --cov=django_postgres_anon --cov-report=xml --cov-report=term-missing --cov-fail-under=87
8293
8394 - name : Upload coverage to Codecov
84- uses : codecov/codecov-action@v3
95+ uses : codecov/codecov-action@v4
8596 with :
97+ token : ${{ secrets.CODECOV_TOKEN }}
8698 file : ./coverage.xml
8799 flags : unittests
88100 name : codecov-umbrella
@@ -91,45 +103,39 @@ jobs:
91103 lint :
92104 runs-on : ubuntu-latest
93105 steps :
94- - uses : actions/checkout@v3
106+ - uses : actions/checkout@v4
95107
96108 - name : Set up Python
97- uses : actions/setup-python@v4
109+ uses : actions/setup-python@v5
98110 with :
99- python-version : ' 3.10 '
111+ python-version : ' 3.11 '
100112
101113 - name : Install dependencies
102114 run : |
103115 python -m pip install --upgrade pip
104- pip install flake8 black isort mypy
105- pip install -e .
116+ pip install -e ".[dev]"
106117
107- - name : Run black
108- run : black --check .
118+ - name : Run ruff format check (replaces black)
119+ run : ruff format --check .
109120
110- - name : Run isort
111- run : isort --check-only .
112-
113- - name : Run flake8
114- run : flake8 django_postgres_anon tests
115-
116- - name : Run mypy
117- run : mypy django_postgres_anon --ignore-missing-imports
121+ - name : Run ruff lint check (replaces flake8, isort, etc.)
122+ run : ruff check django_postgres_anon tests
118123
119124 security :
120125 runs-on : ubuntu-latest
121126 steps :
122- - uses : actions/checkout@v3
127+ - uses : actions/checkout@v4
123128
124129 - name : Set up Python
125- uses : actions/setup-python@v4
130+ uses : actions/setup-python@v5
126131 with :
127- python-version : ' 3.10 '
132+ python-version : ' 3.11 '
128133
129134 - name : Install dependencies
130135 run : |
131136 python -m pip install --upgrade pip
132137 pip install bandit safety
138+ pip install -e .
133139
134140 - name : Run bandit
135141 run : bandit -r django_postgres_anon/
0 commit comments