Repository navigation
59 lines (50 loc) · 2.23 KB
/
Copy pathlf-pre-commit.yml
File metadata and controls
59 lines (50 loc) · 2.23 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
name: 'Linuxfabrik: Pre-commit'
on:
push:
branches:
- 'main'
pull_request: {}
permissions:
contents: 'read'
# A newer push to the same pull request makes the running hooks obsolete.
# Pushes to main are left to finish.
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: "${{ github.event_name == 'pull_request' }}"
jobs:
pre-commit:
name: 'Pre-commit'
runs-on: 'ubuntu-latest'
steps:
- name: 'Harden the runner (Audit all outbound calls)'
uses: 'step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a' # v2.22.4
with:
egress-policy: 'audit'
- name: 'Checkout repository'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # v7.0.1
# This runs pre-commit itself, not the collection. The pinned stack in
# .github/pre-commit/requirements.txt needs 3.10 or newer, so it cannot
# be the py39 floor the controller plugins support. That floor is
# covered by the matrix in lf-unit-tests.yml instead.
- name: 'Set up Python'
uses: 'actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0' # v7.1.0
with:
python-version: '3.13'
# Building the hook environments takes most of the run, gitleaks alone
# half a minute. They only change with the config or the interpreter.
- name: 'Cache the hook environments'
uses: 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9' # v6.1.0
with:
path: '~/.cache/pre-commit'
key: "pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}"
- name: 'Install pre-commit'
run: 'pip install --require-hashes --requirement .github/pre-commit/requirements.txt'
# --all-files, because the hooks otherwise only see what a commit
# happens to touch, and nothing guarantees a contributor ran
# `pre-commit install` at all. pytest-unit is skipped, since
# lf-unit-tests.yml runs the same tests across the full Python and
# ansible-core matrix whenever they are affected.
- name: 'Run the hooks over the whole tree'
env:
SKIP: 'pytest-unit'
run: 'pre-commit run --all-files --show-diff-on-failure'