Skip to content

ci: gate on prek, shared between pre-commit and CI#3

Merged
Destynova2 merged 2 commits into
mainfrom
ci/prek-shared-gate
Jul 24, 2026
Merged

ci: gate on prek, shared between pre-commit and CI#3
Destynova2 merged 2 commits into
mainfrom
ci/prek-shared-gate

Conversation

@Destynova2

Copy link
Copy Markdown
Owner

Contexte

Le dépôt n'avait aucun contrôle automatisé — toutes les régressions trouvées jusqu'ici l'ont été à la main.

Chez grob, prek est local-only et la CI a son propre job shellcheck : deux listes de règles qui dérivent l'une de l'autre. Ici la CI ne définit aucune règle : elle installe les outils puis délègue à prek run --all-files, qui lit le même prek.toml que prek install branche en pre-commit. Resserrer un contrôle = une ligne, un fichier, deux endroits couverts.

Hooks

Hygiène (espaces, newline finale, fins de ligne), validité YAML/TOML, marqueurs de conflit, shellcheck, actionlint, gitleaks, et le parsing du script sous sh, bash, dash, zsh, ksh.

Ce dernier porte l'essentiel : le script est sourcé, donc une erreur de syntaxe casse le shell de login de l'utilisateur au lieu de faire échouer une commande — et la compatibilité 5 shells annoncée en tête de fichier n'était jusqu'ici vérifiée par rien.

Choix sur shellcheck

--severity=warning avec deux exclusions documentées :

  • SC3043 (local non POSIX) : ~70 occurrences. Accepté — les cinq shells visés l'implémentent, et s'en passer ferait fuiter chaque variable de helper dans le shell interactif de l'utilisateur. Le vrai garde-fou de portabilité est le hook 5 shells.
  • SC3045 (type -t) : faux positif. Son unique site d'appel est dans une branche elif [ -n "${BASH_VERSION-}" ], donc jamais exécutée hors bash. Vérifié : sous dash la branche n'est simplement pas prise, sans crash.

Chaîne d'approvisionnement

Aucune action tierce. j178/prek-action ferait le job en une ligne, mais :

v2.0.6 tag Git, réassignable à tout moment
code exécuté dist/index.cjs, 2,46 Mo de JS bundlé
points d'entrée main: et post: — du code tourne aussi après le job
dépôt 95 étoiles, ~10 mois, mainteneur unique

Remplacé par le tarball de release amont + vérification du SHA-256 publié : même résultat, surface relisible. actions/checkout est épinglé par SHA de commit (d23441a…) et non par tag, pour la même raison. gitleaks et actionlint sont épinglés par version.

Vérifications

  • prek run --all-files : 10/10 hooks verts en local
  • actionlint sur le workflow : aucun problème
  • SHA-256 de prek recoupé avec le .sha256 publié en amont
  • permissions: contents: read, concurrency avec annulation

Destynova2 and others added 2 commits July 24, 2026 12:47
The repo had no automated checks: every regression found so far was found
by hand. Add prek.toml as the single description of the gate, and a
workflow that installs the tools and defers to `prek run --all-files`.
CI owns no rules of its own, so the local hook and the pipeline cannot
drift; tightening a check is one line in one file.

Hooks: whitespace and line-ending hygiene, YAML/TOML validity, merge
markers, shellcheck, actionlint, gitleaks, and a parse of the script
under sh, bash, dash, zsh and ksh. That last one carries the weight: the
script is sourced, so a syntax error breaks the user's login shell rather
than failing a command, and the five-shell claim in the file header was
until now unverified.

shellcheck runs at --severity=warning with two exclusions. SC3043
(`local` is not POSIX) fires on nearly every helper and is accepted:
every shell the project targets implements it, and removing it would leak
helper variables into the user's interactive shell. SC3045 (`type -t`) is
a false positive — its only call site is inside an
`elif [ -n "${BASH_VERSION-}" ]` branch.

No third-party action is used. j178/prek-action does this in one line but
executes 2.4 MB of bundled JavaScript from both a `main:` and a `post:`
entry point, behind a mutable tag; the release tarball plus its published
SHA-256 gives the same result with a reviewable surface. actions/checkout
is pinned by commit SHA for the same reason.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The install step assumed prek ships its binary at the archive root, as
gitleaks and actionlint do. It nests it under
prek-x86_64-unknown-linux-musl/, so tar exited 2 with "prek: Not found in
archive" after the checksum had already verified. Name the member and
strip the leading component.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Destynova2
Destynova2 merged commit 12ed5b7 into main Jul 24, 2026
1 check passed
@Destynova2
Destynova2 deleted the ci/prek-shared-gate branch July 24, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant