Skip to content

Commit c44ccda

Browse files
authored
ci: Add pre-commit workflow (#49)
1 parent 2ece871 commit c44ccda

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
pull_request:
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
RUST_TOOLCHAIN_VERSION: "1.80.1"
10+
HADOLINT_VERSION: "v1.17.6"
11+
12+
jobs:
13+
pre-commit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
17+
with:
18+
fetch-depth: 0
19+
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
20+
with:
21+
python-version: '3.12'
22+
- uses: dtolnay/rust-toolchain@master
23+
with:
24+
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
25+
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"
42+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
43+
with:
44+
extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}"

.markdownlint.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# All defaults or options can be checked here:
3+
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
4+
5+
# Default state for all rules
6+
default: true
7+
8+
# MD013/line-length - Line length
9+
MD013:
10+
# Number of characters
11+
line_length: 9999
12+
# Number of characters for headings
13+
heading_line_length: 9999
14+
# Number of characters for code blocks
15+
code_block_line_length: 9999
16+
17+
# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content
18+
MD024:
19+
# Only check sibling headings
20+
siblings_only: true

.pre-commit-config.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
default_language_version:
3+
node: system
4+
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # 4.6.0
8+
hooks:
9+
- id: trailing-whitespace
10+
- id: end-of-file-fixer
11+
- id: detect-aws-credentials
12+
args: ["--allow-missing-credentials"]
13+
- id: detect-private-key
14+
15+
- repo: https://github.com/doublify/pre-commit-rust
16+
rev: eeee35a89e69d5772bdee97db1a6a898467b686e # 1.0
17+
hooks:
18+
- id: fmt
19+
args: ["--all", "--", "--check"]
20+
- id: clippy
21+
args: ["--all-targets", "--", "-D", "warnings"]
22+
- repo: https://github.com/adrienverge/yamllint
23+
rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # 1.35.1
24+
hooks:
25+
- id: yamllint
26+
27+
- repo: https://github.com/igorshubovych/markdownlint-cli
28+
rev: f295829140d25717bc79368d3f966fc1f67a824f # 0.41.0
29+
hooks:
30+
- id: markdownlint
31+
32+
- repo: https://github.com/koalaman/shellcheck-precommit
33+
rev: 2491238703a5d3415bb2b7ff11388bf775372f29 # 0.10.0
34+
hooks:
35+
- id: shellcheck
36+
args: ["--severity=info"]
37+
38+
- repo: https://github.com/rhysd/actionlint
39+
rev: 62dc61a45fc95efe8c800af7a557ab0b9165d63b # 1.7.1
40+
hooks:
41+
- id: actionlint
42+
43+
- repo: https://github.com/hadolint/hadolint
44+
rev: b3555ba9c2bfd9401e79f2f0da68dd1ae38e10c7 # 2.12.0
45+
hooks:
46+
- id: hadolint

.yamllint.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length: disable
6+
truthy:
7+
check-keys: false
8+
comments:
9+
min-spaces-from-content: 1 # Needed due to https://github.com/adrienverge/yamllint/issues/443

0 commit comments

Comments
 (0)