-
Notifications
You must be signed in to change notification settings - Fork 10
136 lines (113 loc) · 4.03 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
# 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:
push:
branches:
- 'master'
- 'develop'
pull_request:
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
run: |
pipx install poetry==1.3.2
poetry config virtualenvs.create true
poetry config virtualenvs.in-project false
poetry config installer.parallel true
- name: Install Python
uses: actions/setup-python@v4
id: setup_python
with:
python-version-file: ".python-version"
cache: "poetry"
- name: Install Hydra dependencies
run: |
poetry env use ${{ steps.setup_python.outputs.python-version }}
poetry install --no-interaction --no-root
- name: Instantiate project using the values in cookiecutter.json
run: poetry run cookiecutter . --no-input --accept-hooks no
- name: Install Node
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 ci
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}}