-
Notifications
You must be signed in to change notification settings - Fork 131
159 lines (135 loc) · 4.89 KB
/
Copy pathbackend.yml
File metadata and controls
159 lines (135 loc) · 4.89 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: backend
on:
workflow_dispatch:
pull_request:
paths:
- "**.py"
- "requirements/**.txt"
- "**.html"
- "**.mo"
- "**.po"
merge_group:
push:
branches:
- main
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:17
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Check cache for gettext
id: cache-gettext
if: matrix.toxenv == 'validate-translations'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ github.workspace }}/gettext-install
key: ${{ runner.os }}-gettext-0.25
- name: Install gettext for translations
if: matrix.toxenv == 'validate-translations'
run: |
if [ "${{ steps.cache-gettext.outputs.cache-hit }}" != "true" ]; then
curl -LO https://ftp.gnu.org/pub/gnu/gettext/gettext-0.25.tar.gz
tar xzvf gettext-0.25.tar.gz
cd gettext-0.25
./configure --prefix=${{ github.workspace }}/gettext-install
make -j$(nproc)
make install
fi
# Always add gettext to path, whether built or restored from cache.
echo "${{ github.workspace }}/gettext-install/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=${{ github.workspace }}/gettext-install/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Update apt
run: sudo apt-get update
- name: Install lxml dependencies
run: |
sudo apt-get update
sudo apt-get install python3.12-dev libxml2-dev libxslt-dev
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: 3.13
- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: "26.x"
- name: Enable Corepack
run: |
npm i -g corepack
corepack enable
- 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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: backend_coverage
path: ./coverage.xml
coverage:
runs-on: ubuntu-latest
needs:
- backend
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: 3.13
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/ci.txt
- name: Retrieve backend coverage
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: backend_coverage
path: backend_coverage
- name: Check backend test coverage
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
git fetch origin ${{ github.base_ref }}
COMPARE_FLAG="--compare-branch=origin/${{ github.base_ref }}"
else
git diff HEAD~1 HEAD > diff.txt
COMPARE_FLAG="--diff-file=diff.txt"
fi
diff-cover backend_coverage/coverage.xml $COMPARE_FLAG --fail-under=100