Skip to content

Commit c2c263a

Browse files
committed
ci: pre-commit & generate actions
1 parent deb48ef commit c2c263a

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed

Diff for: .github/workflows/generate.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: Generate files (documentation, autotools)
3+
on:
4+
push:
5+
paths: [man.md, aclocal.m4, configure.ac]
6+
workflow_dispatch:
7+
jobs:
8+
convert_via_pandoc:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: dorny/paths-filter@v2
13+
id: changes
14+
with:
15+
filters: |
16+
man:
17+
- 'man.md'
18+
autotools:
19+
- 'aclocal.m4'
20+
- 'configure.ac'
21+
- uses: docker://pandoc/core:2.17
22+
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' }}
23+
with:
24+
args: -s man.md -t man -o shc.1
25+
- uses: docker://pandoc/core:2.17
26+
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' }}
27+
with:
28+
args: -s man.md -t html -o man.html
29+
- run: |-
30+
./autogen.sh
31+
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.autotools == 'true' }}
32+
- name: Commit changes
33+
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' || steps.changes.outputs.autotools }}
34+
run: |-
35+
for r in $(git remote) ; do git remote get-url --all $r ; done
36+
git config user.name github-actions
37+
git config user.email [email protected]
38+
git commit -a -m "ci: Github Action Generate Files"
39+
git push

Diff for: .github/workflows/pre-commit.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: pre-commit
3+
on:
4+
pull_request:
5+
push:
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-latest
9+
env:
10+
RAW_LOG: pre-commit.log
11+
CS_XML: pre-commit.xml
12+
steps:
13+
- run: sudo apt-get update && sudo apt-get install cppcheck
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
cache: pip
18+
python-version: "3.12.1"
19+
- run: python -m pip install pre-commit
20+
- uses: actions/cache/restore@v4
21+
with:
22+
path: ~/.cache/pre-commit/
23+
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
24+
}}
25+
- name: Run pre-commit hooks
26+
run: |
27+
set -o pipefail
28+
pre-commit gc
29+
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
30+
- name: Convert Raw Log to Annotations
31+
uses: mdeweerd/[email protected]
32+
if: ${{ failure() }}
33+
with:
34+
in: ${{ env.RAW_LOG }}
35+
- uses: actions/cache/save@v4
36+
if: ${{ ! cancelled() }}
37+
with:
38+
path: ~/.cache/pre-commit/
39+
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
40+
}}
41+
- name: Provide log as artifact
42+
uses: actions/upload-artifact@v4
43+
if: ${{ ! cancelled() }}
44+
with:
45+
name: precommit-logs
46+
path: |
47+
${{ env.RAW_LOG }}
48+
${{ env.CS_XML }}
49+
retention-days: 2

Diff for: .pre-commit-config.yaml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
exclude:
3+
(?x)^(
4+
configure\..*|
5+
.cache/.*
6+
)$
7+
repos:
8+
- repo: https://github.com/executablebooks/mdformat
9+
# Do this before other tools "fixing" the line endings
10+
rev: 0.7.17
11+
hooks:
12+
- id: mdformat
13+
name: Format Markdown
14+
stages: [manual]
15+
entry: mdformat # Executable to run, with fixed options
16+
language: python
17+
types: [markdown]
18+
args: [--wrap, '75', --number]
19+
additional_dependencies:
20+
- mdformat-toc
21+
- mdformat-gfm
22+
- mdformat-beautysh
23+
- repo: https://github.com/pre-commit/pre-commit-hooks
24+
rev: v4.6.0
25+
hooks:
26+
# - id: no-commit-to-branch
27+
# args: [--branch, main]
28+
- id: debug-statements
29+
- id: end-of-file-fixer
30+
exclude: ^(test/.*)$
31+
- id: trailing-whitespace
32+
exclude: .*\.md$
33+
- id: check-json
34+
- id: mixed-line-ending
35+
- id: check-builtin-literals
36+
args: [--ignore=dict]
37+
- id: check-ast
38+
- id: check-merge-conflict
39+
- id: check-executables-have-shebangs
40+
- id: check-shebang-scripts-are-executable
41+
exclude: ^(test/.*)$
42+
- id: check-docstring-first
43+
- id: fix-byte-order-marker
44+
- id: check-case-conflict
45+
- id: check-toml
46+
- repo: https://github.com/lovesegfault/beautysh.git
47+
rev: v6.2.1
48+
hooks:
49+
- id: beautysh
50+
exclude: ^(test/.*)$
51+
additional_dependencies:
52+
- setuptools
53+
- repo: https://github.com/codespell-project/codespell
54+
rev: v2.3.0
55+
hooks:
56+
- id: codespell
57+
args:
58+
- --toml
59+
- pyproject.toml
60+
additional_dependencies:
61+
- tomli
62+
- repo: https://github.com/pocc/pre-commit-hooks
63+
rev: v1.3.5
64+
# Install dependencies on windows:
65+
# choco install llvm uncrustify cppcheck
66+
hooks:
67+
- id: uncrustify
68+
stages: [manual]
69+
args: [--replace, --no-backup, -c, uncrustify.cfg]
70+
- id: cppcheck
71+
args:
72+
- --force
73+
#- --std=c99
74+
- --language=c
75+
#- -IInc
76+
- '--template={file}({line}): {severity} ({id}): {message}'
77+
- id: cpplint
78+
args: ["--filter=-build/header_guard,-build/include,-build/include_subdir,-legal/copyright,-readbility/casting,-readability/fn_size,-whitespace/blank_line,-whitespace/braces,-whitespace/comma,-whitespace/comments,-whitespace/line_length,-whitespace/newline,-whitespace/operators,-whitespace/parens,-whitespace/semicolon,-whitespace/tab,-whitespace/todo"]
79+
additional_dependencies:
80+
- cpplint>=1.6.1
81+
- repo: https://github.com/shellcheck-py/shellcheck-py
82+
rev: v0.10.0.1
83+
hooks:
84+
- id: shellcheck
85+
# args: [-x,-e1007,-e1009,-e1072,-e1073]
86+
- repo: https://github.com/pocc/pre-commit-hooks
87+
rev: v1.3.5
88+
hooks:
89+
- id: clang-format
90+
stages: [manual]
91+
args: [-i]

Diff for: pyproject.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[build-system]
2+
requires = ["setuptools>=61.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
dynamic = ["version"]
7+
8+
[tool.codespell]
9+
ignore-words-list = """
10+
stdio,master,scrpt
11+
"""
12+
skip = """./.*,*/.metadata,*.xml,configure,*Makefile*,config*,*.m4,man.html"""
13+
quiet-level=2
14+
ignore-regex = '\\[fnrstv]'
15+
builtin = "clear,rare,informal,usage,code,names"
16+
17+
[tool.setuptools]
18+
include-package-data = false

0 commit comments

Comments
 (0)