Skip to content

Lint and Test code #673

Lint and Test code

Lint and Test code #673

Workflow file for this run

name: Lint and Test code
on:
pull_request:
schedule:
# run once a week on early monday mornings
- cron: '22 2 * * 1'
jobs:
test:
runs-on: ubuntu-20.04
env:
DJANGO_SETTINGS_MODULE: config.settings.test
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: dear_petition
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: "pip"
cache-dependency-path: "requirements/**.txt"
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker build
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ hashFiles('Dockerfile') }}
restore-keys: |
${{ runner.os }}-docker-
${{ runner.os }}-
- name: Run eslint + format
run: |
npm i
npm run lint
npx prettier --check .
- name: Build Docker Deploy Image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
load: true
tags: dear-petition
target: deploy
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r requirements/local.txt -r requirements/production.txt
- name: Run Tests
run: pytest
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/dear_petition