forked from pypi/warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (137 loc) · 4.46 KB
/
ci.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
129
130
131
132
133
134
135
136
137
138
name: CI
on:
push:
branches:
- main
pull_request:
merge_group:
types: [checks_requested]
workflow_dispatch: # generally only for the "combine-prs" workflow
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build:
if: github.repository == 'pypi/warehouse'
runs-on: depot-ubuntu-22.04-arm
outputs:
buildId: ${{ steps.build.outputs.build-id}}
permissions:
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build image
id: build
uses: depot/build-push-action@v1
with:
save: true
build-args: |
DEVEL=yes
CI=yes
tags: pypi/warehouse:ci-${{ github.run_id }}
test:
# Time out if our test suite has gotten hung
timeout-minutes: 15
needs: build
strategy:
matrix:
include:
- name: Tests
command: bin/tests --postgresql-host postgres
- name: Lint
command: bin/lint
- name: User Documentation
command: bin/user-docs
- name: Developer Documentation
command: bin/dev-docs
- name: Dependencies
command: bin/deps
- name: Licenses
command: bin/licenses
- name: Translations
command: bin/translations
runs-on: depot-ubuntu-22.04-arm
container:
image: registry.depot.dev/rltf7cln5v:${{ needs.build.outputs.buildId }}
env:
BILLING_BACKEND: warehouse.subscriptions.services.MockStripeBillingService api_base=http://stripe:12111 api_version=2020-08-27
permissions:
id-token: write
services:
postgres:
image: ${{ (matrix.name == 'Tests') && 'postgres:16.1' || '' }}
ports:
- 5432:5432
env:
POSTGRES_HOST_AUTH_METHOD: trust # never do this in production!
POSTGRES_INITDB_ARGS: '--no-sync --set fsync=off --set full_page_writes=off'
# Set health checks to wait until postgres has started
options: --health-cmd "pg_isready --username=postgres --dbname=postgres" --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: ${{ (matrix.name == 'Tests') && 'redis:7.0' || '' }}
ports:
- 6379:6379
stripe:
image: ${{ (matrix.name == 'Tests') && 'stripe/stripe-mock:v0.162.0' || '' }}
ports:
- 12111:12111
name: ${{ matrix.name }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache mypy results
if: ${{ (matrix.name == 'Lint') }}
uses: actions/cache@v4
with:
path: |
dev/.mypy_cache
key: ${{ runner.os }}-mypy-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
- name: Run ${{ matrix.name }}
run: ${{ matrix.command }}
check_db:
name: Check Database Consistency
needs: build
runs-on: depot-ubuntu-22.04-arm
continue-on-error: true
container:
image: registry.depot.dev/rltf7cln5v:${{ needs.build.outputs.buildId }}
permissions:
id-token: write
services:
postgres:
image: postgres:16.1
ports:
- 5432:5432
env:
POSTGRES_DB: warehouse
POSTGRES_HOST_AUTH_METHOD: trust # never do this in production!
POSTGRES_INITDB_ARGS: '--no-sync --set fsync=off --set full_page_writes=off'
# Set health checks to wait until postgres has started
options: --health-cmd "pg_isready --username=postgres --dbname=postgres" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Dotenv Action
# We need to load the environment variables to run the CLI
id: dotenv
uses: falti/dotenv-action@v1
with:
path: dev/environment
export-variables: true
keys-case: upper
- name: Check Database
run: bin/db-check
env:
# override the hostname set in `dev/environment`
DATABASE_URL: 'postgresql+psycopg://postgres@postgres/warehouse'