-
Notifications
You must be signed in to change notification settings - Fork 112
128 lines (109 loc) · 3.29 KB
/
backend.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
name: backend
on:
workflow_dispatch:
paths:
- '**.py'
- 'requirements/**.txt'
- '**.html'
- '**.mo'
- '**.po'
pull_request:
paths:
- '**.py'
- 'requirements/**.txt'
- '**.html'
- '**.mo'
- '**.po'
merge_group:
paths:
- '**.py'
- 'requirements/**.txt'
- '**.html'
- '**.mo'
- '**.po'
jobs:
backend:
runs-on: ubuntu-latest
strategy:
matrix:
toxenv:
- lint
- validate-migrations
- validate-assets
- validate-translations
- unittest
services:
postgres:
# https://help.github.com/en/actions/configuring-and-managing-workflows/creating-postgresql-service-containers
# https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml
image: postgres:13
env:
POSTGRES_USER: cfpb
POSTGRES_PASSWORD: cfpb
POSTGRES_DB: cfgov
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
elasticsearch:
image: elasticsearch:7.10.1
ports:
- 9200/tcp
options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
steps:
- uses: actions/checkout@v4
- name: Install gettext for translation validation
if: matrix.toxenv == 'validate-translations'
run: sudo apt-get install gettext
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/ci.txt
- name: Run tox -e ${{ matrix.toxenv }}
run: |
tox -e ${{ matrix.toxenv }}
env:
TEST_RUNNER: core.testutils.runners.StdoutCapturingTestRunner
ES_PORT: ${{ job.services.elasticsearch.ports[9200] }}
- name: Prepare test coverage
if: matrix.toxenv == 'unittest'
run: coverage xml
- name: Store test coverage
# Submit coverage from our prefered tox run only
if: matrix.toxenv == 'unittest'
uses: actions/upload-artifact@v4
with:
name: backend_coverage
path: ./coverage.xml
coverage:
runs-on: ubuntu-latest
needs:
- backend
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/ci.txt
- name: Retrieve backend coverage
uses: actions/download-artifact@v4
with:
name: backend_coverage
path: backend_coverage
- name: Check backend test coverage
run: |
diff-cover backend_coverage/coverage.xml --compare-branch=origin/main --fail-under=100