forked from rust-lang/crates.io
-
Notifications
You must be signed in to change notification settings - Fork 0
228 lines (190 loc) · 6.6 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
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
223
224
225
226
227
228
name: CI
on:
push:
branches:
- auto
- master
- try
pull_request:
jobs:
frontend:
name: Frontend
runs-on: ubuntu-18.04
env:
JOBS: 1 # See https://git.io/vdao3 for details.
# Percy secrets are included here to enable Percy's GitHub integration
# on community-submitted PRs
PERCY_TOKEN: 0d8707a02b19aebbec79bb0bf302b8d2fa95edb33169cfe41b084289596670b1
PERCY_PROJECT: crates-io/crates.io
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Install node modules
run: yarn install
- name: Lint
run: |
yarn lint:hbs
yarn lint:js
yarn lint:deps
- name: Run percy exec
if: github.repository == 'rust-lang/crates.io'
run: npx percy exec -- npm run test-coverage
- name: test-coverage
if: github.repository != 'rust-lang/crates.io'
run: yarn test-coverage
embroider:
name: Frontend (embroider)
runs-on: ubuntu-18.04
env:
USE_EMBROIDER: 'true'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14.x'
- run: yarn install
- run: yarn test
backend:
name: Backend
runs-on: ubuntu-18.04
strategy:
# TODO: [ci] should be true if GitHub Actions supports ""allow failures" on matrix
fail-fast: false
matrix:
rust:
- stable
- beta
env:
RUST_BACKTRACE: 1
DATABASE_URL: postgres://postgres:postgres@localhost/cargo_registry_test
TEST_DATABASE_URL: postgres://postgres:postgres@localhost/cargo_registry_test
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-C debuginfo=0 -D warnings"
MALLOC_CONF: "background_thread:true,abort_conf:true,abort:true,junk:true"
services:
postgres:
image: postgres:11
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Cleanup pre-installed Rust toolchains
# The pre-installed toolchain is under root permission, and this would
# make tarball fail to extract. Here we remove the symlink and install
# our own Rust toolchain if necessary.
run: |
which rustup
which cargo
if [[ -L "$HOME/.cargo" && -L "$HOME/.rustup" ]]; then
rm -v "$HOME/.rustup"
rm -v "$HOME/.cargo"
fi
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# Cache `diesel` binary
#
# The other binaries (like `rustc`) will be overwritten by rustup.
#
# Current size as of 2019-12-23: ~6 MB
- name: Cache cargo binaries
uses: actions/cache@v2
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ matrix.rust }}-${{ hashFiles('.diesel_version') }}
# Current size as of 2019-12-23: ~77 MB
- name: Cache cargo registry cache
uses: actions/cache@v2
with:
path: ~/.cargo/registry/cache
key: ${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}-
${{ runner.os }}-cargo-registry-cache-
# Current size as of 2019-12-23: ~38 MB
- name: Cache cargo registry index
uses: actions/cache@v2
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-index-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-index-${{ matrix.rust }}-
${{ runner.os }}-cargo-registry-index-
# Current size as of 2019-12-23: ~4 MB
- name: Cache cargo git db
uses: actions/cache@v2
with:
path: ~/.cargo/git/db
key: ${{ runner.os }}-cargo-git-db-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-git-db-${{ matrix.rust }}-
${{ runner.os }}-cargo-git-db-
- name: Install ${{ matrix.rust }} Rust
run: |
if [[ ! -d "$HOME/.cargo" || ! -d "$HOME/.rustup" ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
fi
rustup set profile minimal
rustup update ${{ matrix.rust }}
rustup default ${{ matrix.rust }}
- name: Install lint tools
if: matrix.rust == 'stable'
run: |
rustup component add rustfmt
rustup component add clippy
- id: rustc
run:
echo "::set-output name=version::$(rustc -V)"
# Current size as of 2019-12-23: ~336 MB
- name: Cache cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ steps.rustc.outputs.version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-target-${{ steps.rustc.outputs.version }}-
- name: Cargo clean on new rustc version
run: script/ci/cargo-clean-on-new-rustc-version.sh
- name: Setup database
run: |
which diesel || cargo install diesel_cli --vers $(cat .diesel_version) --no-default-features --features postgres --debug
diesel database setup --locked-schema
- name: Lint
if: matrix.rust == 'stable'
run: |
cargo fmt -- --check
cargo clippy --all-targets --all-features --all
- name: Test
run: cargo test
- name: Prune unnecessary cache
run: script/ci/prune-cache.sh
# These jobs doesn't actually test anything, but they're only used to tell
# bors the build completed, as there is no practical way to detect when a
# workflow is successful listening to webhooks only.
#
# ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
end-success:
name: bors build finished
if: success()
runs-on: ubuntu-latest
needs: [frontend, backend]
steps:
- name: Mark the job as successful
run: exit 0
end-failure:
name: bors build finished
if: "!success()"
runs-on: ubuntu-latest
needs: [frontend, backend]
steps:
- name: Mark the job as a failure
run: exit 1