Closed fprasx closed 10 months ago
I'd like to contrive a test (that would fail on current main) before merging this. I can do it or you can have a crack if you want.
Hmm, I don't want to spend too much time on this if you have time, because you'll definitely be more efficient than I am (I'm not great with yaml or bash). My initial idea is to do something like:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 521e3f6..0e959d9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -12,10 +12,11 @@ jobs:
strategy:
fail-fast: false
matrix:
- rust:
- # Test with toolchain file override
- - null
+ use-toolchain-file:
+ - true
+ - false
+ rust:
# Test that the sparse registry check works.
# 1.66 and 1.67 don't support stable sparse registry.
- "1.66"
@@ -32,7 +33,7 @@ jobs:
# Test toolchain file support
- name: Write rust-toolchain.toml
- if: matrix.rust == null
+ if: matrix.use-toolchain-file == true
shell: bash
run: |
cat <<EOF >>rust-toolchain.toml
@@ -51,7 +52,11 @@ jobs:
components: clippy
- name: Check ${{'${{steps.toolchain.outputs.rustc-version}}'}}
- run: echo '${{steps.toolchain.outputs.rustc-version}}'
+ run: |
+ realversion=$(rustc --version)
+ [ "$realversion" != {{steps.toolchain.outputs.rustc-version}} ] || \
+ { echo "toolchain file not overridden: found $realversion"; exit 1}
- name: Check ${{'${{steps.toolchain.outputs.cargo-version}}'}}
run: echo '${{steps.toolchain.outputs.cargo-version}}'
Basically you do every test case with and without a toolchain file, but check that the resulting active toolchain is always the desired one. This is a little bad though because it would immediately double CI usage.
That's a good start; thanks! I'll get it sorted today then.
Thank you both! 🚀
Thank you @fprasx for submitting the PR and thanks @robjtede, for adding the tests.
Using rustup override set will override a local rust-toolchain.toml file while rustup default will not.
Resolves #31