-
Notifications
You must be signed in to change notification settings - Fork 9
145 lines (121 loc) · 4.38 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# 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
push:
branches:
- develop
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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.3.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 + build NPM
working-directory: ./sampleapp
run: |
npm install
npm run build
- 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 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
dependabot_approve:
name: Approve Dependabot prs
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: ${{ github.actor == 'dependabot[bot]' }}
needs: create_and_test_project
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
dependabot_merge:
name: Auto Merge Dependabot prs
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
if: ${{ github.actor == 'dependabot[bot]' }}
needs: dependabot_approve
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}