Skip to content

Commit

Permalink
Merge branch 'develop' into topic/chriscummings/enable-build-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
crankynetman committed Dec 10, 2024
2 parents 64792b0 + 9b93a79 commit 4b50027
Show file tree
Hide file tree
Showing 78 changed files with 1,065 additions and 878 deletions.
11 changes: 0 additions & 11 deletions .ci-scripts/create_user.py

This file was deleted.

91 changes: 91 additions & 0 deletions .github/workflows/behave.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
name: Run behave

on:
push:
branches:
- "**"
pull_request:
branches:
- main
- develop

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
behave:
name: Run Behave
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.11", "3.12"]

steps:
- name: Check out the code
uses: actions/checkout@v4

- name: Set up Docker
uses: docker/setup-buildx-action@v3

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose make
- name: Check Docker state (pre-build)
run: docker ps

- name: Build Docker images
run: make build
env:
PYTHON_IMAGE_VER: "${{ matrix.python-version }}"

- name: Migrate Database
run: make migrate

- name: Run Application
run: make run

- name: Check Docker state (pre-test)
run: docker ps

- name: Run pytest + behave with Coverage
env:
POSTGRES_USER: scram
POSTGRES_DB: test_scram
run: make coverage.xml

- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2

- name: Upload Coverage to Coveralls
if: matrix.python-version == '3.12'
uses: coverallsapp/github-action@v2

- name: Upload Coverage to GitHub
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml

- name: Display Coverage Metrics
if: matrix.python-version == '3.12'
uses: 5monkeys/cobertura-action@v14
with:
minimum_coverage: "50"

- name: Check Docker state (post-test)
if: always()
run: docker ps

- name: Stop Services
if: always()
run: make stop

- name: Clean Up
if: always()
run: make clean
77 changes: 77 additions & 0 deletions .github/workflows/behave_next_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Run behave with unsupported Python versions

on:
push:
branches:
- '**'
pull_request:
branches:
- main
- develop

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
behave_next_python:
name: Run Behave
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.13']

steps:
- name: Check out the code
uses: actions/checkout@v4

- name: Set up Docker
uses: docker/setup-buildx-action@v3

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose make
- name: Check Docker state (pre-build)
run: docker ps

- name: Build Docker images
run: make build
env:
PYTHON_IMAGE_VER: "${{ matrix.python-version }}"

- name: Migrate Database
run: |
make migrate || echo "::warning:: migrate failed on future Python version ${{ matrix.python-version }}."
- name: Run Application
run: |
make run || echo "::warning:: run failed on future Python version ${{ matrix.python-version }}."
- name: Check Docker state (pre-test)
run: docker ps

- name: Run pytest + behave with Coverage
env:
POSTGRES_USER: scram
POSTGRES_DB: test_scram
run: |
make coverage.xml || echo "::warning:: pytest + behave failed on future Python version ${{ matrix.python-version }}."
- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v2

- name: Check Docker state (post-test)
if: always()
run: docker ps

- name: Stop Services
if: always()
run: make stop

- name: Clean Up
if: always()
run: make clean
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'docs/_build/html'
path: 'site/'

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/flake8.yml

This file was deleted.

86 changes: 36 additions & 50 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ jobs:
pytest:
name: Run Pytest
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.11', '3.12']

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: scram
POSTGRES_PASSWORD: ''
POSTGRES_DB: test_scram
POSTGRES_DB: test_scram_${{ matrix.python-version }}
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
Expand All @@ -34,63 +38,45 @@ jobs:
--health-timeout 5s
--health-retries 5
redis:
image: redis:5.0
ports:
- 6379:6379

steps:
- name: Check out the code
uses: actions/checkout@v4

- name: Cache Docker images.
uses: ScribeMD/[email protected]
- uses: actions/setup-python@v5
with:
key: docker-${{ runner.os }}-${{ hashFiles('docker-compose.yaml') }}
python-version: ${{ matrix.python-version }}

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Install Docker Compose
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y docker-compose make
- name: Build Docker images
run: make build
python -m pip install --upgrade pip
pip install -r requirements/local.txt
# https://github.com/pytest-dev/pytest-github-actions-annotate-failures/pull/68 isn't yet in a release
pip install git+https://github.com/pytest-dev/pytest-github-actions-annotate-failures.git@6e66cd895fe05cd09be8bad58f5d79110a20385f
- name: Migrate Database
run: make migrate

- name: Run Application
run: make run

- name: Run Pytest with Coverage
- name: Apply migrations
env:
POSTGRES_USER: scram
POSTGRES_DB: test_scram
run: make coverage.xml

- name: Upload Coverage to Coveralls
uses: coverallsapp/github-action@v2

- name: Upload Coverage to GitHub
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml

- name: Display Coverage Metrics
uses: 5monkeys/cobertura-action@v14
with:
minimum_coverage: '50'
DATABASE_URL: "postgres://scram:@localhost:5432/test_scram_${{ matrix.python-version }}"
run: |
python manage.py makemigrations --noinput
python manage.py migrate --noinput
- name: Stop Services
if: always()
run: make stop
- name: Check for duplicate migrations
env:
DATABASE_URL: "postgres://scram:@localhost:5432/test_scram_${{ matrix.python-version }}"
run: |
if python manage.py makemigrations --dry-run | grep "No changes detected"; then
echo "No duplicate migrations detected."
else
echo "::warning:: Potential duplicate migrations detected. Please review."
fi
- name: Clean Up
if: always()
run: make clean
- name: Run Pytest
env:
DATABASE_URL: "postgres://scram:@localhost:5432/test_scram_${{ matrix.python-version }}"
REDIS_HOST: "localhost"
run: pytest
Loading

0 comments on commit 4b50027

Please sign in to comment.