-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (83 loc) · 3.18 KB
/
pre-commit.yml
File metadata and controls
86 lines (83 loc) · 3.18 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Run pre-commit
on:
workflow_call:
inputs:
commands:
required: false
type: string
default: ""
description: run additional commands for preparing the environment
jobs:
run-pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
id: python-setup
with:
python-version: "3.x"
- name: Run commands
if: inputs.commands
run: ${INPUTS_COMMANDS}
env:
INPUTS_COMMANDS: ${{ inputs.commands }}
- name: Cache pre-commit environments
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: "~/.cache/pre-commit"
key: pre-commit-${{ steps.python-setup.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
- run: pipx run pre-commit run --show-diff-on-failure --color=always --all-files
check-pr-title:
name: Check PR title
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
# The calling workflow must grant these permissions.
permissions:
contents: read
steps:
- name: Checkout ${{ github.repository }} repo
# needed for cspell.config.yml (project-specific)
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
repository: ${{ github.repository }}
ref: ${{ github.sha }}
path: project-repo
- name: Checkout cpp-linter/.github (org) repo
# needed for committed.toml config (org-specific)
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
repository: cpp-linter/.github
path: org-repo
- name: Get PR title
id: get-title
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |-
pr_title=$(gh pr view "${PR_NUMBER}" --repo "${GH_REPO}" --json "title" -q ".title")
echo "title=${pr_title}" >> "${GITHUB_OUTPUT}"
- run: rustup update --no-self-update
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@afcf9780305558bcc9e4bc94b7589ab2bb8b6106 # v1.15.9
- name: Install committed
run: cargo binstall -y committed
env:
GITHUB_TOKEN: ${{ github.token }}
- name: conventional-commit
env:
PR_TITLE: "${{ steps.get-title.outputs.title }}"
COMMITTED_CONFIG: ${{ github.workspace }}/org-repo/.github/committed.toml
run: echo "${PR_TITLE}" | committed --config "${COMMITTED_CONFIG}" --commit-file -
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: latest
- name: spell check
working-directory: project-repo
env:
PR_TITLE: "${{ steps.get-title.outputs.title }}"
run: echo "${PR_TITLE}" | npx cspell-cli lint stdin