-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Enable caching #702
ci: Enable caching #702
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ jobs: | |
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install qemu and OVMF | ||
run: | | ||
sudo apt-get update | ||
|
@@ -36,6 +38,8 @@ jobs: | |
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My concern here is only that the same cache is uploaded multiple times.. simultaneously by every job as for every new change to the dependencies, they all do perform the cargo install in parallel. |
||
|
||
- name: Install qemu and OVMF | ||
run: | | ||
sudo apt-get update | ||
|
@@ -52,6 +56,8 @@ jobs: | |
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install qemu and OVMF | ||
run: | | ||
sudo apt-get update | ||
|
@@ -68,6 +74,8 @@ jobs: | |
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Run cargo test (without unstable) | ||
run: cargo xtask test | ||
|
||
|
@@ -78,6 +86,8 @@ jobs: | |
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Run cargo fmt | ||
run: | | ||
rustup component add rustfmt | ||
|
@@ -111,6 +121,8 @@ jobs: | |
- name: Set MSRV toolchain | ||
run: cp .github/workflows/msrv_toolchain.toml rust-toolchain.toml | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build | ||
run: cargo xtask test-latest-release | ||
|
||
|
@@ -124,6 +136,8 @@ jobs: | |
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Run VM tests | ||
run: cargo xtask run --target x86_64 --ci | ||
timeout-minutes: 6 | ||
|
@@ -143,6 +157,8 @@ jobs: | |
- name: Set toolchain | ||
run: cp .github/workflows/msrv_toolchain.toml rust-toolchain.toml | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build | ||
run: cargo xtask build | ||
|
||
|
@@ -158,6 +174,8 @@ jobs: | |
- name: Set nightly toolchain so that `unstable` can be included | ||
run: cp .github/workflows/nightly_toolchain.toml rust-toolchain.toml | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build | ||
run: cargo xtask build --feature-permutations | ||
|
||
|
@@ -176,6 +194,8 @@ jobs: | |
- name: Enable nightly toolchain | ||
run: cp .github/workflows/nightly_toolchain.toml rust-toolchain.toml | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Run VM tests with the `unstable` feature | ||
run: cargo xtask run --target x86_64 --headless --ci --unstable | ||
timeout-minutes: 4 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use an approach as in https://github.com/rust-osdev/multiboot2/blob/main/.github/workflows/_build-rust.yml#L52 instead.
The solution you picked for caching only caches dependencies and only works reliably with a Cargo.lock file, as the README says. https://github.com/Swatinem/rust-cache
Hence, I'm in favor of a solution as in the Multiboot2 crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to use a prebuilt solution if possible (easier to read the CI config then, and hopefully simpler to maintain), so I'd like to carefully check that
Swatinem/rust-cache
really doesn't meet our needs.That's a good point about
Cargo.lock
, but we could probably just check inCargo.lock
. The Cargo FAQ recommends against it, but I've often seen that recommendation debated. See rust-lang/cargo#8728 for example. Alternatively, we could skip checking inCargo.lock
and see how much difference it makes for us in practice. We have a nightly CI run, and I think we might find that does a decent job of initializing our caches so that PR runs are fast (which is probably when we will actually notice and care about CI time).As to only caching dependencies, I think that's fine.
rust-cache
makes the claim that caching incremental builds of the crate itself is generally not effective, and I find that convincing. Caching the deps used byxtask
in particular is what will really save a lot of CI time I think.Regarding total space used by the cache:
So about 5.5GiB currently in use for this project. That seems fine right?
Lastly, I tried running the CI on this PR, then running it a second time. All the jobs with the cache enabled ran faster. That seems like pretty strong evidence to me that the cache is working as intended. On the left is the first run without an up-to-date cache, and on the right is the run with a good cache:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few ideas I like to try out, ok? I think, we can have a neat and simpler solution for everything.. let's see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I tested something like in the multiboot2 repo: one single big workflow that covers all the building, style checks, unit testing and integration tests that has a lot of configure options.
The outcome is a big feature-creep, semi-working variant.