Skip to content

build(deps): update dependency pre-commit to ~4.6.0 #1691

build(deps): update dependency pre-commit to ~4.6.0

build(deps): update dependency pre-commit to ~4.6.0 #1691

Workflow file for this run

name: Continuous Integration
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
POETRY_VERSION: 1.8.5 # Make sure this matches the Dockerfile
on:
pull_request:
branches: ["main"]
paths-ignore: ["docs/**"]
push:
branches: ["main", "staging"]
paths-ignore: ["docs/**"]
tags:
- "v*"
jobs:
python_linters:
name: Python Linting
runs-on: ubuntu-24.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==$POETRY_VERSION
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "poetry"
cache-dependency-path: "poetry.lock"
- name: Install dependencies
# Removed the virtualenvs.create false line so Poetry manages the env normally
run: poetry install --only dev --no-root
- name: ruff
# Added poetry run
run: poetry run ruff check . --output-format=github
- name: black
# Added poetry run
run: poetry run black . --check
- name: djlint
# Added poetry run after xargs
run: find milk2meat/ -name '*.html' -o -name '*.mjml' | xargs poetry run djlint --check
javascript_linters:
name: JavaScript Linting
runs-on: ubuntu-24.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Stylelint
run: npm run lint:style
- name: ESLint
run: npm run lint:js
- name: Prettier
run: npm run lint:format
javascript_tests:
runs-on: ubuntu-24.04
needs: [python_linters, javascript_linters]
outputs:
coverage: ${{ steps.extract_coverage.outputs.coverage }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test:cov
- name: Extract JS coverage
id: extract_coverage
run: |
export JS_TOTAL=$(node -e "console.log(require('./coverage/coverage-summary.json').total.lines.pct)")
echo "coverage=$JS_TOTAL" >> $GITHUB_OUTPUT
echo "### Total JS coverage: ${JS_TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: "Upload JS coverage data"
uses: actions/upload-artifact@v4
with:
name: js-covdata
path: coverage/
python_tests:
runs-on: ubuntu-24.04
needs: [python_linters, javascript_linters]
services:
postgres:
image: postgres:15.17
env:
POSTGRES_USER: test_postgres_user
POSTGRES_PASSWORD: custom_pass
POSTGRES_DB: test_postgres_db
ports:
- 5432:5432 # Expose the port to the VM
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
# Use localhost since we are running natively on the VM now
DATABASE_URL: "postgres://test_postgres_user:custom_pass@localhost:5432/test_postgres_db"
DJANGO_SECRET_KEY: "secret"
DEBUG: False
ALLOWED_HOSTS: ""
ADMIN_URL: "fooadmin/"
TURNSTILE_SITE_KEY: "fake-key"
TURNSTILE_SECRET_KEY: "fake-key"
TZ: Africa/Lusaka
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Install System Dependencies
run: sudo apt-get update && sudo apt-get install -y libmagic1 libpq-dev
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: "npm"
- name: Build frontend assets
run: |
npm ci
npm run build:prod
- name: Install poetry
run: pipx install poetry==$POETRY_VERSION
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "poetry"
cache-dependency-path: "poetry.lock"
- name: Install Python Dependencies
run: poetry install --with dev,test,docs --no-interaction
- name: Test with pytest
run: |
# Use poetry run to execute commands within the automatically managed virtualenv
# Run system checks
poetry run python manage.py check
# Check for missing migrations
poetry run python manage.py makemigrations --check --noinput
# Create cache table.
poetry run python manage.py createcachetable
# Collect static files
poetry run python manage.py collectstatic --noinput --clear
# Run backend tests
poetry run pytest
- name: "Upload coverage data"
uses: actions/upload-artifact@v4
with:
name: covdata
path: coverage.*
coverage:
name: Coverage
needs: [python_tests, javascript_tests]
runs-on: ubuntu-24.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: "Download coverage data"
uses: actions/download-artifact@v4
with:
name: covdata
- name: "Download JS coverage data"
uses: actions/download-artifact@v4
with:
name: js-covdata
path: js-coverage/
- name: "Extract total coverage"
run: |
export PY_TOTAL=$(python -c "import json;print(round(json.load(open('coverage.json'))['totals']['percent_covered']))")
export JS_TOTAL=${{ needs.javascript_tests.outputs.coverage }}
echo "py_total=$PY_TOTAL" >> $GITHUB_ENV
echo "js_total=$JS_TOTAL" >> $GITHUB_ENV
echo "### Python coverage: ${PY_TOTAL}%" >> $GITHUB_STEP_SUMMARY
echo "### JavaScript coverage: ${JS_TOTAL}%" >> $GITHUB_STEP_SUMMARY
- name: "Create Python coverage badge"
if: (github.repository == 'engineervix/milk2meat') && (github.ref == 'refs/heads/main')
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: d435cc3f4234a469e5df13bf019a6385
filename: covbadge.json
label: Python Coverage
message: ${{ env.py_total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.py_total }}
namedLogo: pytest
- name: "Create JavaScript coverage badge"
if: (github.repository == 'engineervix/milk2meat') && (github.ref == 'refs/heads/main')
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.JEST_GIST_TOKEN }}
gistID: c2c521fe0d35ef3db3801b3203ed1fe4
filename: covbadge.json
label: JS Coverage
message: ${{ env.js_total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.js_total }}
namedLogo: jest
release:
needs:
[
python_linters,
javascript_linters,
python_tests,
javascript_tests,
coverage,
]
permissions:
contents: write
if: needs.python_tests.result == 'success' && needs.javascript_tests.result == 'success' && startsWith( github.ref, 'refs/tags/v' )
runs-on: ubuntu-24.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install invoke colorama tomli
- name: Get the version
id: get_version
run: |
echo "${{ github.ref }}"
echo "VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///')" >> $GITHUB_ENV
- name: Generate Release Title
id: get_release_title
shell: bash
run: |
export TODAY="($(TZ=Africa/Lusaka date --iso))"
echo "RELEASE_NAME=$VERSION $TODAY" >> $GITHUB_ENV
- name: Extract Release Notes
shell: bash
run: |
invoke get-release-notes
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.RELEASE_NAME }}
body_path: ../LATEST_RELEASE_NOTES.md