-
Notifications
You must be signed in to change notification settings - Fork 346
139 lines (120 loc) · 4.73 KB
/
repo_checks.yml
File metadata and controls
139 lines (120 loc) · 4.73 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# ============================================================================ #
# Copyright (c) 2022 - 2026 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
merge_group:
types:
- checks_requested
name: "Basic content checks"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# ==========================================================================
# Job 1: Code Formatting (clang-format, yapf, markdownlint, file quality)
# ==========================================================================
formatting:
name: Check code formatting
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup pre-commit
id: setup
uses: ./.github/actions/setup-precommit
with:
cache-key-suffix: formatting
# No extra tools needed - pre-commit provides clang-format/yapf
- name: Run formatting checks
run: |
# TODO: Enable end-of-file-fixer, trailing-whitespace, mixed-line-ending when enabled in .pre-commit-config.yaml
HOOKS="clang-format yapf markdownlint check-added-large-files check-case-conflict check-merge-conflict check-symlinks check-yaml check-toml check-json"
EXIT_CODE=0
for hook in $HOOKS; do
echo "::group::Running hook: $hook"
if [ "${{ steps.setup.outputs.mode }}" == "pr" ]; then
cat ${{ steps.setup.outputs.changed-files }} | xargs -r pre-commit run $hook --files || EXIT_CODE=$?
else
pre-commit run $hook --all-files --show-diff-on-failure || EXIT_CODE=$?
fi
echo "::endgroup::"
done
exit $EXIT_CODE
# ==========================================================================
# Job 2: License Headers
# ==========================================================================
license_headers:
name: Check license headers
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1 # Shallow clone - runs on all files, no git diff needed
- name: Setup pre-commit
uses: ./.github/actions/setup-precommit
with:
cache-key-suffix: license
install-go: 'true' # For license-eye
- name: Run license header checks
run: |
HOOKS="license-headers spellcheck-allowlist-sorted"
EXIT_CODE=0
for hook in $HOOKS; do
echo "::group::Running hook: $hook"
pre-commit run $hook --all-files --hook-stage pre-push || EXIT_CODE=$?
echo "::endgroup::"
done
exit $EXIT_CODE
# ==========================================================================
# Job 3: Spell Checking
# ==========================================================================
spelling:
name: Check spelling
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup pre-commit
id: setup
uses: ./.github/actions/setup-precommit
with:
cache-key-suffix: spelling
install-aspell: 'true' # For spell checking
- name: Run spell checks
run: |
pre-commit run spellcheck --all-files --hook-stage pre-push
# ==========================================================================
# Job 4: Link Validation
# ==========================================================================
links:
name: Check links
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: Setup pre-commit
id: setup
uses: ./.github/actions/setup-precommit
with:
cache-key-suffix: links
install-node: 'true' # For markdown-link-check
- name: Run link checks
run: |
if [ "${{ steps.setup.outputs.mode }}" == "pr" ]; then
cat ${{ steps.setup.outputs.changed-files }} | grep '\.md$' || true | xargs -r pre-commit run markdown-link-check --hook-stage pre-push --files
else
pre-commit run markdown-link-check --all-files --hook-stage pre-push
fi