From 6d0d22bd2b79b74a697ef31865cfc58a3560d077 Mon Sep 17 00:00:00 2001 From: RageKnify Date: Mon, 24 Oct 2022 11:29:17 +0100 Subject: [PATCH 1/9] chore: Cleanup and speed-up CI This introduces multiple changes to our CI setup - Switch cache action to rust-cache, this handles which directories to cache for us - Switch to the nextest[2] test runner for Windows and MacOS - Join the smaller jobs into one bigger misc job that handles clippy, rustfmt, documentation and examples. This should still be faster than the linux job and should save some resources overall [1] - https://github.com/Swatinem/rust-cache [2] - https://nexte.st/ --- .config/nextest.toml | 3 + .github/workflows/rust.yml | 156 +++++++++---------------------------- Cargo.toml | 6 ++ 3 files changed, 44 insertions(+), 121 deletions(-) create mode 100644 .config/nextest.toml diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 00000000000..18e4061a01f --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,3 @@ +[profile.ci] +# Don't fail fast in CI to run the full test suite. +fail-fast = false diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e7c170dff0d..6d924e2996f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,8 +9,8 @@ on: name: Continuous integration jobs: - test_on_linux: - name: Tests on Linux + linux: + name: Build and Test on Linux runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -19,14 +19,9 @@ jobs: 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: Swatinem/rust-cache@v2 + - name: Build + run: cargo build --all-targets --quiet - name: Run cargo-tarpaulin uses: actions-rs/tarpaulin@v0.1 with: @@ -34,9 +29,14 @@ jobs: - name: Upload to codecov.io uses: codecov/codecov-action@v3 - test_on_windows: - name: Tests on Windows - runs-on: windows-latest + tests: + name: Build and Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - macos-latest + - windows-latest steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1.0.7 @@ -44,36 +44,19 @@ jobs: 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 --features intl + - uses: Swatinem/rust-cache@v2 + - name: Build tests + run: cargo test --no-run --profile ci + # this order is faster according to rust-analyzer + - name: Build + run: cargo build --all-targets --quiet --profile ci + - name: Install latest nextest release + uses: taiki-e/install-action@nextest + - name: Test with latest nextest release + run: cargo nextest run -- --profile ci --cargo-profile ci --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 + misc: + name: Misc (clippy, rustfmt, docs, examples) runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -82,85 +65,16 @@ jobs: 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') }} + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + - name: Lint (clippy) + run: cargo clippy --all-features --all-targets + - name: Lint (rustfmt) + run: cargo fmt --all --check + - name: Generate documentation + run: cargo doc -v --document-private-items --all-features - run: cd boa_examples - name: Build examples - uses: actions-rs/cargo@v1 - with: - command: build + run: cargo build --quiet --profile ci - 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 + run: cargo run --bin classes --profile ci diff --git a/Cargo.toml b/Cargo.toml index bbb50e7f50c..5aa35f87222 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,12 @@ boa_macros = { version = "0.16.0", path = "boa_macros" } allow_branch = "main" # The release profile, used for `cargo build --release`. +[profile.ci] +inherits = "dev" +# reduce size of ci cache +debug = false +incremental = false + [profile.release] # Enables "fat" LTO, for faster release builds lto = "fat" From 7e10cec0d4b4af917695b3352379b5244cd5368b Mon Sep 17 00:00:00 2001 From: RageKnify Date: Mon, 24 Oct 2022 13:01:56 +0100 Subject: [PATCH 2/9] chore: Try to fix nextest flags --- .github/workflows/rust.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6d924e2996f..69b8b00b8a8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,10 +50,10 @@ jobs: # this order is faster according to rust-analyzer - name: Build run: cargo build --all-targets --quiet --profile ci - - name: Install latest nextest release + - name: Install latest nextest uses: taiki-e/install-action@nextest - - name: Test with latest nextest release - run: cargo nextest run -- --profile ci --cargo-profile ci --features intl + - name: Test with nextest + run: cargo nextest run --profile ci --cargo-profile ci --features intl misc: name: Misc (clippy, rustfmt, docs, examples) From 6bcd19c3ce0bd12aa6534cd42d95a13d8fab5335 Mon Sep 17 00:00:00 2001 From: RageKnify Date: Mon, 24 Oct 2022 13:23:30 +0100 Subject: [PATCH 3/9] chore: rustfmt before clippy (fail faster) --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 69b8b00b8a8..bde4bf75da8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -67,10 +67,10 @@ jobs: profile: minimal components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 - - name: Lint (clippy) - run: cargo clippy --all-features --all-targets - name: Lint (rustfmt) run: cargo fmt --all --check + - name: Lint (clippy) + run: cargo clippy --all-features --all-targets - name: Generate documentation run: cargo doc -v --document-private-items --all-features - run: cd boa_examples From 52a4ec80665c1b8a9ba64c5118b72de156d6ab88 Mon Sep 17 00:00:00 2001 From: RageKnify Date: Mon, 24 Oct 2022 13:34:29 +0100 Subject: [PATCH 4/9] chore: Check linux build with misc tarpaulin is very slow already, this should balance things out --- .github/workflows/rust.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bde4bf75da8..ce768d31e81 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,7 +10,7 @@ name: Continuous integration jobs: linux: - name: Build and Test on Linux + name: Calculate coverage information runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -20,8 +20,6 @@ jobs: override: true profile: minimal - uses: Swatinem/rust-cache@v2 - - name: Build - run: cargo build --all-targets --quiet - name: Run cargo-tarpaulin uses: actions-rs/tarpaulin@v0.1 with: @@ -56,7 +54,7 @@ jobs: run: cargo nextest run --profile ci --cargo-profile ci --features intl misc: - name: Misc (clippy, rustfmt, docs, examples) + name: Misc (rustfmt, clippy, docs, check build, examples) runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -73,6 +71,8 @@ jobs: 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 - name: Build examples run: cargo build --quiet --profile ci From ada22e53571c361e2162633ea2099511f36c11a6 Mon Sep 17 00:00:00 2001 From: RageKnify Date: Mon, 24 Oct 2022 15:35:43 +0100 Subject: [PATCH 5/9] chore: Fix profile comments --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5aa35f87222..cffa4bbe1ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,13 +32,13 @@ boa_macros = { version = "0.16.0", path = "boa_macros" } [workspace.metadata.workspaces] allow_branch = "main" -# The release profile, used for `cargo build --release`. +# The ci profile, designed to reduce size of target directory [profile.ci] inherits = "dev" -# reduce size of ci cache debug = false incremental = false +# The release profile, used for `cargo build --release`. [profile.release] # Enables "fat" LTO, for faster release builds lto = "fat" From 3326a894fe85e20a257495a5cf1441ccb860c3db Mon Sep 17 00:00:00 2001 From: RageKnify Date: Mon, 24 Oct 2022 18:58:35 +0100 Subject: [PATCH 6/9] chore: separate rust-cache for tarpaulin and misc This will make them have separate cache keys, meaning they don't share their target directory and each one stores and loads a smaller archive from the cache. --- .github/workflows/rust.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ce768d31e81..9aca364e834 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,7 +9,7 @@ on: name: Continuous integration jobs: - linux: + coverage: name: Calculate coverage information runs-on: ubuntu-latest steps: @@ -20,6 +20,7 @@ jobs: override: true profile: minimal - uses: Swatinem/rust-cache@v2 + key: tarpaulin - name: Run cargo-tarpaulin uses: actions-rs/tarpaulin@v0.1 with: @@ -65,6 +66,7 @@ jobs: profile: minimal components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 + key: misc - name: Lint (rustfmt) run: cargo fmt --all --check - name: Lint (clippy) From abfc071139415c8755a0eaf0285b04c6987f8ead Mon Sep 17 00:00:00 2001 From: RageKnify Date: Tue, 25 Oct 2022 11:38:50 +0100 Subject: [PATCH 7/9] chore: Update bors.toml, cleanup rust.yml Simplified the name of the jobs in rust.yml Removed bors.yml, it was just copying rust.yml, instead this adds the staging and trying branches to the list of branches where the ci should run --- .github/workflows/bors.yml | 162 ------------------------------------- .github/workflows/rust.yml | 10 ++- bors.toml | 22 ++--- 3 files changed, 14 insertions(+), 180 deletions(-) delete mode 100644 .github/workflows/bors.yml diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml deleted file mode 100644 index af3785231ad..00000000000 --- a/.github/workflows/bors.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9aca364e834..9f6105c42aa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,3 +1,5 @@ +name: Continuous integration + on: pull_request: branches: @@ -5,12 +7,12 @@ on: push: branches: - main - -name: Continuous integration + - staging # bors + - trying # bors jobs: coverage: - name: Calculate coverage information + name: Coverage runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -55,7 +57,7 @@ jobs: run: cargo nextest run --profile ci --cargo-profile ci --features intl misc: - name: Misc (rustfmt, clippy, docs, check build, examples) + name: Misc runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/bors.toml b/bors.toml index c16f2d13b65..ab5bf23a1d6 100644 --- a/bors.toml +++ b/bors.toml @@ -1,21 +1,15 @@ # docs https://bors.tech/documentation/ status = [ - "Tests on Linux", - "Tests on Windows", - "Tests on MacOS", - "Rustfmt", - "Clippy", - "Examples", - "Documentation", + "Coverage", + "Build and Test (macos-latest)", + "Build and Test (windows-latest)", + "Misc", ] pr_status = [ - "Tests on Linux", - "Tests on Windows", - "Tests on MacOS", - "Rustfmt", - "Clippy", - "Examples", - "Documentation", + "Coverage", + "Build and Test (macos-latest)", + "Build and Test (windows-latest)", + "Misc", ] block_labels = [ "blocked" ] required_approvals = 2 From 17eccb19f3a5bff47a07a51295cd39cc92611e7a Mon Sep 17 00:00:00 2001 From: RageKnify Date: Tue, 25 Oct 2022 11:49:08 +0100 Subject: [PATCH 8/9] chore: Fix rust-cache usage --- .github/workflows/rust.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9f6105c42aa..9c4bafd4954 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,7 +22,8 @@ jobs: override: true profile: minimal - uses: Swatinem/rust-cache@v2 - key: tarpaulin + with: + key: tarpaulin - name: Run cargo-tarpaulin uses: actions-rs/tarpaulin@v0.1 with: @@ -68,7 +69,8 @@ jobs: profile: minimal components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 - key: misc + with: + key: misc - name: Lint (rustfmt) run: cargo fmt --all --check - name: Lint (clippy) From ac04a60d4b02f6392ff4994ff9449f21c69176bd Mon Sep 17 00:00:00 2001 From: RageKnify Date: Tue, 25 Oct 2022 12:03:20 +0100 Subject: [PATCH 9/9] style: Fix prettier --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9c4bafd4954..58c181022a8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,7 +8,7 @@ on: branches: - main - staging # bors - - trying # bors + - trying # bors jobs: coverage: