Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[run]
branch = True
# Only measure your apps (replace with your actual app names)
source =
peachjam
africanlii
liiweb

[report]
show_missing = True
skip_covered = True
# Omit settings and migrations from the report
omit =
*/migrations/*
*/settings/*.py
116 changes: 80 additions & 36 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,108 @@
name: Test

on: [push, pull_request]

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

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
app:
- peachjam
- africanlii
- liiweb

services:
postgres:
image: pgvector/pgvector:pg17
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
## db health checks
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 3

steps:
- uses: actions/checkout@v3

- name: Set up Python Environment
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
- uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get install -y libreoffice poppler-utils pandoc
python -m pip install --upgrade setuptools wheel
pip install .[dev]
pip install psycopg[binary]==3.2.12 unittest-xml-reporting
npm ci --no-audit --ignore-scripts --only=prod
npm i -g sass

- name: Run tests
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/peach-jam"
TEST_RUNNER: "xmlrunner.extra.djangotestrunner.XMLTestRunner"
run: |
pre-commit run --all-files
python manage.py test peachjam_subs peachjam_search ${{ matrix.app }} --settings=${{ matrix.app }}.settings

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: success() || failure()
continue-on-error: true
with:
files: test-reports/*.xml
- uses: actions/checkout@v3

- name: Set up Python Environment
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip

- uses: actions/setup-node@v3
with:
node-version: "18"

- name: Install dependencies
run: |
sudo apt-get -y update
sudo apt-get install -y libreoffice poppler-utils pandoc
python -m pip install --upgrade setuptools wheel
pip install .[dev]
pip install psycopg[binary]==3.2.12 unittest-xml-reporting coverage
npm ci --no-audit --ignore-scripts --only=prod
npm i -g sass

- name: Run tests with coverage
env:
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/peach-jam"
TEST_RUNNER: "xmlrunner.extra.djangotestrunner.XMLTestRunner"
run: |
pre-commit run --all-files
coverage run manage.py test peachjam_subs peachjam_search ${{ matrix.app }} --settings=${{ matrix.app }}.settings
coverage html

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: success() || failure()
continue-on-error: true
with:
files: test-reports/*.xml

# Get the changed files in the PR
- name: Get changed files in PR
id: files
uses: tj-actions/changed-files@v34

# Generate a small PR coverage summary
- name: Generate coverage summary for PR files
if: github.event_name == 'pull_request'
run: |
# Get changed files (comma-separated)
CHANGED_FILES=$(echo "${{ steps.files.outputs.all_changed_files }}" | tr ' ' ',')
echo "Files changed in PR: $CHANGED_FILES"

# Generate coverage report only for changed files, include backticks for markdown
if [ -n "$CHANGED_FILES" ]; then
coverage report --skip-covered --include="$CHANGED_FILES" > coverage_summary.txt
echo '```' > coverage_summary.txt.tmp
cat coverage_summary.txt >> coverage_summary.txt.tmp
echo '```' >> coverage_summary.txt.tmp
mv coverage_summary.txt.tmp coverage_summary.txt
else
echo "No changed files in coverage report" > coverage_summary.txt
fi

- name: Post Coverage comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && (success() || failure())
continue-on-error: true
with:
path: coverage_summary.txt
header: 'Coverage report'

- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-report-${{ matrix.app }}
path: htmlcov/
1 change: 1 addition & 0 deletions peachjam/views/courts.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def get_context_data(self, **kwargs):
return context

def add_judges_facet(self, context):
# test comment for coverage
if "judges" not in self.exclude_facets:
judges = list(
judge
Expand Down
1 change: 1 addition & 0 deletions peachjam/views/journals.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class JournalArticleListView(FilteredDocumentListView):
form_class = JournalArticleFilterForm

def add_facets(self, context):
# test comment for coverage
super().add_facets(context)
journals = list(
self.form.filter_queryset(self.get_base_queryset(), exclude="journals")
Expand Down