Skip to content

Commit

Permalink
ci: pre-commit & generate actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Aug 11, 2024
1 parent deb48ef commit c2c263a
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Generate files (documentation, autotools)
on:
push:
paths: [man.md, aclocal.m4, configure.ac]
workflow_dispatch:
jobs:
convert_via_pandoc:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
man:
- 'man.md'
autotools:
- 'aclocal.m4'
- 'configure.ac'
- uses: docker://pandoc/core:2.17
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' }}
with:
args: -s man.md -t man -o shc.1
- uses: docker://pandoc/core:2.17
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' }}
with:
args: -s man.md -t html -o man.html
- run: |-
./autogen.sh
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.autotools == 'true' }}
- name: Commit changes
if: ${{ github.event_name == 'workflow_dispath' || steps.changes.outputs.man == 'true' || steps.changes.outputs.autotools }}
run: |-
for r in $(git remote) ; do git remote get-url --all $r ; done
git config user.name github-actions
git config user.email [email protected]
git commit -a -m "ci: Github Action Generate Files"
git push
49 changes: 49 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: pre-commit
on:
pull_request:
push:
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
RAW_LOG: pre-commit.log
CS_XML: pre-commit.xml
steps:
- run: sudo apt-get update && sudo apt-get install cppcheck
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
python-version: "3.12.1"
- run: python -m pip install pre-commit
- uses: actions/cache/restore@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
}}
- name: Run pre-commit hooks
run: |
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
- name: Convert Raw Log to Annotations
uses: mdeweerd/[email protected]
if: ${{ failure() }}
with:
in: ${{ env.RAW_LOG }}
- uses: actions/cache/save@v4
if: ${{ ! cancelled() }}
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
}}
- name: Provide log as artifact
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: precommit-logs
path: |
${{ env.RAW_LOG }}
${{ env.CS_XML }}
retention-days: 2
91 changes: 91 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
exclude:
(?x)^(
configure\..*|
.cache/.*
)$
repos:
- repo: https://github.com/executablebooks/mdformat
# Do this before other tools "fixing" the line endings
rev: 0.7.17
hooks:
- id: mdformat
name: Format Markdown
stages: [manual]
entry: mdformat # Executable to run, with fixed options
language: python
types: [markdown]
args: [--wrap, '75', --number]
additional_dependencies:
- mdformat-toc
- mdformat-gfm
- mdformat-beautysh
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# - id: no-commit-to-branch
# args: [--branch, main]
- id: debug-statements
- id: end-of-file-fixer
exclude: ^(test/.*)$
- id: trailing-whitespace
exclude: .*\.md$
- id: check-json
- id: mixed-line-ending
- id: check-builtin-literals
args: [--ignore=dict]
- id: check-ast
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
exclude: ^(test/.*)$
- id: check-docstring-first
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-toml
- repo: https://github.com/lovesegfault/beautysh.git
rev: v6.2.1
hooks:
- id: beautysh
exclude: ^(test/.*)$
additional_dependencies:
- setuptools
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args:
- --toml
- pyproject.toml
additional_dependencies:
- tomli
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
# Install dependencies on windows:
# choco install llvm uncrustify cppcheck
hooks:
- id: uncrustify
stages: [manual]
args: [--replace, --no-backup, -c, uncrustify.cfg]
- id: cppcheck
args:
- --force
#- --std=c99
- --language=c
#- -IInc
- '--template={file}({line}): {severity} ({id}): {message}'
- id: cpplint
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"]
additional_dependencies:
- cpplint>=1.6.1
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
# args: [-x,-e1007,-e1009,-e1072,-e1073]
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
stages: [manual]
args: [-i]
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
dynamic = ["version"]

[tool.codespell]
ignore-words-list = """
stdio,master,scrpt
"""
skip = """./.*,*/.metadata,*.xml,configure,*Makefile*,config*,*.m4,man.html"""
quiet-level=2
ignore-regex = '\\[fnrstv]'
builtin = "clear,rare,informal,usage,code,names"

[tool.setuptools]
include-package-data = false

0 comments on commit c2c263a

Please sign in to comment.