Repository: rust-cli/config-rs (language: rust)

Issue:
Investigate ways to make CI faster
I really don't like how slow CI is for this repository.

If someone wants to make CI faster, I'd love to see PRs for that!


Discussion / hints:
Just came across this, might be worth looking into if someone does tackle this:
- https://nexte.st/
- https://github.com/nextest-rs/nextest

Doesn't really look like the tests are using that much time, more so on the build portion prior.

---

You could have your matrix build jobs start with building `config-rs` with dev-dependencies, and [uploading that artifact](https://github.com/nextest-rs/reuse-build-partition-example/blob/18818174bd49d8ffb39414bbb29e3d8d8f1fe85a/.github/workflows/ci.yml#L36-L37) for all subsequent matrix jobs to [download a copy of](https://github.com/nextest-rs/reuse-build-partition-example/blob/18818174bd49d8ffb39414bbb29e3d8d8f1fe85a/.github/workflows/ci.yml#L62-L63). Might be a speed-up.

If `actions/cache` action can be leveraged, that's usually nicer and they can avoid that initial job, one will upload the cache if it's fresh and subsequent runs of the CI will bring in that cache if nothing has changed (eg: `Cargo.lock`).

---

I haven't worked with Rust with Github Actions, but I imagine you could cache some of the time consuming parts. I see in the actions history:
- Some jobs take 5 minutes to run `cargo --check`. Those seem to be for a specific MSRV version rather than stable/beta/nightly channels. Not sure why they are slower, perhaps Github has some cache proxy layer for the more common channels to save bandwidth? 🤷‍♂️ 
- Other jobs like `cargo clippy` and `cargo test` can take 1-2 minutes to download and compile the crates, which is the bulk of the jobs. Leveraging cache would help there a fair bit.

A quick look, [this action](https://github.com/marketplace/actions/rust-cache) seems to be a popular way to cache dependencies, benefits from a `Cargo.lock` being present, with only caveat being less useful on Nightly toolchain. So that should hopefully make a difference with https://github.com/mehcode/config-rs/pull/492 👍 


Fix patch:
diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml
index 49b33561..723c1cef 100644
--- a/.github/workflows/msrv.yml
+++ b/.github/workflows/msrv.yml
@@ -6,14 +6,6 @@ jobs:
   check:
     name: Check
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        rust:
-          - 1.70.0
-          - stable
-          - beta
-          - nightly
-
     steps:
       - name: Checkout sources
         uses: actions/checkout@v4.1.1
@@ -21,28 +13,17 @@ jobs:
       - name: Install toolchain
         uses: dtolnay/rust-toolchain@master
         with:
-          toolchain: ${{ matrix.rust }}
+          toolchain: 1.70.0
 
-      - name: Run cargo check
-        if: matrix.rust != 'nightly'
-        run: cargo check --all-features
+      - name: Cache
+        uses: Swatinem/rust-cache@v2
 
-      - name: Run cargo check (nightly)
-        if: matrix.rust == 'nightly'
-        continue-on-error: true
-        run: cargo check --all-features
+      - name: Run cargo check
+        run: cargo check --all-features --examples --tests
 
   test:
-    needs: [check]
     name: Test Suite
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        rust:
-          - 1.70.0
-          - stable
-          - beta
-          - nightly
     steps:
       - name: Checkout sources
         uses: actions/checkout@v4.1.1
@@ -50,31 +31,18 @@ jobs:
       - name: Install toolchain
         uses: dtolnay/rust-toolchain@master
         with:
-          toolchain: ${{ matrix.rust }}
-
-      - name: Run cargo test
-        if: matrix.rust != 'nightly' && matrix.rust != '1.56.1'
-        run: cargo test --all-features
+          toolchain: 1.70.0
 
-      - name: Run cargo test (nightly)
-        if: matrix.rust == '1.66.0'
-        continue-on-error: true
-        run: cargo test --tests --all-features
+      - name: Cache
+        uses: Swatinem/rust-cache@v2
 
-      - name: Run cargo test (nightly)
-        if: matrix.rust == 'nightly'
-        continue-on-error: true
+      - name: Run cargo test
         run: cargo test --all-features
 
   fmt:
     needs: [check]
     name: Rustfmt
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        rust:
-          - stable
-          - beta
     steps:
       - name: Checkout sources
         uses: actions/checkout@v4.1.1
@@ -82,21 +50,17 @@ jobs:
       - name: Install toolchain
         uses: dtolnay/rust-toolchain@master
         with:
-          toolchain: ${{ matrix.rust }}
+          toolchain: 1.70.0
           components: rustfmt
 
       - name: Run cargo fmt
+        continue-on-error: ${{ matrix.rust == 'beta' }}
         run: cargo fmt --all -- --check
 
   clippy:
     needs: [check]
     name: Clippy
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        rust:
-          - 1.70.0
-          - 1.73.0
     steps:
       - name: Checkout sources
         uses: actions/checkout@v4.1.1
@@ -104,32 +68,12 @@ jobs:
       - name: Install toolchain
         uses: dtolnay/rust-toolchain@master
         with:
-          toolchain: ${{ matrix.rust }}
+          toolchain: 1.70.0
           components: clippy
 
+      - name: Cache
+        uses: Swatinem/rust-cache@v2
+
       - name: Run cargo clippy
         run: cargo clippy --all-targets --all-features -- -D warnings
 
-  check-examples:
-    name: Check examples
-    needs: [check]
-    runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        rust:
-          - 1.70.0
-          - 1.73.0
-
-    steps:
-      - name: Checkout sources
-        uses: actions/checkout@v4.1.1
-
-      - name: Install toolchain
-        uses: dtolnay/rust-toolchain@master
-        with:
-          toolchain: ${{ matrix.rust }}
-          components: clippy
-
-      - name: Run cargo check
-        run: cargo check --examples
-


Test patch: