Skip to content

Commit 0126c0e

Browse files
Initial commit
0 parents  commit 0126c0e

File tree

97 files changed

+17410
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+17410
-0
lines changed

.dockerignore

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__
7+
*.pyc
8+
*.pyo
9+
*.pyd
10+
.Python
11+
env
12+
pip-log.txt
13+
pip-delete-this-directory.txt
14+
.tox
15+
.coverage
16+
.coverage.*
17+
.pytest_cache
18+
.mypy_cache
19+
htmlcov
20+
21+
# Django
22+
*.log
23+
local_settings.py
24+
db.sqlite3
25+
media
26+
27+
# Virtual environments
28+
venv
29+
.venv
30+
env
31+
.env
32+
ENV
33+
env.bak
34+
venv.bak
35+
36+
# IDEs
37+
.idea
38+
.vscode
39+
*.swp
40+
*.swo
41+
*~
42+
43+
# OS
44+
.DS_Store
45+
.DS_Store?
46+
._*
47+
.Spotlight-V100
48+
.Trashes
49+
ehthumbs.db
50+
Thumbs.db
51+
52+
# Build artifacts
53+
build
54+
dist
55+
*.egg-info
56+
.eggs
57+
58+
# Documentation
59+
docs/_build
60+
site
61+
62+
# Node.js (if any)
63+
node_modules
64+
npm-debug.log
65+
66+
# Temporary files
67+
*.tmp
68+
*.bak
69+
70+
# Docker
71+
.dockerignore
72+
Dockerfile*
73+
docker-compose*.yml
74+
75+
# CI/CD
76+
.github
77+
78+
# Local development
79+
.env.local
80+
.env.development
81+
.env.production
82+
83+
# Test reports
84+
reports
85+
htmlcov
86+
.coverage
87+
coverage.xml
88+
89+
# Other
90+
*.orig

.flake8

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[flake8]
2+
max-line-length = 120
3+
ignore = E203,W503,E501,F401
4+
exclude =
5+
.git,
6+
__pycache__,
7+
venv,
8+
.venv,
9+
env,
10+
.env,
11+
build,
12+
dist,
13+
*.egg-info,
14+
migrations,
15+
.tox,
16+
.pytest_cache,
17+
node_modules,
18+
staticfiles,
19+
per-file-ignores =
20+
__init__.py:F401
21+
tests/*:F401,F811
22+
*/migrations/*:E501,F401
23+
max-complexity = 10

.github/workflows/test.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.8', '3.9', '3.10', '3.11']
15+
django-version: ['3.2', '4.0', '4.1', '4.2']
16+
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
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
42+
- name: Set up Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Install PostgreSQL Anonymizer Extension
48+
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"
53+
54+
- name: Cache pip dependencies
55+
uses: actions/cache@v3
56+
with:
57+
path: ~/.cache/pip
58+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}
59+
restore-keys: |
60+
${{ runner.os }}-pip-
61+
62+
- name: Install dependencies
63+
run: |
64+
python -m pip install --upgrade pip
65+
pip install Django==${{ matrix.django-version }}
66+
pip install -e .
67+
pip install -r requirements.txt
68+
pip install coverage pytest pytest-django pytest-cov
69+
70+
- name: Setup test database
71+
run: |
72+
export PGPASSWORD=postgres
73+
psql -h localhost -U postgres -d test_db -c "CREATE EXTENSION IF NOT EXISTS anon CASCADE;"
74+
75+
- name: Run tests
76+
env:
77+
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test_db
78+
run: |
79+
coverage run --source='.' -m pytest tests/ -v
80+
coverage report
81+
coverage xml
82+
83+
- name: Upload coverage to Codecov
84+
uses: codecov/codecov-action@v3
85+
with:
86+
file: ./coverage.xml
87+
flags: unittests
88+
name: codecov-umbrella
89+
fail_ci_if_error: false
90+
91+
lint:
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/checkout@v3
95+
96+
- name: Set up Python
97+
uses: actions/setup-python@v4
98+
with:
99+
python-version: '3.10'
100+
101+
- name: Install dependencies
102+
run: |
103+
python -m pip install --upgrade pip
104+
pip install flake8 black isort mypy
105+
pip install -e .
106+
107+
- name: Run black
108+
run: black --check .
109+
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
118+
119+
security:
120+
runs-on: ubuntu-latest
121+
steps:
122+
- uses: actions/checkout@v3
123+
124+
- name: Set up Python
125+
uses: actions/setup-python@v4
126+
with:
127+
python-version: '3.10'
128+
129+
- name: Install dependencies
130+
run: |
131+
python -m pip install --upgrade pip
132+
pip install bandit safety
133+
134+
- name: Run bandit
135+
run: bandit -r django_postgres_anon/
136+
137+
- name: Run safety
138+
run: safety check

0 commit comments

Comments
 (0)