Repository navigation
222 lines (203 loc) · 8.55 KB
/
Copy pathci.yml
File metadata and controls
222 lines (203 loc) · 8.55 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
---
# Modifications Copyright (c) 2026 Ctrl IQ, Inc.
name: CI
env:
LC_ALL: "C.UTF-8" # prevent ERROR: Ansible could not initialize the preferred locale: unsupported locale setting
CI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEV_DOCKER_OWNER: ${{ github.repository_owner }}
COMPOSE_TAG: ${{ github.base_ref || 'main' }}
on:
pull_request:
jobs:
common-tests:
name: ${{ matrix.tests.name }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
packages: read
contents: read
# The API suite runs on PostgreSQL, which is what Ascender is deployed
# against; it used to run on SQLite, which left the partitioned event
# tables, the COPY that assembles job stdout and every query-count
# assertion untested. The service is shared by the whole matrix, which
# costs nothing for the jobs that do not open a connection.
#
# The credentials have to match the fallback in ascender/settings/defaults.py:
# the suite itself is told where to connect through ASCENDER_TEST_DATABASE_*
# below, but the ascender-manage checks that make test runs afterwards load
# the development settings, and the throwaway container has no settings
# files for those to read, so they connect with the fallback.
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: ascender
POSTGRES_PASSWORD: ascenderpass
POSTGRES_DB: ascender
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
tests:
- name: api-test
command: /start_tests.sh
- name: api-migrations
command: /start_tests.sh test_migrations
- name: api-lint
command: /var/lib/ascender/venv/ascender/bin/tox -e linters
# Advisory while the diagnostics that are already in the tree are worked
# through: the job reports them, it does not fail the pull request.
- name: api-type-check
command: /var/lib/ascender/venv/ascender/bin/tox -e typecheck
advisory: true
# Audits what the image installed rather than resolving requirements.txt
# again, so it sees the versions that ship. Advisory until the backlog
# it reports is clear.
# Blocking, unlike the advisory run above: it covers only the packages
# that already report nothing, so it fails when one of them regresses.
- name: api-type-check-strict
command: /var/lib/ascender/venv/ascender/bin/tox -e typecheck-strict
- name: api-dependency-audit
command: /bin/bash -c "/var/lib/ascender/venv/ascender/bin/pip install --quiet pip-audit && /var/lib/ascender/venv/ascender/bin/pip-audit --progress-spinner=off"
advisory: true
# The UI's API types are generated from the serializers and committed.
# This regenerates them and fails if the committed copy has drifted,
# which is what happens when a serializer changes and nobody reruns
# make ui-api-types.
- name: ui-api-types-drift
command: /bin/bash -c "make ui-api-types && git diff --exit-code ascender/ui/src/types/api.generated.ts"
- name: ui-lint
command: make ui-lint
- name: ui-type-check
command: make ui-type-check
- name: ui-test-screens
command: make ui-test-screens
- name: ui-test-general
command: make ui-test-general
steps:
- name: Checkout ascender
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build ascender_devel image for running checks
uses: ./.github/actions/ascender_devel_image
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run check ${{ matrix.tests.name }}
continue-on-error: ${{ matrix.tests.advisory || false }}
# Host networking so the throwaway container reaches the service that
# the runner published on localhost.
env:
DOCKER_RUNNER_OPTS: >-
--network host
-e ASCENDER_TEST_DATABASE_HOST=127.0.0.1
-e ASCENDER_TEST_DATABASE_PORT=5432
-e ASCENDER_TEST_DATABASE_NAME=ascender
-e ASCENDER_TEST_DATABASE_USER=ascender
-e ASCENDER_TEST_DATABASE_PASSWORD=ascenderpass
run: AWX_DOCKER_CMD='${{ matrix.tests.command }}' make docker-runner
dev-env:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
packages: read
contents: read
steps:
- name: Checkout ascender
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Start the development environment
uses: ./.github/actions/run_ascender_devel
with:
build-ui: false
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install the ctrliq.ascender collection for the smoke test
run: ansible-galaxy collection install ctrliq.ascender
- name: Run smoke test
run: ansible-playbook tools/docker-compose/ansible/smoke-test.yml -v
- name: Get logs from the development environment on failure
if: failure()
run: docker logs tools_ascender_1 || true
e2e:
name: ui-e2e
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
packages: read
contents: read
steps:
- name: Checkout ascender
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# build-ui, unlike the dev-env job, because these tests drive the built UI
# the way a user meets it rather than a development server
- name: Start the development environment with the UI built
uses: ./.github/actions/run_ascender_devel
with:
build-ui: true
github-token: ${{ secrets.GITHUB_TOKEN }}
# The UI is built after the web process is already serving, and Django
# caches the index template that names the bundle. Without this the tests
# run against whatever was in the image, not against this pull request.
- name: Serve the UI that was just built
run: |
docker exec tools_ascender_1 \
supervisorctl -c /etc/supervisord.conf restart ascender-processes:uvicorn
SECONDS=0
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' -k https://localhost:8043/api/v2/ping/)" != "200" ]]; do
if [[ $SECONDS -gt 180 ]]; then echo "the API did not come back after the restart"; exit 1; fi
sleep 5
done
- name: Set up Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
- name: Install the end-to-end dependencies
working-directory: ascender/ui/e2e
run: npm ci --ignore-scripts
- name: Install the browser
working-directory: ascender/ui/e2e
run: npx playwright install --with-deps chromium
# run_ascender_devel sets the admin password to this
- name: Run the end-to-end tests
working-directory: ascender/ui/e2e
env:
ASCENDER_URL: https://localhost:8043
ASCENDER_USERNAME: admin
ASCENDER_PASSWORD: password
run: npm test
- name: Upload the report on failure
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-report
path: |
ascender/ui/e2e/playwright-report
ascender/ui/e2e/test-results
retention-days: 7
if-no-files-found: ignore
- name: Get logs from the development environment on failure
if: failure()
run: docker logs tools_ascender_1 || true
ui-dependency-audit:
name: ui-dependency-audit
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout ascender
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
# --omit=dev because a vulnerability in a build-time package does not ship
# to anyone, and the noise would bury what does. Advisory for now, like the
# Python audit above.
- name: Audit the UI dependencies
continue-on-error: true
working-directory: ascender/ui
run: npm audit --omit=dev