-
Notifications
You must be signed in to change notification settings - Fork 198
190 lines (157 loc) · 4.79 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
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
name: CI
on:
push:
branches:
- master
pull_request:
schedule:
- cron: "0 0 * * *"
env:
RUST_BACKTRACE: 1
RUST_CACHE_KEY: rust-cache-20240327
DOCSRS_PREFIX: ignored/cratesfyi-prefix
DOCSRS_DATABASE_URL: postgresql://cratesfyi:password@localhost:15432
DOCSRS_LOG: docs_rs=debug,rustwide=info
AWS_ACCESS_KEY_ID: cratesfyi
AWS_SECRET_ACCESS_KEY: secret_key
S3_ENDPOINT: http://localhost:9000
DOCSRS_INCLUDE_DEFAULT_TARGETS: false
DOCSRS_DOCKER_IMAGE: ghcr.io/rust-lang/crates-build-env/linux-micro
SENTRY_ENVIRONMENT: dev
jobs:
sqlx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: install
run: |
rustup override set stable
rustup update stable
- name: install `just`
run: sudo snap install --edge --classic just
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ env.RUST_CACHE_KEY }}
- name: Build
run: cargo build --workspace --locked
- name: Launch postgres
run: |
cp .env.sample .env
mkdir -p ${DOCSRS_PREFIX}/public-html
docker compose up -d db
# Give the database enough time to start up
sleep 5
# Make sure the database is actually working
psql "${DOCSRS_DATABASE_URL}"
- name: run database migrations
run: cargo run -- database migrate
- name: install SQLX CLI
run: cargo install sqlx-cli --no-default-features --features postgres
- name: run sqlx prepare --check
run: just sqlx-check
- name: test reverse migrations
run: |
# --target 0 means "revert everything"
cargo sqlx migrate revert \
--database-url $DOCSRS_DATABASE_URL \
--target-version 0
- name: Clean up the database
run: docker compose down --volumes
test:
env:
SQLX_OFFLINE: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: install
run: |
rustup override set stable
rustup update stable
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ env.RUST_CACHE_KEY }}
- name: Build
run: cargo build --workspace --locked
- name: Launch postgres and min.io
run: |
cp .env.sample .env
mkdir -p ${DOCSRS_PREFIX}/public-html
docker compose up -d db s3
# Give the database enough time to start up
sleep 5
# Make sure the database is actually working
psql "${DOCSRS_DATABASE_URL}"
- name: run workspace tests
run: |
cargo test --workspace --locked --no-fail-fast
- name: run slow tests
env:
DOCSRS_INCLUDE_DEFAULT_TARGETS: true
run: |
cargo test --locked -- --ignored --test-threads=1
- name: Clean up the database
run: docker compose down --volumes
GUI_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: install
run: |
rustup override set stable
rustup update stable
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ env.RUST_CACHE_KEY }}
- name: Launch postgres and min.io
run: |
cp .env.sample .env
mkdir -p ${DOCSRS_PREFIX}/public-html
docker compose up -d db s3
# Give the database enough time to start up
sleep 5
# Make sure the database is actually working
psql "${DOCSRS_DATABASE_URL}"
- name: Run GUI tests
run: ./dockerfiles/run-gui-tests.sh
- name: Clean up the database
run: docker compose down --volumes
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: install
run: |
rustup override set stable
rustup update stable
rustup component add rustfmt
- run: cargo fmt -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: install
run: |
rustup override set stable
rustup update stable
rustup component add clippy
- name: install `just`
run: sudo snap install --edge --classic just
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ env.RUST_CACHE_KEY }}
- run: just lint
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: install `just`
run: sudo snap install --edge --classic just
- run: npm install -g eslint@8
- run: just lint-js