-
Notifications
You must be signed in to change notification settings - Fork 69
98 lines (81 loc) · 2.91 KB
/
main.yml
File metadata and controls
98 lines (81 loc) · 2.91 KB
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
---
name: test
env:
GIT_REF: ${{ github.event.pull_request.head.sha || github.sha }}
RUN: docker compose run --rm --no-deps
"on":
schedule:
- cron: "0 5 * * 0"
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install uv
uses: astral-sh/setup-uv@e06108dd0aef18192324c70427afc47652e63a82 # v7
with:
enable-cache: false
ignore-empty-workdir: true
- name: Create Django project from template
run: |
uv run --with django django-admin startproject \
--template="https://github.com/lincolnloop/django-layout/zipball/$GIT_REF" \
--extension=py,md,gitignore,yaml,json,toml \
--name=Makefile,Dockerfile \
--exclude=.github \
project_name .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: Build and cache
uses: docker/bake-action@82490499d2e5613fcead7e128237ef0b0ea210f7 # v7
with:
load: true
set: |
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
source: .
- name: Initialize project
run: make init
- name: Start dependencies
run: docker compose up db -d
# pytest-cov doesn't support parallel mode, so manually set the coverage
# filename with a random suffix so it can be combined with other runs.
- name: Run tests
run: >-
${RUN} -e COVERAGE_FILE=.coverage.$RANDOM app
pytest --cov --cov-report= --junitxml=junit.xml
- name: Check missing migrations
run: ${RUN} app coverage run -m manage makemigrations --check
- name: Start dev server
run: docker compose up -d
timeout-minutes: 5
- name: Show running Docker containers
run: docker ps
- name: Test dev server
run: curl -I --retry 10 --retry-all-errors --fail localhost:8000/
- name: Generate coverage report
run: ${RUN} app bash -c "coverage combine && coverage xml"
- name: Upload coverage reports to Codecov
# Publish coverage on success, fail, but not cancel.
if: success() || failure()
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
- name: Upload test results to Codecov
# Upload JUnit test reports for test analytics
if: success() || failure()
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
report_type: test_results
- name: Dump Docker logs
run: |
set -x
docker compose ps
docker compose logs
if: always()