-
Notifications
You must be signed in to change notification settings - Fork 3
112 lines (107 loc) · 3.58 KB
/
pre-deploy.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
on:
# Triggers the workflow on push or pull request events but only for the main branch
workflow_call:
inputs:
assets_required:
required: false
default: false
type: boolean
postgres_unit_testing:
required: false
default: false
type: boolean
check_db_migrations:
required: false
default: false
type: boolean
db_name:
required: false
default: "postgres_db"
type: string
# not required when not deploying to cf
secrets:
GOV_NOTIFY_API_KEY:
required: false
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
testing-unit-postgres-aws:
runs-on: ubuntu-latest
environment: Dev
if: ${{ inputs.postgres_unit_testing == true }}
services:
# Label used to access the service containers
postgres:
# Docker Hub image
image: postgres@sha256:3267c505060a0052e5aa6e5175a7b41ab6b04da2f8c4540fc6e98a37210aa2d3
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: ${{ inputs.db_name }}
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- name: checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: 3.10.x
- name: Install uv
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5
with:
enable-cache: true
- name: install dependencies
run: uv sync
- name: build static assets (if frontend)
if: ${{inputs.assets_required == true}}
env:
FLASK_ENV: "development"
run: uv run python build.py
- name: run unit tests
run: uv run python -m pytest -m "not accessibility"
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/${{ inputs.db_name }}
check_db:
name: Check DB migrations
runs-on: ubuntu-latest
if: ${{ inputs.check_db_migrations == true }}
services:
postgres:
# Docker Hub image
image: postgres:16.2@sha256:4aea012537edfad80f98d870a36e6b90b4c09b27be7f4b4759d72db863baeebb
# Provide the password for postgres
env:
POSTGRES_PASSWORD: password
POSTGRES_DB: pre_award_stores
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5
with:
enable-cache: true
- name: Check DB is up to date
env:
FLASK_ENV: unit_test
run: uv run --frozen flask db upgrade && uv run --frozen flask db check
- name: Check that .current-alembic-head is pinned
env:
FLASK_ENV: unit_test
run: |
uv run --frozen flask db current | grep "$(cat ./db/migrations/.current-alembic-head) (head)"