-
Notifications
You must be signed in to change notification settings - Fork 125
69 lines (67 loc) · 2.31 KB
/
django.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
name: Django application
on: [push]
jobs:
docker_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build docker
run: docker compose build
- name: Run ruff
run: docker compose run django ruff check styleguide_example/
- name: Run mypy
run: docker compose run django mypy --config mypy.ini styleguide_example/
- name: Run tests
run: docker compose run django py.test
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: github_actions
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12.4
cache: "pip"
cache-dependency-path: |
requirements/local.txt
requirements/base.txt
# This is a more aggresive cache.
# The one above caches the wheel files, but still runs the installation for them
# While the cache below caches the entire Python directory.
- name: Cache pip
uses: actions/cache@v4
with:
path: /opt/hostedtoolcache/Python/3.12.4/x64/ # This path is specific to Ubuntu
key: python-${{ hashFiles('requirements/local.txt') }}-${{ hashFiles('requirements/base.txt') }}
- name: Install dependencies
run: pip install -r requirements/local.txt
- name: Run ruff
run: ruff check .
- name: Type check
run: mypy --config mypy.ini styleguide_example/
- name: Run tests
run: pytest
deploy_to_heroku:
runs-on: ubuntu-latest
needs: build
# The project is currently hosted on render.com
if: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Deploy to Heroku
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_APP_NAME: "hacksoft-styleguide-example"
run: git push --force https://heroku:[email protected]/$HEROKU_APP_NAME.git origin/master:master