Skip to content

Commit 48e6513

Browse files
committed
Cleanup and speed-up CI (#2376)
Currently we run 7 different jobs: - tests linux - tests macos - tests windows - rustfmt - clippy - examples - documentation With this change I reduced them to 4 and hopefully sped them up. The total execution time is limited by the tests, especially linux that calculates coverage. Having separate jobs for clippy and rustfmt (which take a very small amount of time) is a waste of energy. With this PR: Introduced a new cargo profile, `ci`, that should create smaller sized binaries and reduce the our cache usage. I changed the test runner for macos and windows to [nextest](https://nexte.st/), which should be faster and is specifically designed for CI. I merged all smaller tasks in a single job, misc, the steps clearly identify what is being tested so it shouldn't affect clarity. Switched to using the [rust-cache](https://github.com/Swatinem/rust-cache) GH action, this simplifies our work by no longer having to worry about which directories to cache, rust-cache handles all that for us. ~~The bors task should also be modified, I'll get to it as soon as I have time. I believe it should be possible for us to have a single workflow described and have it both be the normal CI and the bors test.~~
1 parent 946a4dd commit 48e6513

File tree

5 files changed

+59
-298
lines changed

5 files changed

+59
-298
lines changed

.config/nextest.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[profile.ci]
2+
# Don't fail fast in CI to run the full test suite.
3+
fail-fast = false

.github/workflows/bors.yml

Lines changed: 0 additions & 162 deletions
This file was deleted.

.github/workflows/rust.yml

Lines changed: 42 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
name: Continuous integration
2+
13
on:
24
pull_request:
35
branches:
46
- main
57
push:
68
branches:
79
- main
8-
9-
name: Continuous integration
10+
- staging # bors
11+
- trying # bors
1012

1113
jobs:
12-
test_on_linux:
13-
name: Tests on Linux
14+
coverage:
15+
name: Coverage
1416
runs-on: ubuntu-latest
1517
steps:
1618
- uses: actions/checkout@v3
@@ -19,101 +21,44 @@ jobs:
1921
toolchain: stable
2022
override: true
2123
profile: minimal
22-
- name: Cache cargo
23-
uses: actions/cache@v3
24+
- uses: Swatinem/rust-cache@v2
2425
with:
25-
path: |
26-
target
27-
~/.cargo/git
28-
~/.cargo/registry
29-
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
26+
key: tarpaulin
3027
- name: Run cargo-tarpaulin
3128
uses: actions-rs/[email protected]
3229
with:
3330
args: --features intl --ignore-tests
3431
- name: Upload to codecov.io
3532
uses: codecov/codecov-action@v3
3633

37-
test_on_windows:
38-
name: Tests on Windows
39-
runs-on: windows-latest
40-
steps:
41-
- uses: actions/checkout@v3
42-
- uses: actions-rs/[email protected]
43-
with:
44-
toolchain: stable
45-
override: true
46-
profile: minimal
47-
- name: Cache cargo
48-
uses: actions/cache@v3
49-
with:
50-
path: |
51-
target
52-
~/.cargo/git
53-
~/.cargo/registry
54-
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
55-
- uses: actions-rs/cargo@v1
56-
with:
57-
command: test
58-
args: -v --features intl
59-
60-
test_on_macos:
61-
name: Tests on MacOS
62-
runs-on: macos-latest
63-
steps:
64-
- uses: actions/checkout@v3
65-
- uses: actions-rs/[email protected]
66-
with:
67-
toolchain: stable
68-
override: true
69-
profile: minimal
70-
- uses: actions-rs/cargo@v1
71-
with:
72-
command: test
73-
args: -v --features intl
74-
75-
fmt:
76-
name: Rustfmt
77-
runs-on: ubuntu-latest
78-
steps:
79-
- uses: actions/checkout@v3
80-
- uses: actions-rs/[email protected]
81-
with:
82-
toolchain: stable
83-
override: true
84-
profile: minimal
85-
components: rustfmt
86-
- uses: actions-rs/cargo@v1
87-
with:
88-
command: fmt
89-
args: --all -- --check
90-
91-
clippy:
92-
name: Clippy
93-
runs-on: ubuntu-latest
34+
tests:
35+
name: Build and Test
36+
runs-on: ${{ matrix.os }}
37+
strategy:
38+
matrix:
39+
os:
40+
- macos-latest
41+
- windows-latest
9442
steps:
9543
- uses: actions/checkout@v3
9644
- uses: actions-rs/[email protected]
9745
with:
9846
toolchain: stable
9947
override: true
10048
profile: minimal
101-
components: clippy
102-
- name: Cache cargo
103-
uses: actions/cache@v3
104-
with:
105-
path: |
106-
target
107-
~/.cargo/git
108-
~/.cargo/registry
109-
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
110-
- uses: actions-rs/cargo@v1
111-
with:
112-
command: clippy
113-
args: -- --verbose
49+
- uses: Swatinem/rust-cache@v2
50+
- name: Build tests
51+
run: cargo test --no-run --profile ci
52+
# this order is faster according to rust-analyzer
53+
- name: Build
54+
run: cargo build --all-targets --quiet --profile ci
55+
- name: Install latest nextest
56+
uses: taiki-e/install-action@nextest
57+
- name: Test with nextest
58+
run: cargo nextest run --profile ci --cargo-profile ci --features intl
11459

115-
examples:
116-
name: Examples
60+
misc:
61+
name: Misc
11762
runs-on: ubuntu-latest
11863
steps:
11964
- uses: actions/checkout@v3
@@ -122,45 +67,20 @@ jobs:
12267
toolchain: stable
12368
override: true
12469
profile: minimal
125-
- name: Cache cargo
126-
uses: actions/cache@v3
127-
with:
128-
path: |
129-
target
130-
~/.cargo/git
131-
~/.cargo/registry
132-
key: ${{ runner.os }}-cargo-examples-${{ hashFiles('**/Cargo.lock') }}
70+
components: rustfmt, clippy
71+
- uses: Swatinem/rust-cache@v2
72+
with:
73+
key: misc
74+
- name: Lint (rustfmt)
75+
run: cargo fmt --all --check
76+
- name: Lint (clippy)
77+
run: cargo clippy --all-features --all-targets
78+
- name: Generate documentation
79+
run: cargo doc -v --document-private-items --all-features
80+
- name: Build
81+
run: cargo build --all-targets --quiet --profile ci
13382
- run: cd boa_examples
13483
- name: Build examples
135-
uses: actions-rs/cargo@v1
136-
with:
137-
command: build
84+
run: cargo build --quiet --profile ci
13885
- name: Run example classes
139-
uses: actions-rs/cargo@v1
140-
with:
141-
command: run
142-
args: --bin classes
143-
144-
doc:
145-
name: Documentation
146-
runs-on: ubuntu-latest
147-
steps:
148-
- uses: actions/checkout@v3
149-
- uses: actions-rs/[email protected]
150-
with:
151-
toolchain: stable
152-
override: true
153-
profile: minimal
154-
- name: Cache cargo
155-
uses: actions/cache@v3
156-
with:
157-
path: |
158-
target
159-
~/.cargo/git
160-
~/.cargo/registry
161-
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
162-
- name: Generate documentation
163-
uses: actions-rs/cargo@v1
164-
with:
165-
command: doc
166-
args: -v --document-private-items --all-features
86+
run: cargo run --bin classes --profile ci

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ boa_macros = { version = "0.16.0", path = "boa_macros" }
3232
[workspace.metadata.workspaces]
3333
allow_branch = "main"
3434

35+
# The ci profile, designed to reduce size of target directory
36+
[profile.ci]
37+
inherits = "dev"
38+
debug = false
39+
incremental = false
40+
3541
# The release profile, used for `cargo build --release`.
3642
[profile.release]
3743
# Enables "fat" LTO, for faster release builds

0 commit comments

Comments
 (0)