-
Notifications
You must be signed in to change notification settings - Fork 15
68 lines (66 loc) · 1.93 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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