-
Notifications
You must be signed in to change notification settings - Fork 19
46 lines (41 loc) · 1.84 KB
/
Copy pathpre-commit.yml
File metadata and controls
46 lines (41 loc) · 1.84 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
# A basic workflow to run pre-commit on code changes.
# https://pre-commit.com and https://github.com/pre-commit/action
name: pre-commit
on:
push:
branches: [ "main", "py3.[0-9]+" ]
pull_request:
branches: [ "main", "py3.[0-9]+" ]
concurrency:
# One group per PR and one per tracked branch, so a newer commit cancels the
# predecessor's run on `main` as well as inside a PR.
group: pre-commit-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
with:
# The citation check below needs the merge ref's first parent.
fetch-depth: 2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: 3.x
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
# The `no-line-number-citations` hook above reads the staged diff, which is
# empty under the action's `--all-files`, so it cannot see what a pull
# request adds. A `pull_request` event checks out `refs/pull/N/merge`, whose
# first parent is the base branch tip, so `HEAD^1..HEAD` is this PR's own
# contribution and nothing else -- which is what keeps the numbers already
# in the tree out of scope.
#
# `--annotate` marks each one on the diff and exits 0. The commit hook is
# the blocking side; this side exists for branches that predate the hook and
# for commits made with `--no-verify`, where failing the job would wall work
# already in flight rather than stop a line being written.
- name: upstream citations name a symbol, not a line number
if: github.event_name == 'pull_request'
run: python3 scripts/check-new-line-citations.py --base HEAD^1 --annotate