Skip to content

Commit 9f5469c

Browse files
committed
fix(ci): Install hadolint in pre-commit workflow
1 parent 9b4e796 commit 9f5469c

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

.github/workflows/pr_pre-commit.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
env:
88
CARGO_TERM_COLOR: always
99
RUST_TOOLCHAIN_VERSION: "1.80.1"
10+
HADOLINT_VERSION: "v1.17.6"
1011

1112
jobs:
1213
pre-commit:
@@ -22,6 +23,22 @@ jobs:
2223
with:
2324
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
2425
components: rustfmt,clippy
26+
- name: Setup Hadolint
27+
shell: bash
28+
run: |
29+
set -euo pipefail
30+
31+
LOCATION_DIR="$HOME/.local/bin"
32+
LOCATION_BIN="$LOCATION_DIR/hadolint"
33+
34+
SYSTEM=$(uname -s)
35+
ARCH=$(uname -m)
36+
37+
mkdir -p "$LOCATION_DIR"
38+
curl -sL -o "${LOCATION_BIN}" "https://github.com/hadolint/hadolint/releases/download/${{ env.HADOLINT_VERSION }}/hadolint-$SYSTEM-$ARCH"
39+
chmod 700 "${LOCATION_BIN}"
40+
41+
echo "$LOCATION_DIR" >> "$GITHUB_PATH"
2542
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
2643
with:
2744
extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}"

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
fail_fast: false
33

4+
default_language_version:
5+
node: system
6+
47
repos:
58
- repo: https://github.com/pre-commit/pre-commit-hooks
69
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # 4.6.0

config/rust.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# If you change the Rust toolchain version here, make sure to also change
44
# docker-images/ubi8-rust-builder/Dockerfile & docker-images/ubi9-rust-builder/Dockerfile
55
rust_version: 1.80.0
6+
hadolint_version: v1.17.6

template/.github/workflows/pr_pre-commit.yaml.j2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
env:
88
CARGO_TERM_COLOR: always
99
RUST_TOOLCHAIN_VERSION: "{[ rust_version }]"
10+
HADOLINT_VERSION: "{[ hadolint_version }]"
1011

1112
jobs:
1213
pre-commit:
@@ -22,6 +23,22 @@ jobs:
2223
with:
2324
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
2425
components: rustfmt,clippy
26+
- name: Setup Hadolint
27+
shell: bash
28+
run: |
29+
set -euo pipefail
30+
31+
LOCATION_DIR="$HOME/.local/bin"
32+
LOCATION_BIN="$LOCATION_DIR/hadolint"
33+
34+
SYSTEM=$(uname -s)
35+
ARCH=$(uname -m)
36+
37+
mkdir -p "$LOCATION_DIR"
38+
curl -sL -o "${LOCATION_BIN}" "https://github.com/hadolint/hadolint/releases/download/${{ env.HADOLINT_VERSION }}/hadolint-$SYSTEM-$ARCH"
39+
chmod 700 "${LOCATION_BIN}"
40+
41+
echo "$LOCATION_DIR" >> "$GITHUB_PATH"
2542
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
2643
with:
2744
extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}"

template/.pre-commit-config.yaml.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
exclude: ^(Cargo\.nix|crate-hashes\.json|nix/.*)$
33

4+
default_language_version:
5+
node: system
6+
47
repos:
58
- repo: https://github.com/pre-commit/pre-commit-hooks
69
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # 4.6.0

0 commit comments

Comments
 (0)