WUT_Computer_Science/.github/workflows/pre-commit.yml
Krzysztof kuhy Rudnicki 0928dfdd13
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (push) Waiting to run
CI: pin shellcheck, and enable Actions on the repo
Two things kept CI from being green, and neither was the code.

First, GitHub Actions was DISABLED at the repository level. The workflows
registered fine and simply never ran -- `gh api .../actions/permissions`
returned {"enabled": false}. Now enabled.

Second, once it ran, shellcheck failed on a file that is clean locally:
SC2236 in PSD/zin3/python/run_temperature_system.sh. `language: system` hooks
use whatever is on PATH, and Ubuntu's packaged shellcheck is not the 0.11.0
this machine has, so the build went red for a difference in tool version
rather than in the code. That is the failure mode testsAndMisc pins tools to
avoid, so the workflow now installs shellcheck v0.11.0 and verifies its
SHA256 -- checked here first: the digest matches and the archive really does
unpack to shellcheck-v0.11.0/shellcheck.

The `! -z` -> `-n` fix is applied too. Pinning stops the next version drift;
fixing the code means this instance is right under either version.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172dj34FDpao6wsix8ZuCzE
2026-08-28 18:31:11 +02:00

64 lines
2.3 KiB
YAML

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