-
Notifications
You must be signed in to change notification settings - Fork 0
/
proj_main.yml
102 lines (101 loc) · 5.35 KB
/
proj_main.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
name: main
on: [push, pull_request]
jobs:
build:
name: Build {{project_name}}
strategy:
matrix:
python: [3.12]
node: [20.13]
env:
DATABASE_URL: "sqlite:///"
REDIS_URL: "redis://"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Store branch and latest SHA
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
id: git
- name: Setup Python ${% templatetag openvariable %} matrix.python {% templatetag closevariable %}
uses: actions/setup-python@v5
with:
python-version: ${% templatetag openvariable %} matrix.python {% templatetag closevariable %}
- name: Setup Node ${% templatetag openvariable %} matrix.node {% templatetag closevariable %}
uses: actions/setup-node@v4
with:
node-version: ${% templatetag openvariable %} matrix.node {% templatetag closevariable %}
- name: Cache node modules
uses: actions/cache@v4
env:
cache_name: node-modules-cache
with:
path: ~/.npm
key: build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.branch {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.sha_short {% templatetag closevariable %}
restore-keys: |
build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.branch {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.sha_short {% templatetag closevariable %}
build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.branch {% templatetag closevariable %}
build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}
- name: Cache pip
uses: actions/cache@v4
env:
cache_name: pip-cache
with:
path: ~/.cache/pip
key: build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.branch {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.sha_short {% templatetag closevariable %}
restore-keys: |
build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.branch {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.sha_short {% templatetag closevariable %}
build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}-${% templatetag openvariable%} steps.git.outputs.branch {% templatetag closevariable %}
build-${% templatetag openvariable%} env.cache_name {% templatetag closevariable %}
- run: python -m pip install --upgrade pip
- run: python -m pip install poetry==1.7.1
- run: curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
- run: sudo apt-get install git-lfs --upgrade
- run: poetry install --with dev --no-root --no-interaction --no-ansi
- run: npm install
- run: npm run build
- run: npm run lint
- name: Generate secret key
run: echo '::set-output name=SECRET_KEY::`python -c "import uuid; print(uuid.uuid4().hex + uuid.uuid4().hex)"`'
id: secret_id_generator
- name: Linting
run: poetry run ruff check ./backend/
env:
DJANGO_SETTINGS_MODULE: "{{project_name}}.settings.local_base"
SECRET_KEY: ${% templatetag openvariable %} steps.secret_id_generator.outputs.SECRET_KEY {% templatetag closevariable %}
DATABASE_URL: "sqlite:///"
ALLOWED_HOSTS: ".example.org"
SENDGRID_USERNAME: "test"
SENDGRID_PASSWORD: "test"
REDIS_URL: "redis://"
- run: poetry run pre-commit run --all-files
env:
SKIP: ruff,eslint,missing-migrations,backend-schema
- run: poetry run python manage.py makemigrations --check --dry-run
env:
DJANGO_SETTINGS_MODULE: "{{project_name}}.settings.production"
SECRET_KEY: ${% templatetag openvariable %} steps.secret_id_generator.outputs.SECRET_KEY {% templatetag closevariable %}
DATABASE_URL: "sqlite:///"
ALLOWED_HOSTS: ".example.org"
SENDGRID_USERNAME: "test"
SENDGRID_PASSWORD: "test"
REDIS_URL: "redis://"
working-directory: backend
- run: poetry run python manage.py check --deploy
env:
DJANGO_SETTINGS_MODULE: "{{project_name}}.settings.production"
SECRET_KEY: ${% templatetag openvariable %} steps.secret_id_generator.outputs.SECRET_KEY {% templatetag closevariable %}
DATABASE_URL: "sqlite:///"
ALLOWED_HOSTS: ".example.org"
SENDGRID_USERNAME: "test"
SENDGRID_PASSWORD: "test"
REDIS_URL: "redis://"
working-directory: backend
- run: |
poetry run coverage run manage.py test
mkdir -p junit
poetry run coverage xml -o junit/test-results.xml
working-directory: backend
- run: npm run test