Skip to content

Bump ruff from 0.5.3 to 0.5.4 #293

Bump ruff from 0.5.3 to 0.5.4

Bump ruff from 0.5.3 to 0.5.4 #293

Workflow file for this run

name: test
on:
pull_request:
branches:
- main
# Allow calling this workflow from others:
workflow_call:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports: ["5432:5432"]
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
# Via https://adamj.eu/tech/2023/11/02/github-actions-faster-python-virtual-environments/
- name: Restore cached virtualenv
uses: actions/cache/restore@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
path: .venv
- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: Save cached virtualenv
uses: actions/cache/save@v4
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
path: .venv
- name: Run ruff
# ruff is already installed from our requirements
run: ruff check .
- name: Run Tests
# Shouldn't need to manually migrate, but otherwise the tests that use AdminSite() fail:
run: |
./manage.py collectstatic --verbosity=0 --noinput
./manage.py migrate --verbosity=0 --noinput
coverage run --concurrency=multiprocessing ./manage.py test --parallel
coverage combine
coverage xml
env:
ALLOWED_HOSTS: "*"
DATABASE_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres"
DJANGO_SECRET_KEY: "fake-secret-key-for-tests"
MEDIA_ROOT: "${{ github.workspace }}/tests/_media"
PEPYS_LOG_LEVEL: "ERROR"
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
- name: Slack notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
# fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message)
fields: repo,workflow,message,commit,action,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTIONS_CI_SLACK_HOOK }} # required
# Run even if job fails/cancelled, but only if Slack webhook is present (it's not when Dependabot runs):
if: ${{ always() && env.SLACK_WEBHOOK_URL != null }}