Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Automatically install toolchain from rust-toolchain.toml #195

Open
2 of 3 tasks
npmccallum opened this issue Oct 1, 2021 · 4 comments
Open
2 of 3 tasks

Automatically install toolchain from rust-toolchain.toml #195

npmccallum opened this issue Oct 1, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@npmccallum
Copy link

Do the checklist before filing an issue:

Motivation

Cargo now offers the rust-toolchain.toml file which allows a project to specify what toolchain details it needs. Currently, actions-rs requires you to set up two actions:

  • actions-rs/toolchain@v1 - install the toolchain things you need
  • actions-rs/cargo@v1 - run cargo (i.e. build)

Instead, the actions-rs/cargo@v1 action could detect if no toolchain was manually specified in the actions yml. If not, it should read rust-toolchain.toml and install all the required stuff automatically.

Workflow example

rust-toolchain.toml:

[toolchain]
channel = "nightly-2021-09-30"
targets = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"]
profile = "minimal"

.github/workflows/test.yml:

on: [push]

name: CI

jobs:
  build_and_test:
    name: Rust project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --all-features

Notice the lack of any reference to actions-rs/toolchain@v1. Instead, actions-rs/cargo@v1 will install everything required as specified in the rust-toolchain.toml file.

Additional context

https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file

@npmccallum npmccallum added the enhancement New feature or request label Oct 1, 2021
@npmccallum
Copy link
Author

Alternatively, you could do:

on: [push]

name: CI

jobs:
  build_and_test:
    name: Rust project
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
      - uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --all-features

Where the toolchain action gathers all the details from the rust-toolchain.toml file.

@maroider
Copy link

Where the toolchain action gathers all the details from the rust-toolchain.toml file.

This doesn't work at all for me. The action just fails with toolchain input was not given and repository does not have a rust-toolchain file.

.github/workflows/release.yml
name: Release
on:
  push:
    tags:
      - "v*.*.*"

jobs:
  build:
    runs-on: windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup Rust toolchain
        uses: actions-rs/toolchain@v1
      - name: Build release binary
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          files: target/release/fstlg.exe
rust-toolchain.toml
[toolchain]
channel = "nightly-2022-08-14"

@zicklag
Copy link

zicklag commented Nov 4, 2022

@maroider I believe that @npmccallum is saying that would be an alternative way that the action could behave, not how it behaves currently.


For what it's worth, either of the options above for potential behaviors would be quite useful to me.

@dsherret
Copy link

I created a new minimal action specifically for this for anyone who needs it: https://github.com/dsherret/rust-toolchain-file

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Development

No branches or pull requests

4 participants