-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
92 lines (81 loc) · 3.08 KB
/
action.yml
File metadata and controls
92 lines (81 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
name: Run pre-commit
description: |
This action sets up Python, the pre-commit tool, and additional tools
required for various hooks. It then runs pre-commit against the changed files.
This actions expects checkouts with depth 0.
inputs:
python-version:
description: Python version to install
default: "3.12"
rust:
description: Whether to install the Rust toolchain (and which version to use)
rust-components:
description: |
Override which Rust components are installed. Only takes effect when Rust
is installed.
default: rustfmt,clippy
rust-tools:
description: |
Install Rust-based tools using `cargo install --locked`. Tools can be
specified using the following format: `CRATE[@<VER>]`. Individual tools
are separated by space
hadolint:
description: Whether to install hadolint (and which version to use)
nix:
description: Whether to install nix (and which version to use)
nix-github-token:
description: |
The GitHub token is used by Nix to pull from GitHub with higher rate-limits. Required when
the 'nix' input is used.
runs:
using: composite
steps:
- name: Setup Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ inputs.python-version }}
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@c5a29ddb4d9d194e7c84ec8c3fba61b1c31fee8c
if: ${{ inputs.rust }}
with:
toolchain: ${{ inputs.rust }}
components: ${{ inputs.rust-components }}
- name: Install Rust Tools
if: ${{ inputs.rust-tools }}
env:
RUST_TOOLS: ${{ inputs.rust-tools }}
shell: bash
run: |
set -euo pipefail
# Make a list out of the space separated list off tools/crates
RUST_TOOLS=($RUST_TOOLS)
cargo install --locked "${RUST_TOOLS[@]}"
- name: Setup Hadolint
if: ${{ inputs.hadolint }}
shell: bash
run: |
set -euo pipefail
LOCATION_DIR="$HOME/.local/bin"
LOCATION_BIN="$LOCATION_DIR/hadolint"
SYSTEM=$(uname -s)
ARCH=$(uname -m)
mkdir -p "$LOCATION_DIR"
curl -sL -o "${LOCATION_BIN}" "https://github.com/hadolint/hadolint/releases/download/${{ inputs.hadolint }}/hadolint-$SYSTEM-$ARCH"
chmod 700 "${LOCATION_BIN}"
echo "$LOCATION_DIR" | tee -a "$GITHUB_PATH"
- name: Abort if nix-github-token input is not set
if: inputs.nix && !inputs.nix-github-token
shell: bash
run: |
echo "nix-github-token input must be set when nix input is set"
exit 1
- name: Setup nix
if: inputs.nix
uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 #v30
with:
github_access_token: ${{ inputs.nix-github-token }}
install_url: https://releases.nixos.org/nix/nix-${{ inputs.nix }}/install
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: "--from-ref '${{ github.event.pull_request.base.sha }}' --to-ref '${{ github.event.pull_request.head.sha }}'"