-
Notifications
You must be signed in to change notification settings - Fork 9
92 lines (74 loc) · 2.83 KB
/
project_ci.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# In YAML, 'raw' and 'endraw' can't come at the beginning of a token or at the end of a quoted value, which is why they're in weird places. They are
# needed to escape YAML templating variables, which still allowing cookiecutter to replace the value of the repository name.
name: Project CI
on: pull_request
jobs:
create_and_test_project:
name: Create and test Django project
runs-on: ubuntu-latest
env:
DATABASE_URL: "psql://postgres:postgres@localhost/postgres"
DJANGO_SETTINGS_MODULE: "sampleapp.config.settings.test"
DJANGO_SECRET_KEY: "!!!! Change me !!!!"
ACUITY_USER_KEY: ""
ACUITY_SECRET_KEY: ""
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install and configure Poetry
uses: snok/install-poetry@e3dbfd357f4751d4f582d62bc8a71e56c2a7015b # v1.3.2
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
# Configure Python for the template
- uses: actions/setup-python@v4
id: setup_python
with:
python-version-file: ".python-version"
cache: "poetry"
- run: poetry env use ${{ steps.setup_python.outputs.python-version }}
- name: Load cached venv if cache exists
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies if cache does not exist
run: poetry install --no-interaction --no-root
# Instantiate the project
- name: Instantiate project using the values in cookiecutter.json
run: poetry run cookiecutter . --no-input
# Configure the project environment
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- run: npm install
working-directory: ./sampleapp
- run: npm run build
working-directory: ./sampleapp
- run: poetry env use 3.10.4
working-directory: ./sampleapp
- name: Install dependencies if cache does not exist
working-directory: ./sampleapp
run: poetry install --no-interaction --no-root
- run: poetry run playwright install
working-directory: ./sampleapp
- run: poetry run coverage run --source='.' manage.py test
working-directory: ./sampleapp
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432