Skip to content

Commit 82d1f2b

Browse files
Support multiple Rust toolchain files (#20)
* Support multiple Rust toolchain files Accept one or two toolchain directories and install the versions, components, and targets declared by their native rustup files. Document the breaking v2 interface and explicit default selection. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> * Simplify multiple toolchain setup Use setup-rust-toolchain's source directory support for the optional additional toolchain and update the documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> --------- Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 2f4142b commit 82d1f2b

2 files changed

Lines changed: 44 additions & 52 deletions

File tree

‎README.md‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,48 @@ jobs:
99
setup:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v7
1313

14-
- uses: hyperlight-dev/ci-setup-workflow@v1.0.0
15-
with:
16-
rust-toolchain: "1.74.0"
14+
- uses: hyperlight-dev/ci-setup-workflow@v2.0.0
15+
with:
16+
additional-toolchain-directory: guests
1717
```
1818
19+
Check out the consumer repository before invoking the action.
20+
1921
## Inputs
2022
2123
### Parameters
2224
2325
| Name | Description |
2426
| ---- | ----------- |
25-
| `rust-toolchain` | The rust toolchain version to use. |
27+
| `additional-toolchain-directory` | Optional directory containing another `rust-toolchain.toml` or `rust-toolchain` file. |
28+
| `just-version` | Version of Just to install; defaults to `1.41`. |
29+
30+
The action reads `rust-toolchain.toml` or `rust-toolchain` from the repository
31+
root, falling back to stable when neither file exists. Set
32+
`additional-toolchain-directory` when another directory, such as a guest
33+
project, uses a different toolchain.
34+
35+
Rustup reads the version, profile, components, and targets from each toolchain
36+
file. Put required extras such as `clippy`, `rustfmt`, `x86_64-unknown-none`,
37+
or cross-compilation targets in those files.
2638

2739
## Overview
2840

2941
This action performs the following steps:
3042

31-
- Installs the Rust tool chain at the specified version.
32-
- Installs additional rust components like clippy, rustfmt, ect
33-
- Installs Just
34-
- Sets up the clang toolchain on Linux machines (this should probably get moved into the hosted runner image setup...)
35-
- Installs the `x86_64-pc-windows-msvc` rust target for cross-compilation on Linux machines
43+
- Installs rustup if needed and the root toolchain (or stable by default).
44+
- Installs an additional toolchain when requested.
45+
- Installs the requested components and targets.
46+
- Installs Just.
47+
- Sets up the clang toolchain on Linux.
48+
- Enables the Windows Hypervisor Platform on Windows.
3649
- Sets up environment variables needed to build / run tests based on the machine's configuration.
3750

51+
Runners need Bash 5 and rustup or curl. The setup action installs rustup when
52+
missing and installs Bash through Homebrew on macOS.
53+
3854
## Code of Conduct
3955

4056
See the [Code of Conduct](./CODE_OF_CONDUCT.md).

‎action.yml‎

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ name: "Hyperlight Workflow Setup"
44
description: "Common setup steps for GitHub workflows in the Hyperlight project"
55

66
inputs:
7-
rust-toolchain:
8-
description: "(Default: 1.94.0) Rust toolchain specification to install - see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification"
7+
additional-toolchain-directory:
8+
description: "Optional directory containing another Rust toolchain file."
99
required: false
10-
default: "1.94.0"
1110
just-version:
1211
description: '(Default: 1.41) Version of just to install.'
1312
required: false
@@ -16,12 +15,23 @@ runs:
1615
using: composite
1716
steps:
1817

19-
- uses: dtolnay/rust-toolchain@master
18+
- name: Install Rust toolchain
19+
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
2020
with:
21-
toolchain: ${{ inputs.rust-toolchain }}
22-
components: clippy, rustfmt
23-
24-
- uses: extractions/setup-just@v4
21+
cache: 'false'
22+
matcher: 'false'
23+
build-warnings: ''
24+
25+
- name: Install additional Rust toolchain
26+
if: ${{ inputs.additional-toolchain-directory != '' }}
27+
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
28+
with:
29+
rust-src-dir: ${{ inputs.additional-toolchain-directory }}
30+
cache: 'false'
31+
matcher: 'false'
32+
build-warnings: ''
33+
34+
- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
2535
with:
2636
just-version: ${{ inputs.just-version }}
2737

@@ -87,21 +97,6 @@ runs:
8797
fi
8898
shell: bash
8999

90-
# This is needed to build the rust guests
91-
- name: Install x86_64-unknown-none target
92-
if: ${{ (runner.os == 'Linux') }}
93-
run: |
94-
rustup target add x86_64-unknown-none
95-
shell: bash
96-
97-
# We do this in case there is toolchain skew between repos
98-
- name: Install older rust toolchain(s)
99-
if: ${{ (runner.os == 'Linux') }}
100-
run: |
101-
rustup toolchain install 1.85.0
102-
rustup toolchain install 1.86.0
103-
shell: bash
104-
105100
- name: Set up env vars (Linux)
106101
if: ${{ (runner.os == 'Linux') }}
107102
run: |
@@ -125,25 +120,6 @@ runs:
125120
run: Enable-WindowsOptionalFeature -Online -FeatureName HyperVisorPlatform
126121
shell: pwsh
127122

128-
- name: Install x86_64-pc-windows-msvc target (Windows)
129-
if: ${{ (runner.os == 'Windows') }}
130-
run: |
131-
rustup target add x86_64-pc-windows-msvc
132-
shell: pwsh
133-
134-
- name: Install x86_64-unknown-none target (Windows)
135-
if: ${{ (runner.os == 'Windows') }}
136-
run: |
137-
rustup target add x86_64-unknown-none
138-
shell: pwsh
139-
140-
- name: Install older rust toolchain(s) (Windows)
141-
if: ${{ (runner.os == 'Windows') }}
142-
run: |
143-
rustup toolchain install 1.85.0
144-
rustup toolchain install 1.86.0
145-
shell: pwsh
146-
147123
- name: Set up env vars (Windows)
148124
if: ${{ (runner.os == 'Windows') }}
149125
run: |

0 commit comments

Comments
 (0)