Skip to content

Commit

Permalink
Switch GitHub actions to actions-rust-lang/setup-toolchain (#1182)
Browse files Browse the repository at this point in the history
* Switch GitHub actions to actions-rust-lang/setup-toolchain

Removes explicit reference to Swatinem/rust-cache as
actions-rust-lang/setup-rust-toolchain automatically uses this action
to enable caching (unless we set `cache: false`).

Also switches our toolchain environment to be the same as the build
environment, as the `rust-toolchain.toml` file overrides it anyway.
This is undesirable: nightly rustfmt has some additional options we
would like to keep.

* Use my branch to allow overriding the toolchain file

Since we use nightly Rust tooling for our linting, we want to override
our usual toolchain for the linting step.  Upstream
`setup-rust-toolchain` currently doesn't allow this.  I have submitted
a PR at
actions-rust-lang/setup-rust-toolchain#26 to
add the functionality, but until then this commit points to a branch
on my personal repository at
https://github.com/Twey/setup-rust-toolchain/.  We should revert it
once the PR is merged.
  • Loading branch information
Twey authored Nov 1, 2023
1 parent 4ac2464 commit c384aa0
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 52 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- uses: Twey/setup-rust-toolchain@v1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
Expand All @@ -59,9 +57,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- uses: Twey/setup-rust-toolchain@v1
- name: Checkout docs.rs tool repository
run: |
cd ${{ runner.temp }}
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/dynamodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ jobs:
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
target: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- uses: Twey/setup-rust-toolchain@v1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/explorer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
target: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- uses: Twey/setup-rust-toolchain@v1
- name: Build
run: |
cd linera-explorer
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
profile: minimal
- uses: Swatinem/rust-cache@v2
- uses: Twey/setup-rust-toolchain@v1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
Expand Down
23 changes: 6 additions & 17 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
target: wasm32-unknown-unknown
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- uses: Twey/setup-rust-toolchain@v1
- name: Clear up some space
run: |
sudo rm -rf /usr/share/dotnet
Expand Down Expand Up @@ -102,17 +97,11 @@ jobs:
run: >
find linera-* -name '*.rs' -a -not -wholename '*/target/*' -print0
| xargs -0 -L1 ./scripts/target/release/check_copyright_header
- uses: actions-rs/toolchain@v1
- uses: Twey/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: nightly-2023-10-22
target: wasm32-unknown-unknown
components: clippy
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt
- uses: Swatinem/rust-cache@v2
components: clippy rustfmt
- name: Install cargo-machete
run: |
cargo install cargo-machete --locked
Expand All @@ -131,7 +120,7 @@ jobs:
cargo install cargo-sort --locked
- name: Check formatting
run: |
cargo +nightly fmt -- --check
cargo +nightly-2023-10-22 fmt -- --check
- name: Check for unused dependencies
run: |
cargo machete
Expand All @@ -143,7 +132,7 @@ jobs:
- name: Run Wasm application lints
run: |
cd examples
cargo +nightly fmt -- --check
cargo fmt -- --check
cargo clippy --all-targets --all-features --target wasm32-unknown-unknown --locked
cargo clippy --all-targets --all-features --target x86_64-unknown-linux-gnu --locked
- name: Run clippy
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/scylladb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ jobs:
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
target: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- uses: Twey/setup-rust-toolchain@v1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
Expand Down
9 changes: 2 additions & 7 deletions linera-service/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Project {
debug!("writing Cargo.toml");
Self::create_cargo_toml(&root, name, linera_root)?;

debug!("writing rust-toolchain");
debug!("writing rust-toolchain.toml");
Self::create_rust_toolchain(&root)?;

debug!("writing state.rs");
Expand Down Expand Up @@ -167,15 +167,10 @@ impl Project {
}

fn create_rust_toolchain(project_root: &Path) -> Result<()> {
Self::write_string_to_file(
&project_root.join("rust-toolchain"),
include_str!("../template/rust-toolchain.template"),
)?;
Self::write_string_to_file(
&project_root.join("rust-toolchain.toml"),
include_str!("../template/rust-toolchain.toml.template"),
)?;
Ok(())
)
}

fn create_state_file(source_directory: &Path) -> Result<()> {
Expand Down
1 change: 0 additions & 1 deletion linera-service/template/rust-toolchain.template

This file was deleted.

1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

3 changes: 2 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[toolchain]
channel = "1.72.0"
components = [ "rustfmt", "rustc-dev", "rust-src" ]
components = [ "clippy", "rustfmt", "rust-src" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "minimal"

0 comments on commit c384aa0

Please sign in to comment.