Skip to content

Commit c1c5ae6

Browse files
bjoernricksgreenbonebot
authored andcommitted
Add: Add an action to setup a rust environment
1 parent 21eb05a commit c1c5ae6

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

setup-rust/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Setup Rust Action
2+
3+
Action to setup a rust environment.
4+
5+
## Example
6+
7+
```yml
8+
9+
name: Build with rust
10+
11+
on:
12+
push:
13+
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Setup Rust
20+
uses: greenbone/actions/setup-rust@v3
21+
- name: Build
22+
run: |
23+
cargo build
24+
```
25+
26+
## Action Configuration
27+
28+
| Input | Description | |
29+
| ------------ | ------------------------------------------------- | ------------------------------ |
30+
| rust-version | The rust version to setup, for example `nightly`. | Optional (default is `stable`) |

setup-rust/action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Setup Rust Environment"
2+
3+
description: "A GitHub Action to set up a Rust environment."
4+
5+
inputs:
6+
rust-version:
7+
description: "The Rust version to install (default: stable)"
8+
required: false
9+
default: "stable"
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
15+
with:
16+
path: |
17+
~/.cargo/bin/
18+
~/.cargo/registry/index/
19+
~/.cargo/registry/cache/
20+
~/.cargo/git/db/
21+
target/
22+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
23+
- name: Set up Rust
24+
run: rustup update ${{ inputs.rust-version }} && rustup default ${{ inputs.rust-version }} || rustup default ${{ inputs.rust-version }}
25+
shell: bash
26+
- name: Ensure linting and formatting tools are installed
27+
run: rustup component add rustfmt clippy
28+
shell: bash

0 commit comments

Comments
 (0)