Skip to content

Commit 13357a0

Browse files
committed
ci: add pre-commit and ci
Signed-off-by: msclock <[email protected]>
1 parent 0a7db98 commit 13357a0

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
6+
push:
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
15+
pre-commit:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
ref: ${{ github.head_ref }}
26+
27+
- name: Set up python
28+
uses: actions/setup-python@v3
29+
30+
- name: Run pre-commit on codebase
31+
uses: pre-commit/[email protected]
32+
33+
- name: Auto commit action
34+
uses: stefanzweifel/git-auto-commit-action@v4
35+
if: failure()
36+
with:
37+
commit_message: 'ci: auto fixes from pre-commit'

.pre-commit-config.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# To use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# Or:
6+
#
7+
# pre-commit install # (runs every time you commit in git)
8+
#
9+
# To update this file:
10+
#
11+
# pre-commit autoupdate
12+
#
13+
# See https://github.com/pre-commit/pre-commit
14+
15+
fail_fast: false
16+
exclude: |
17+
(?x)(
18+
^(.vscode/.*)
19+
)
20+
files: '' # set '' as default
21+
22+
repos:
23+
# Standard hooks
24+
- repo: https://github.com/pre-commit/pre-commit-hooks
25+
rev: v4.4.0
26+
hooks:
27+
- id: check-added-large-files
28+
args: [--maxkb=4096]
29+
- id: check-case-conflict
30+
- id: check-merge-conflict
31+
- id: end-of-file-fixer
32+
- id: mixed-line-ending
33+
- id: trailing-whitespace
34+
35+
# Check yaml
36+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
37+
rev: v2.10.0
38+
hooks:
39+
- id: pretty-format-yaml
40+
args:
41+
- --autofix
42+
- --offset=2
43+
exclude: |
44+
(?x)(
45+
.copier-answers.yml
46+
)
47+
48+
# Changes tabs to spaces
49+
- repo: https://github.com/Lucas-C/pre-commit-hooks
50+
rev: v1.5.4
51+
hooks:
52+
- id: remove-tabs
53+
54+
# CMake formatting
55+
- repo: https://github.com/cheshirekow/cmake-format-precommit
56+
rev: v0.6.13
57+
hooks:
58+
- id: cmake-format
59+
additional_dependencies: [pyyaml]
60+
types: [file]
61+
files: (\.cmake|CMakeLists.txt)(.in)?$
62+
63+
# Check for spelling
64+
- repo: https://github.com/codespell-project/codespell
65+
rev: v2.2.5
66+
hooks:
67+
- id: codespell
68+
args:
69+
- -L=lang
70+
- --check-filenames
71+
- --write-changes

0 commit comments

Comments
 (0)