Frontend Tests, hooks and utils #516
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v2 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache pip | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/**.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Cache Docker build | |
uses: actions/cache@v2 | |
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@v2 | |
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 |