├── .github └── workflows │ └── ci.yml ├── LICENSE ├── README.md └── action.yml /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | workflow_dispatch: 8 | schedule: [cron: "40 1 * * *"] 9 | 10 | permissions: 11 | contents: read 12 | 13 | jobs: 14 | install: 15 | name: Rust ${{matrix.rust}} on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}} 16 | runs-on: ${{matrix.os}}-latest 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | os: [ubuntu, macos, windows] 21 | rust: [nightly, beta, stable, 1.62.0] 22 | include: 23 | - os: ubuntu 24 | rust: 1.0.0 25 | timeout-minutes: 45 26 | steps: 27 | - uses: actions/checkout@v3 28 | - name: Create toolchain file 29 | shell: bash 30 | run: | 31 | echo "[toolchain]" >> rust-toolchain.toml 32 | echo "channel = \"${{matrix.rust}}\"" >> rust-toolchain.toml 33 | cat rust-toolchain.toml 34 | - uses: ./ 35 | name: Run dsherret/rust-toolchain-file${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}} 36 | id: toolchain 37 | - name: echo ${{'${{steps.toolchain.outputs.cachekey}}'}} 38 | run: echo '${{steps.toolchain.outputs.cachekey}}' 39 | - name: check ${{'${{steps.toolchain.outputs.cachekey}}'}} 40 | if: matrix.rust == '1.62.0' 41 | run: cmp -s <(echo ${{steps.toolchain.outputs.cachekey}}) <(echo 20220627a831) 42 | shell: bash 43 | - run: rustc --version 44 | - run: cargo init . --bin --name CI 45 | if: matrix.rust == 'nightly' || matrix.rust == 'beta' || matrix.rust == 'stable' 46 | - run: cargo add syn@1 47 | if: matrix.rust == 'nightly' || matrix.rust == 'beta' || matrix.rust == 'stable' 48 | - run: cargo check 49 | if: matrix.rust == 'nightly' || matrix.rust == 'beta' || matrix.rust == 'stable' 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Install Rust Toolchain via rust-toolchain.toml 2 | 3 | GitHub Action to install Rust's toolchain via the 4 | [`rust-toolchain.toml`](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) 5 | file in your repository. 6 | 7 | Fork of https://github.com/dtolnay/rust-toolchain that supports and makes it 8 | mandatory to use a rust-toolchain.toml file. Unfortunately `rust-toolchain` did 9 | not want to support installing from a rust-toolchain.toml file, so this project 10 | exists. If you do not want to use a rust-toolchain.toml file, then please use 11 | that project as this action does not support other inputs. 12 | 13 | Note: GitHub actions now 14 | [automatically sets up](https://github.com/actions-rs/toolchain/issues/126#issuecomment-1463045252) 15 | the Rust version based on the rust-toolchain.toml, but it won't setup the other 16 | defaults from `dtolnay/rust-toolchain` for you like enabling colours on the CI 17 | as this action will. 18 | 19 | ## Example workflow 20 | 21 | 1. Create a 22 | [`rust-toolchain.toml`](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) 23 | file in the root directory of your repository: 24 | 25 | ```toml 26 | [toolchain] 27 | channel = "1.68" 28 | components = [ "rustfmt", "clippy" ] 29 | ``` 30 | 31 | 2. Add an entry to this action in your GitHub Actions workflow file (ensure the 32 | repo is checked out first): 33 | 34 | ```yaml 35 | name: test suite 36 | on: [push, pull_request] 37 | 38 | jobs: 39 | test: 40 | name: cargo test 41 | runs-on: ubuntu-latest 42 | steps: 43 | - uses: actions/checkout@v3 44 | - uses: dsherret/rust-toolchain-file@v1 45 | - run: cargo test --all-features 46 | ``` 47 | 48 | The selection of Rust toolchain on the CI will then be made based on the 49 | rust-toolchain.toml file enabling you to easily keep it in sync with your local 50 | development versions and have a single source of truth for what version to use. 51 | 52 | ## Inputs 53 | 54 | You must define everything in the rust-toolchain.toml file. 55 | 56 | ## Outputs 57 | 58 |
Name | 61 |Description | 62 |
---|---|
cachekey |
65 | A short hash of the installed rustc version, appropriate for use as a cache key. "20220627a831" |
66 |
name |
69 | Rustup's name for the selected version of the toolchain, like "1.62.0" . Suitable for use with cargo +${{steps.toolchain.outputs.name}} . |
70 |