Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: pre-commit & generate actions #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 github-actions@github.com
git commit -a -m "ci: Github Action Generate Files"
git push
50 changes: 50 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: pre-commit
on:
pull_request:
push:
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
LOG_TO_CS: .github/logToCs.py
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@v4
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/logToCheckStyle@v2024.2.9
if: ${{ failure() }}
with:
in: ${{ env.RAW_LOG }}
- uses: actions/cache/save@v4
if: ${{ always() }}
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: ${{ always() }}
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.5.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.2.6
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.9.0.6
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