mirror of
https://github.com/dtolnay/rust-toolchain.git
synced 2025-06-07 03:06:38 +00:00
Only support a rust-toolchain.toml file
This commit is contained in:
parent
e12eda571d
commit
9bde10f6e6
4 changed files with 39 additions and 165 deletions
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
@ -2,7 +2,7 @@ name: CI
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
schedule: [cron: "40 1 * * *"]
|
||||
|
@ -25,8 +25,13 @@ jobs:
|
|||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Create toolchain file
|
||||
run: |
|
||||
echo "[toolchain]" >> rust-toolchain.toml
|
||||
echo "channel = \"${{matrix.rust}}\"" >> rust-toolchain.toml
|
||||
cat rust-toolchain.toml
|
||||
- uses: ./
|
||||
name: Run dtolnay/rust-toolchain${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}}
|
||||
name: Run dsherret/rust-toolchain-file${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}}
|
||||
id: toolchain
|
||||
with:
|
||||
toolchain: ${{matrix.rust}}
|
||||
|
|
78
README.md
78
README.md
|
@ -1,12 +1,19 @@
|
|||
# Install Rust Toolchain
|
||||
# Install Rust Toolchain via rust-toolchain.toml
|
||||
|
||||
This GitHub Action installs a Rust toolchain using rustup. It is designed for
|
||||
one-line concise usage and good defaults.
|
||||
|
||||
<br>
|
||||
Fork of https://github.com/dtolnay/rust-toolchain that supports and makes it mandatory to use a rust-toolchain.toml file.
|
||||
|
||||
## Example workflow
|
||||
|
||||
Create a [`rust-toolchain.toml`](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) file:
|
||||
|
||||
```toml
|
||||
[toolchain]
|
||||
channel = "1.68"
|
||||
components = [ "rustfmt", "clippy" ]
|
||||
```
|
||||
|
||||
Then add an entry to this action in your github actions:
|
||||
|
||||
```yaml
|
||||
name: test suite
|
||||
on: [push, pull_request]
|
||||
|
@ -17,45 +24,15 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: dsherret/rust-toolchain-file@1
|
||||
- run: cargo test --all-features
|
||||
```
|
||||
|
||||
The selection of Rust toolchain is made based on the particular @rev of this
|
||||
Action being requested. For example "dtolnay/rust-toolchain@nightly" pulls in
|
||||
the nightly Rust toolchain, while "dtolnay/rust-toolchain@1.42.0" pulls in
|
||||
1.42.0.
|
||||
|
||||
<br>
|
||||
The selection of Rust toolchain is made based on the rust-toolchain.toml file.
|
||||
|
||||
## Inputs
|
||||
|
||||
All inputs are optional.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>toolchain</code></td>
|
||||
<td>
|
||||
Rustup toolchain specifier e.g. <code>stable</code>, <code>nightly</code>, <code>1.42.0</code>, <code>nightly-2022-01-01</code>.
|
||||
<b>Important: the default is to match the @rev as described above.</b>
|
||||
When passing an explicit <code>toolchain</code> as an input instead of @rev, you'll want to use "dtolnay/rust-toolchain@master" as the revision of the action.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>targets</code></td>
|
||||
<td>Comma-separated string of additional targets to install e.g. <code>wasm32-unknown-unknown</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>components</code></td>
|
||||
<td>Comma-separated string of additional components to install e.g. <code>clippy, rustfmt</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
None. You must define everything in the rust-toolchain.toml file.
|
||||
|
||||
## Outputs
|
||||
|
||||
|
@ -74,31 +51,6 @@ All inputs are optional.
|
|||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
## Toolchain expressions
|
||||
|
||||
The following forms are available for projects that use a sliding window of
|
||||
compiler support.
|
||||
|
||||
```yaml
|
||||
# Installs the most recent stable toolchain as of the specified time
|
||||
# offset, which may be written in years, months, weeks, or days.
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable 18 months ago
|
||||
```
|
||||
|
||||
```yaml
|
||||
# Installs the stable toolchain which preceded the most recent one by
|
||||
# the specified number of minor versions.
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable minus 8 releases
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT
|
||||
|
|
56
action.yml
56
action.yml
|
@ -1,24 +1,10 @@
|
|||
name: rustup toolchain install
|
||||
author: David Tolnay
|
||||
description: Install the Rust toolchain
|
||||
name: rust-toolchain.toml setup
|
||||
author: David Tolnay, David Sherret
|
||||
description: Install the Rust toolchain via a rust-toolchain.toml file
|
||||
branding:
|
||||
icon: activity
|
||||
color: purple
|
||||
|
||||
inputs:
|
||||
toolchain:
|
||||
description: Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification
|
||||
required: true
|
||||
targets:
|
||||
description: Comma-separated list of target triples to install for this toolchain
|
||||
required: false
|
||||
target:
|
||||
description: Alias for `targets`
|
||||
required: false
|
||||
components:
|
||||
description: Comma-separated list of components to be additionally installed
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
cachekey:
|
||||
description: A short hash of the rustc version, appropriate for use as a cache key. "20220627a831"
|
||||
|
@ -30,22 +16,17 @@ outputs:
|
|||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: parse
|
||||
- id: ensure-toolchain-file
|
||||
run: |
|
||||
: parse toolchain version
|
||||
if [[ $toolchain =~ ^stable' '[0-9]+' '(year|month|week|day)s?' 'ago$ ]]; then
|
||||
if [[ ${{runner.os}} == macOS ]]; then
|
||||
echo "toolchain=1.$((($(date -v-$(sed 's/stable \([0-9]*\) \(.\).*/\1\2/' <<< $toolchain) +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "toolchain=1.$((($(date --date "${toolchain#stable }" +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
elif [[ $toolchain =~ ^stable' 'minus' '[0-9]+' 'releases?$ ]]; then
|
||||
echo "toolchain=1.$((($(date +%s)/60/60/24-16569)/7/6-${toolchain//[^0-9]/}))" >> $GITHUB_OUTPUT
|
||||
if [[ -f "rust-toolchain" || -f "rust-toolchain.toml" ]]
|
||||
then
|
||||
echo "found toolchain"
|
||||
else
|
||||
echo "toolchain=$toolchain" >> $GITHUB_OUTPUT
|
||||
echo "No rust-toolchain or rust-toolchain.toml file found in repo."
|
||||
echo "Please ensure the repo is checked out first or add this file."
|
||||
echo "If you don't want this file, then please use https://github.com/dtolnay/rust-toolchain"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
toolchain: ${{inputs.toolchain}}
|
||||
shell: bash
|
||||
|
||||
- id: flags
|
||||
|
@ -68,18 +49,15 @@ runs:
|
|||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
|
||||
- name: rustup toolchain install ${{steps.parse.outputs.toolchain}}
|
||||
run: rustup toolchain install ${{steps.parse.outputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
|
||||
shell: bash
|
||||
|
||||
- run: rustup default ${{steps.parse.outputs.toolchain}}
|
||||
- name: rustup toolchain install
|
||||
run: rustup toolchain install --no-self-update
|
||||
shell: bash
|
||||
|
||||
- id: rustc-version
|
||||
run: |
|
||||
: create cachekey
|
||||
DATE=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
|
||||
HASH=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
|
||||
DATE=$(rustc --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
|
||||
HASH=$(rustc --version --verbose | sed -ne 's/^commit-hash: //p')
|
||||
echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
|
||||
|
@ -102,7 +80,7 @@ runs:
|
|||
# except on 1.66 and 1.67, on which it is unstable
|
||||
if [ -z "${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set}" -o -f "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol ]; then
|
||||
touch "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol || true
|
||||
if rustc +${{steps.parse.outputs.toolchain}} --version --verbose | (! grep -q '^release: 1\.6[67]\.'); then
|
||||
if rustc --version --verbose | (! grep -q '^release: 1\.6[67]\.'); then
|
||||
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
|
||||
else
|
||||
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git >> $GITHUB_ENV
|
||||
|
@ -110,5 +88,5 @@ runs:
|
|||
fi
|
||||
shell: bash
|
||||
|
||||
- run: rustc +${{steps.parse.outputs.toolchain}} --version --verbose
|
||||
- run: rustc --version --verbose
|
||||
shell: bash
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
if ! git diff-index --quiet HEAD; then
|
||||
echo "Not running update-revs.sh because git working directory is dirty" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
patch_releases=(
|
||||
1.12.1 1.15.1 1.22.1 1.24.1 1.26.1 1.26.2 1.27.1 1.27.2 1.29.1 1.29.2 1.30.1
|
||||
1.31.1 1.34.1 1.34.2 1.41.1 1.43.1 1.44.1 1.45.1 1.45.2 1.52.1 1.56.1 1.58.1
|
||||
1.62.1 1.66.1 1.67.1
|
||||
)
|
||||
|
||||
releases() {
|
||||
printf "%s\n" 1.{0..70}.0 ${patch_releases[@]} | sort -V
|
||||
}
|
||||
|
||||
base=$(git rev-parse HEAD)
|
||||
push=()
|
||||
|
||||
declare -A minor
|
||||
for rev in `releases`; do
|
||||
minor[${rev%.*}]=$rev
|
||||
done
|
||||
|
||||
for rev in `releases` stable beta nightly; do
|
||||
echo "Updating $rev branch"
|
||||
git checkout --quiet "$base"
|
||||
git branch --quiet --delete --force $rev &>/dev/null || true
|
||||
sed -i "s/required: true/required: false\n default: $rev/" action.yml
|
||||
git add action.yml
|
||||
git commit --quiet --message "toolchain: $rev"
|
||||
git checkout --quiet -b $rev
|
||||
push+=("$rev:refs/heads/$rev")
|
||||
if [ "${minor[${rev%.*}]}" == $rev ]; then
|
||||
push+=("$rev:refs/heads/${rev%.*}")
|
||||
fi
|
||||
done
|
||||
|
||||
for tool in clippy miri; do
|
||||
echo "Updating $tool branch"
|
||||
git checkout --quiet --detach nightly
|
||||
git branch --quiet --delete --force $tool &>/dev/null || true
|
||||
if [ $tool == miri ]; then
|
||||
default="miri, rust-src"
|
||||
echo -e " - uses: dtolnay/install@xargo\n with:\n bin: xargo-check" >> action.yml
|
||||
else
|
||||
default=$tool
|
||||
fi
|
||||
sed -i "/required: false/{N;s/\n$/\n default: $default\n/}" action.yml
|
||||
git add action.yml
|
||||
git commit --quiet --message "components: $tool"
|
||||
git checkout --quiet -b $tool
|
||||
push+=("$tool:refs/heads/$tool")
|
||||
done
|
||||
|
||||
git checkout --quiet "$base"
|
||||
|
||||
echo "git push origin --force-with-lease ${push[@]}"
|
Loading…
Add table
Add a link
Reference in a new issue