This repository was archived by the owner on Aug 29, 2026. It is now read-only.
Repository navigation
63 lines (55 loc) · 2.27 KB
/
Copy pathpre-commit.yml
File metadata and controls
63 lines (55 loc) · 2.27 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
name: pre-commit
# The local hooks can be skipped -- a fresh clone that never ran ./install.sh
# has no hooks at all -- so the gate needs a second home that nobody can
# forget to install.
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
# scripts/check_md_naming.sh is a thin shim that execs the shared gate
# out of the utils repo. A runner has no ~/utils, so without this the
# hook fails with "shared gate not found".
UTILS_ROOT: ${{ github.workspace }}/.utils
steps:
# fetch-depth 1: the history here is ~494 MB and no gate reads it.
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Check out the shared gates
uses: actions/checkout@v4
with:
repository: kuhyx/utils
path: .utils
- uses: actions/setup-python@v5
with:
python-version: "3.x"
# Pinned, not apt-installed. `language: system` hooks run whatever is on
# PATH, so an unpinned shellcheck makes CI disagree with every developer
# machine: Ubuntu's package flagged SC2236 in a file that 0.11.0 locally
# does not, and the build went red for a difference in tool version
# rather than in the code.
- name: Install shellcheck (pinned)
env:
SHELLCHECK_VERSION: v0.11.0
SHELLCHECK_SHA256: 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
run: |
set -euo pipefail
url="https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
curl -fsSL "$url" -o /tmp/sc.tar.xz
echo "${SHELLCHECK_SHA256} /tmp/sc.tar.xz" | sha256sum -c -
tar -xJf /tmp/sc.tar.xz -C /tmp
sudo install -m 0755 "/tmp/shellcheck-${SHELLCHECK_VERSION}/shellcheck" /usr/local/bin/shellcheck
shellcheck --version
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
run: python -m pip install --quiet pre-commit
- name: Run the hooks
run: pre-commit run --all-files --show-diff-on-failure