-
Notifications
You must be signed in to change notification settings - Fork 9
91 lines (76 loc) · 3.07 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
# 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.
# Instructions to clear caches:
# 1) List all caches for this repo using the Github CLI: gh api -H "Accept: application/vnd.github+json" /repos/Lightmatter/django-hydra/actions/caches
# 2) Delete each cache id from the list, e.g.: gh api --method DELETE -H "Accept: application/vnd.github+json" /repos/Lightmatter/django-hydra/actions/caches/1
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_SECRET_KEY: "!!!! Change me !!!!"
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: 1.2.1
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"
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Hydra dependencies
run: |
poetry env use ${{ steps.setup_python.outputs.python-version }}
poetry install --no-interaction --no-root
# Instantiate the project
- name: Instantiate project using the values in cookiecutter.json
run: poetry run cookiecutter . --no-input --accept-hooks no
# Configure the project environment
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Install NPM package
working-directory: ./sampleapp
run: npm install
- name: Install Sample App dependencies
working-directory: ./sampleapp
run: |
poetry env use ${{ steps.setup_python.outputs.python-version }}
poetry install --no-interaction --no-root
poetry run playwright install chromium
- name: Run tests
working-directory: ./sampleapp
run: |
poetry run ./manage.py collectstatic --no-input
poetry run coverage run --source='.' -m pytest
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