Skip to content

Commit 7e562c6

Browse files
committed
Auto merge of #1942 - weihanglo:chore/github-actions, r=jtgeibel
Transit CI to GitHub Actions # What Transit the CI process to GitHub Actions. Close #1903 [Live GitHub Actions of this PR](https://github.com/weihanglo/crates.io/actions?query=workflow%3ACI+) # Details - Create two independent jobs, Frontend and Backend, to run in parallel. - The pre-installed Rust in the environment of Github Actions is installed under root privileges. That makes tarball cache fails to restore. Instead, we install Rust via rustup script manually. - GitHub Actions has not yet support `allow_failures` option, so we set` fail-fast` to false to prevent failure on nightly to cancel the entire CI process. - Update all documents mentioned Travis-CI to GitHub Actions. # Need helps - I have no experience of handling Percy token. Need some help to check the correctness. - Not sure how to configure GitHub with bors correctly. I followed [this](https://github.com/rust-osdev/x86_64/blob/master/bors.toml) and set the status to job names.
2 parents 41dca80 + d201c50 commit 7e562c6

File tree

5 files changed

+231
-9
lines changed

5 files changed

+231
-9
lines changed

.github/workflows/ci.yml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- auto
7+
- try
8+
9+
pull_request:
10+
11+
jobs:
12+
frontend:
13+
name: Frontend
14+
runs-on: ubuntu-16.04
15+
env:
16+
JOBS: 1 # See https://git.io/vdao3 for details.
17+
PERCY_PARALLEL_TOTAL: 2
18+
# Percy secrets are included here to enable Percy's GitHub integration
19+
# on community-submitted PRs
20+
PERCY_TOKEN: 0d8707a02b19aebbec79bb0bf302b8d2fa95edb33169cfe41b084289596670b1
21+
PERCY_PROJECT: crates-io/crates.io
22+
23+
steps:
24+
- uses: actions/checkout@v2-beta
25+
26+
- uses: actions/cache@v1
27+
with:
28+
path: ~/.npm
29+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
30+
restore-keys: |
31+
${{ runner.os }}-node-
32+
33+
- uses: actions/setup-node@v1
34+
with:
35+
node-version: '12.x'
36+
37+
- name: Install node modules
38+
run: npm ci
39+
40+
- name: Lint
41+
run: |
42+
npm run lint:hbs
43+
npm run lint:js
44+
npm run lint:deps
45+
46+
- name: Add nonce for parallel tests
47+
run: echo ::set-env name=PERCY_PARALLEL_NONCE::`date +%s`
48+
49+
- name: Test
50+
run: npm test
51+
52+
backend:
53+
name: Backend
54+
runs-on: ubuntu-16.04
55+
strategy:
56+
# TODO: [ci] should be true if GitHub Actions supports ""allow failures" on matrix
57+
fail-fast: false
58+
matrix:
59+
rust:
60+
- stable
61+
- beta
62+
- nightly
63+
64+
env:
65+
DATABASE_URL: postgres://postgres:@localhost/cargo_registry_test
66+
TEST_DATABASE_URL: postgres://postgres:@localhost/cargo_registry_test
67+
CARGO_INCREMENTAL: 0
68+
RUSTFLAGS: "-C debuginfo=0 -D warnings"
69+
70+
steps:
71+
- uses: actions/checkout@v2-beta
72+
73+
- name: Cleanup pre-installed Rust toolchains
74+
# The pre-installed toolchain is under root permission, and this would
75+
# make tarball fail to extract. Here we remove the symlink and install
76+
# our own Rust toolchain if necessary.
77+
run: |
78+
which rustup
79+
which cargo
80+
if [[ -L "$HOME/.cargo" && -L "$HOME/.rustup" ]]; then
81+
rm -v "$HOME/.rustup"
82+
rm -v "$HOME/.cargo"
83+
fi
84+
echo "::add-path::$HOME/.cargo/bin"
85+
86+
- name: Cache rustup
87+
uses: actions/cache@v1
88+
with:
89+
path: ~/.rustup
90+
key: ${{ runner.os }}-rustup-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
91+
restore-key: |
92+
${{ runner.os }}-rustup-${{ matrix.rust }}-
93+
${{ runner.os }}-rustup-
94+
95+
- name: Cache cargo binaries
96+
uses: actions/cache@v1
97+
with:
98+
path: ~/.cargo/bin
99+
key: ${{ runner.os }}-cargo-bin-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
100+
restore-key: |
101+
${{ runner.os }}-cargo-bin-${{ matrix.rust }}-
102+
${{ runner.os }}-cargo-bin-
103+
104+
- name: Cache cargo registry cache
105+
uses: actions/cache@v1
106+
with:
107+
path: ~/.cargo/registry/cache
108+
key: ${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
109+
restore-key: |
110+
${{ runner.os }}-cargo-registry-cache-${{ matrix.rust }}-
111+
${{ runner.os }}-cargo-registry-cache-
112+
113+
- name: Cache cargo registry index
114+
uses: actions/cache@v1
115+
with:
116+
path: ~/.cargo/registry/index
117+
key: ${{ runner.os }}-cargo-registry-index-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
118+
restore-key: |
119+
${{ runner.os }}-cargo-registry-index-${{ matrix.rust }}-
120+
${{ runner.os }}-cargo-registry-index-
121+
122+
- name: Cache cargo git db
123+
uses: actions/cache@v1
124+
with:
125+
path: ~/.cargo/git/db
126+
key: ${{ runner.os }}-cargo-git-db-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
127+
restore-key: |
128+
${{ runner.os }}-cargo-git-db-${{ matrix.rust }}-
129+
${{ runner.os }}-cargo-git-db-
130+
131+
- name: Cache cargo build
132+
uses: actions/cache@v1
133+
with:
134+
path: target
135+
key: ${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
136+
restore-key: |
137+
${{ runner.os }}-cargo-build-target-${{ matrix.rust }}-
138+
${{ runner.os }}-cargo-build-target-
139+
140+
- name: Install ${{ matrix.rust }} Rust
141+
run: |
142+
if [[ ! -d "$HOME/.cargo" || ! -d "$HOME/.rustup" ]]; then
143+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
144+
sh rustup-init.sh -y --default-toolchain none
145+
fi
146+
rustup set profile minimal
147+
rustup update ${{ matrix.rust }}
148+
rustup default ${{ matrix.rust }}
149+
150+
- name: Install lint tools
151+
if: matrix.rust == 'stable'
152+
run: |
153+
rustup component add rustfmt
154+
rustup component add clippy
155+
156+
- name: Cargo clean on new rustc version
157+
run: script/ci/cargo-clean-on-new-rustc-version.sh
158+
159+
- name: Install required system libraries
160+
run: |
161+
sudo tee /etc/apt/sources.list.d/pgdg.list <<END
162+
deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main
163+
END
164+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
165+
sudo apt-get update
166+
sudo apt-get install -y libpq-dev postgresql-11
167+
mkdir -p /etc/postgresql/11/main
168+
sudo tee /etc/postgresql/11/main/pg_hba.conf <<END
169+
local all all trust
170+
host all all 127.0.0.1/32 trust
171+
END
172+
sudo systemctl restart postgresql@11-main
173+
174+
- name: Setup database
175+
run: |
176+
which diesel || cargo install diesel_cli --vers $(cat .diesel_version) --no-default-features --features postgres
177+
diesel database setup --locked-schema
178+
179+
- name: Lint
180+
if: matrix.rust == 'stable'
181+
run: |
182+
cargo fmt -- --check
183+
cargo clippy --all-targets --all-features --all
184+
185+
- name: Test
186+
run: cargo test
187+
188+
- name: Prune unnecessary cache
189+
run: script/ci/prune-cache.sh
190+
191+
192+
# These jobs doesn't actually test anything, but they're only used to tell
193+
# bors the build completed, as there is no practical way to detect when a
194+
# workflow is successful listening to webhooks only.
195+
#
196+
# ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
197+
198+
end-success:
199+
name: bors build finished
200+
if: success()
201+
runs-on: ubuntu-latest
202+
needs: [frontend, backend]
203+
204+
steps:
205+
- name: Mark the job as successful
206+
run: exit 0
207+
208+
end-failure:
209+
name: bors build finished
210+
if: "!success()"
211+
runs-on: ubuntu-latest
212+
needs: [frontend, backend]
213+
214+
steps:
215+
- name: Mark the job as a failure
216+
run: exit 1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# crates.io
22

3-
[![Build Status](https://travis-ci.com/rust-lang/crates.io.svg?branch=master)](https://travis-ci.com/rust-lang/crates.io)
3+
[![Build Status](https://github.com/rust-lang/crates.io/workflows/CI/badge.svg)](https://github.com/rust-lang/crates.io/actions?query=workflow%3ACI)
44
[![What's Deployed](https://img.shields.io/badge/whatsdeployed-prod-green.svg)](https://whatsdeployed.io/s-9IG)
55

66
Source code for the default [Cargo](http://doc.crates.io) registry. Viewable

docs/ARCHITECTURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ local development environment
100100
writable directory - (ignored in `.gitignore`)
101101
* `tmp/index-bare` - A bare git repository, used as the origin for `tmp/index-co` during
102102
development - (ignored in `.gitignore`)
103-
* `.travis.yml` - Configuration for continous integration at [Travis CI][]
103+
* `.github/workflows/*` - Configuration for continuous integration at [GitHub Actions]
104104
* `.watchmanconfig` - Use by Ember CLI to efficiently watch for file changes if you install watchman
105105

106-
[Travis CI]: https://travis-ci.com/rust-lang/crates.io
106+
[GitHub Actions]: https://github.com/rust-lang/crates.io/actions

docs/CONTRIBUTING.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,23 @@ like to see all new types and functions, public and private, to have documentati
2626
comments on them. If you change an existing type or function, and it doesn't have
2727
a documentation comment on it, it'd be great if you could add one to it too.
2828

29-
When you submit a pull request, it will be automatically tested on TravisCI. In
29+
When you submit a pull request, it will be automatically tested on GitHub Actions. In
3030
addition to running both the frontend and the backend tests described below,
31-
Travis runs [jslint], [clippy], and [rustfmt] on each PR.
31+
GitHub Actions runs [jslint], [clippy], and [rustfmt] on each PR.
3232

33-
If you don't want to run these tools locally, please watch the Travis results
33+
If you don't want to run these tools locally, please watch the GitHub Actions results
3434
and submit additional commits to your pull request to fix any issues they find!
3535

3636
If you do want to run these tools locally in order to fix issues before
3737
submitting, that would be great too! Please consult each tool's installation
38-
instructions and the .travis.yml file in this repository for the latest
39-
installation and running instructions. The logs for recent builds in Travis
38+
instructions and the [.github/workflows/ci.yml] file in this repository for the latest
39+
installation and running instructions. The logs for recent builds in GitHub Actions
4040
may also be helpful to see which versions of these tools we're currently using.
4141

4242
[jslint]: http://jslint.com/
4343
[clippy]: https://github.com/rust-lang-nursery/rust-clippy
4444
[rustfmt]: https://github.com/rust-lang-nursery/rustfmt
45+
[.github/workflows/ci.yml]: /.github/workflows/ci.yml
4546

4647
We will try to review your pull requests as soon as possible!
4748

@@ -86,7 +87,7 @@ as well.
8687

8788
In order to run the frontend on Windows and macOS, you will need to have installed:
8889

89-
- [node](https://nodejs.org/en/) >= 12.9.1 (see `package.json` and `.travis.yml` for what we currently use)
90+
- [node](https://nodejs.org/en/) >= 12.9.1 (see `package.json` and `.github/workflows/ci.yml` for what we currently use)
9091
- [npm](https://www.npmjs.com/get-npm) >= 6.10.2
9192

9293
Follow the links for each of these tools for their recommended installation

script/ci/prune-cache.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
set -e
44

5+
if [[ ! -d "target/debug" ]]; then
6+
echo "No build artifacts found. Exit immediately."
7+
exit 0
8+
fi
9+
510
echo "Initial cache size:"
611
du -hs target/debug
712

0 commit comments

Comments
 (0)