Browse Source

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.~~
pull/2380/head
João Borges 2 years ago
parent
commit
48e6513564
  1. 3
      .config/nextest.toml
  2. 162
      .github/workflows/bors.yml
  3. 164
      .github/workflows/rust.yml
  4. 6
      Cargo.toml
  5. 22
      bors.toml

3
.config/nextest.toml

@ -0,0 +1,3 @@
[profile.ci]
# Don't fail fast in CI to run the full test suite.
fail-fast = false

162
.github/workflows/bors.yml

@ -1,162 +0,0 @@
name: bors
on:
push:
branches:
- staging
- trying
jobs:
test_on_linux:
name: Tests on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: test
args: -v
test_on_windows:
name: Tests on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: test
args: -v
test_on_macos:
name: Tests on MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: test
args: -v
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
components: clippy
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- --verbose
examples:
name: Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-examples-${{ hashFiles('**/Cargo.lock') }}
- run: cd boa_examples
- name: Build examples
uses: actions-rs/cargo@v1
with:
command: build
- name: Run example classes
uses: actions-rs/cargo@v1
with:
command: run
args: --bin classes
doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: -v --document-private-items --all-features

164
.github/workflows/rust.yml

@ -1,3 +1,5 @@
name: Continuous integration
on: on:
pull_request: pull_request:
branches: branches:
@ -5,12 +7,12 @@ on:
push: push:
branches: branches:
- main - main
- staging # bors
name: Continuous integration - trying # bors
jobs: jobs:
test_on_linux: coverage:
name: Tests on Linux name: Coverage
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -19,14 +21,9 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
profile: minimal profile: minimal
- name: Cache cargo - uses: Swatinem/rust-cache@v2
uses: actions/cache@v3
with: with:
path: | key: tarpaulin
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- name: Run cargo-tarpaulin - name: Run cargo-tarpaulin
uses: actions-rs/tarpaulin@v0.1 uses: actions-rs/tarpaulin@v0.1
with: with:
@ -34,63 +31,14 @@ jobs:
- name: Upload to codecov.io - name: Upload to codecov.io
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
test_on_windows: tests:
name: Tests on Windows name: Build and Test
runs-on: windows-latest runs-on: ${{ matrix.os }}
steps: strategy:
- uses: actions/checkout@v3 matrix:
- uses: actions-rs/toolchain@v1.0.7 os:
with: - macos-latest
toolchain: stable - windows-latest
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: test
args: -v --features intl
test_on_macos:
name: Tests on MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: test
args: -v --features intl
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7 - uses: actions-rs/toolchain@v1.0.7
@ -98,22 +46,19 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
profile: minimal profile: minimal
components: clippy - uses: Swatinem/rust-cache@v2
- name: Cache cargo - name: Build tests
uses: actions/cache@v3 run: cargo test --no-run --profile ci
with: # this order is faster according to rust-analyzer
path: | - name: Build
target run: cargo build --all-targets --quiet --profile ci
~/.cargo/git - name: Install latest nextest
~/.cargo/registry uses: taiki-e/install-action@nextest
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }} - name: Test with nextest
- uses: actions-rs/cargo@v1 run: cargo nextest run --profile ci --cargo-profile ci --features intl
with:
command: clippy
args: -- --verbose
examples: misc:
name: Examples name: Misc
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -122,45 +67,20 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
profile: minimal profile: minimal
- name: Cache cargo components: rustfmt, clippy
uses: actions/cache@v3 - uses: Swatinem/rust-cache@v2
with: with:
path: | key: misc
target - name: Lint (rustfmt)
~/.cargo/git run: cargo fmt --all --check
~/.cargo/registry - name: Lint (clippy)
key: ${{ runner.os }}-cargo-examples-${{ hashFiles('**/Cargo.lock') }} run: cargo clippy --all-features --all-targets
- name: Generate documentation
run: cargo doc -v --document-private-items --all-features
- name: Build
run: cargo build --all-targets --quiet --profile ci
- run: cd boa_examples - run: cd boa_examples
- name: Build examples - name: Build examples
uses: actions-rs/cargo@v1 run: cargo build --quiet --profile ci
with:
command: build
- name: Run example classes - name: Run example classes
uses: actions-rs/cargo@v1 run: cargo run --bin classes --profile ci
with:
command: run
args: --bin classes
doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.7
with:
toolchain: stable
override: true
profile: minimal
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
target
~/.cargo/git
~/.cargo/registry
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
- name: Generate documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: -v --document-private-items --all-features

6
Cargo.toml

@ -32,6 +32,12 @@ boa_macros = { version = "0.16.0", path = "boa_macros" }
[workspace.metadata.workspaces] [workspace.metadata.workspaces]
allow_branch = "main" allow_branch = "main"
# The ci profile, designed to reduce size of target directory
[profile.ci]
inherits = "dev"
debug = false
incremental = false
# The release profile, used for `cargo build --release`. # The release profile, used for `cargo build --release`.
[profile.release] [profile.release]
# Enables "fat" LTO, for faster release builds # Enables "fat" LTO, for faster release builds

22
bors.toml

@ -1,21 +1,15 @@
# docs https://bors.tech/documentation/ # docs https://bors.tech/documentation/
status = [ status = [
"Tests on Linux", "Coverage",
"Tests on Windows", "Build and Test (macos-latest)",
"Tests on MacOS", "Build and Test (windows-latest)",
"Rustfmt", "Misc",
"Clippy",
"Examples",
"Documentation",
] ]
pr_status = [ pr_status = [
"Tests on Linux", "Coverage",
"Tests on Windows", "Build and Test (macos-latest)",
"Tests on MacOS", "Build and Test (windows-latest)",
"Rustfmt", "Misc",
"Clippy",
"Examples",
"Documentation",
] ]
block_labels = [ "blocked" ] block_labels = [ "blocked" ]
required_approvals = 2 required_approvals = 2

Loading…
Cancel
Save