0
0
Fork 0
mirror of https://github.com/dtolnay/rust-toolchain.git synced 2025-06-05 00:53:34 +03:00

Add rust-toolchain.toml awareness

This commit is contained in:
Murph Murphy 2023-01-31 14:10:59 -07:00
parent c758e63728
commit 5ab0241b57
4 changed files with 69 additions and 55 deletions

View file

@ -1,44 +0,0 @@
name: CI
on:
push:
branches: [master]
pull_request:
schedule: [cron: "40 1 * * *"]
permissions:
contents: read
jobs:
install:
name: Rust ${{matrix.rust}} on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}}
runs-on: ${{matrix.os}}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
rust: [nightly, beta, stable, 1.62.0, stable 18 months ago, stable minus 8 releases]
include:
- os: ubuntu
rust: 1.0.0
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- uses: ./
name: Run dtolnay/rust-toolchain${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}}
id: toolchain
with:
toolchain: ${{matrix.rust}}
- name: echo ${{'${{steps.toolchain.outputs.cachekey}}'}}
run: echo '${{steps.toolchain.outputs.cachekey}}'
- name: check ${{'${{steps.toolchain.outputs.cachekey}}'}}
if: matrix.rust == '1.62.0'
run: cmp -s <(echo ${{steps.toolchain.outputs.cachekey}}) <(echo 20220627a831)
shell: bash
- run: rustc --version
- run: cargo init . --bin --name CI
if: matrix.rust == 'nightly' || matrix.rust == 'beta' || matrix.rust == 'stable'
- run: cargo add syn@1
if: matrix.rust == 'nightly' || matrix.rust == 'beta' || matrix.rust == 'stable'
- run: cargo check
if: matrix.rust == 'nightly' || matrix.rust == 'beta' || matrix.rust == 'stable'

12
.github/workflows/sync.yml vendored Normal file
View file

@ -0,0 +1,12 @@
name: Rebase Upstream
on:
schedule:
- cron: "0 0 * * 0" # run once a week
workflow_dispatch: # run manually
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: imba-tjd/rebase-upstream-action@master

View file

@ -17,16 +17,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable - uses: IronCoreLabs/rust-toolchain@stable
- run: cargo test --all-features - run: cargo test --all-features
``` ```
The selection of Rust toolchain is made based on the particular @rev of this 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 Action being requested. For example "IronCoreLabs/rust-toolchain@nightly" pulls in
the nightly Rust toolchain, while "dtolnay/rust-toolchain@1.42.0" pulls in the nightly Rust toolchain, while "IronCoreLabs/rust-toolchain@1.42.0" pulls in
1.42.0. 1.42.0.
<br> ## Toolchain File
The [Rust toolchain file](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) is supported.
If present it will be used to populate `toolchain`, `components` and `targets` parameters. If those parameters are explicitly set as inputs to the action, they will take precedence over the values in the toolchain file. To use only the toolchain file for parameters, pass no inputs and set the @rev to @master.
## Inputs ## Inputs
@ -42,7 +45,7 @@ All inputs are optional.
<td> <td>
Rustup toolchain specifier e.g. <code>stable</code>, <code>nightly</code>, <code>1.42.0</code>, <code>nightly-2022-01-01</code>. 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> <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. When passing an explicit <code>toolchain</code> as an input instead of @rev, you'll want to use "IronCoreLabs/rust-toolchain@master" as the revision of the action.
</td> </td>
</tr> </tr>
<tr> <tr>
@ -57,6 +60,27 @@ All inputs are optional.
<br> <br>
## Outputs
<table>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr>
<td><code>toolchain</code></td>
<td>
The parsed toolchain that was installed by this action.
</td>
</tr>
<tr>
<td><code>cachekey</code></td>
<td>A short hash of the rustc version, appropriate for use as a cache key. ex "20220627a831"</td>
</tr>
</table>
<br>
## Toolchain expressions ## Toolchain expressions
The following forms are available for projects that use a sliding window of The following forms are available for projects that use a sliding window of
@ -65,7 +89,7 @@ compiler support.
```yaml ```yaml
# Installs the most recent stable toolchain as of the specified time # Installs the most recent stable toolchain as of the specified time
# offset, which may be written in years, months, weeks, or days. # offset, which may be written in years, months, weeks, or days.
- uses: dtolnay/rust-toolchain@master - uses: IronCoreLabs/rust-toolchain@master
with: with:
toolchain: stable 18 months ago toolchain: stable 18 months ago
``` ```
@ -73,7 +97,7 @@ compiler support.
```yaml ```yaml
# Installs the stable toolchain which preceded the most recent one by # Installs the stable toolchain which preceded the most recent one by
# the specified number of minor versions. # the specified number of minor versions.
- uses: dtolnay/rust-toolchain@master - uses: IronCoreLabs/rust-toolchain@master
with: with:
toolchain: stable minus 8 releases toolchain: stable minus 8 releases
``` ```

View file

@ -8,7 +8,7 @@ branding:
inputs: inputs:
toolchain: toolchain:
description: Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification description: Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification
required: true required: false
targets: targets:
description: Comma-separated list of target triples to install for this toolchain description: Comma-separated list of target triples to install for this toolchain
required: false required: false
@ -30,6 +30,28 @@ outputs:
runs: runs:
using: composite using: composite
steps: steps:
- id: extract-toml-values
run: |
# once https://github.com/mikefarah/yq/pull/1439 is merged, the yq already on the system will have toml support
pip3 install yq
TOML_FILE=$(ls rust-toolchain.toml || ls rust-toolchain)
if [ -z "$TOML_FILE" ]; then
echo "rust-toolchain{.toml} not found, expecting explicit inputs"
exit 0
fi
TOML_TOOLCHAIN=$(tomlq -r '.toolchain.channel | select(. != null)' $TOML_FILE)
if [ -n "$TOML_TOOLCHAIN" ]; then
echo "toml-toolchain=$TOML_TOOLCHAIN" >> $GITHUB_OUTPUT
fi
TOML_TARGETS=$(tomlq -r '.toolchain.targets | select(. != null) | @csv' $TOML_FILE)
if [ -n "$TOML_TARGETS" ]; then
echo "toml-targets=$TOML_TARGETS" >> $GITHUB_OUTPUT
fi
TOML_COMPONENTS=$(tomlq -r '.toolchain.components | select(. != null) | @csv' $TOML_FILE)
if [ -n "$TOML_COMPONENTS" ]; then
echo "toml-components=$TOML_COMPONENTS" >> $GITHUB_OUTPUT
fi
shell: bash
- id: parse - id: parse
run: | run: |
: parse toolchain version : parse toolchain version
@ -45,7 +67,7 @@ runs:
echo "toolchain=$toolchain" >> $GITHUB_OUTPUT echo "toolchain=$toolchain" >> $GITHUB_OUTPUT
fi fi
env: env:
toolchain: ${{inputs.toolchain}} toolchain: ${{inputs.toolchain || steps.extract-toml-values.outputs.toml-toolchain || 'stable'}}
shell: bash shell: bash
- id: flags - id: flags
@ -55,8 +77,8 @@ runs:
echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT
echo "downgrade=${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT echo "downgrade=${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT
env: env:
targets: ${{inputs.targets || inputs.target || ''}} targets: ${{inputs.targets || inputs.target || steps.extract-toml-values.outputs.toml-targets || ''}}
components: ${{inputs.components}} components: ${{inputs.components || steps.extract-toml-values.outputs.toml-components }}
shell: bash shell: bash
- run: | - run: |