Skip to content

Commit a0827d6

Browse files
authored
Create action.yml
1 parent 1c4a63e commit a0827d6

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

action.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Setup Rust Toolchain for GitHub CI
2+
description: |
3+
Setup specific Rust versions and integrate nicely into the ecosystem.
4+
The action enabled caching of Rust tools and build artifacts and sets environment variables for faster and more efficient caching.
5+
It also sets up problem matchers showing compilation and formatting issues.
6+
7+
branding:
8+
icon: "play"
9+
color: "gray-dark"
10+
11+
# Add option to install directly from rust-toolchain file
12+
# Blocked on rustup support: https://github.com/rust-lang/rustup/issues/2686
13+
#
14+
# The action is heavily inspired by https://github.com/dtolnay/rust-toolchain
15+
inputs:
16+
toolchain:
17+
description: "Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification"
18+
required: false
19+
default: "stable"
20+
target:
21+
description: "Target triple to install for this toolchain"
22+
required: false
23+
components:
24+
description: "Comma-separated list of components to be additionally installed"
25+
required: false
26+
27+
outputs:
28+
rustc-version:
29+
description: "Version as reported by `rustc --version`"
30+
value: ${{steps.versions.outputs.rustc-version}}
31+
cargo-version:
32+
description: "Version as reported by `cargo --version`"
33+
value: ${{steps.versions.outputs.cargo-version}}
34+
rustup-version:
35+
description: "Version as reported by `rustup --version`"
36+
value: ${{steps.versions.outputs.rustup-version}}
37+
38+
runs:
39+
using: composite
40+
steps:
41+
- id: flags
42+
run: |
43+
: construct rustup command line
44+
echo "::set-output name=targets::$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)"
45+
echo "::set-output name=components::$(for c in ${components//,/ }; do echo -n ' --component' $c; done)"
46+
echo "::set-output name=downgrade::${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}"
47+
env:
48+
targets: ${{inputs.target}}
49+
components: ${{inputs.components}}
50+
shell: bash
51+
- name: rustup toolchain install ${{inputs.toolchain}}
52+
run: |
53+
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
54+
rustup default ${{inputs.toolchain}}
55+
shell: bash
56+
- name: Print installed versions
57+
id: versions
58+
run: |
59+
echo "::set-output name=rustc-version::$(rustc --version)"
60+
rustc --version
61+
echo "::set-output name=cargo-version::$(cargo --version)"
62+
cargo --version
63+
echo "::set-output name=rustup-version::$(rustup --version)"
64+
rustup --version
65+
shell: bash
66+
67+
- name: "Setup Rust Caching"
68+
uses: Swatinem/rust-cache@v1
69+
- name: "Install Rust Problem Matcher"
70+
run: echo "::add-matcher::${{ github.action_path }}/rust.json"
71+
shell: bash
72+
- name: "Setting Environment Variables"
73+
run: |
74+
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
75+
echo "CARGO_PROFILE_DEV_DEBUG=0" >> $GITHUB_ENV
76+
echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
77+
shell: bash

0 commit comments

Comments
 (0)