Skip to content

Commit 147b8a6

Browse files
committed
ci: Add workflow (check spelling, formatting excluded)
1 parent 7d65d2c commit 147b8a6

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed

.codespellrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[codespell]
2+
builtin=clear,rare,informal,usage,code,names
3+
ignore-words-list=aci,master,jupyter,lite,ws,wan,hass,cmak,aks,tim,offen,som,iterm,man-in-the-middle
4+
skip="./.*"
5+
quiet-level=2

.github/workflows/pre-commit.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
LOG_TO_CS: .github/logToCs.py
11+
RAW_LOG: pre-commit.log
12+
CS_XML: pre-commit.xml
13+
steps:
14+
- name: Install required tools
15+
run: sudo apt-get update && sudo apt-get install cppcheck
16+
if: false
17+
# Checkout git sources to analyze
18+
- uses: actions/checkout@v4
19+
# Needed to ensuire expected file exists
20+
- name: Create requirements.txt if no requirements.txt or pyproject.toml
21+
run: |-
22+
[ -r requirements.txt ] || [ -r pyproject.toml ] || touch requirements.txt
23+
# Install python and pre-commit tool
24+
- uses: actions/setup-python@v4
25+
with:
26+
cache: pip
27+
python-version: '3.11'
28+
- run: python -m pip install pre-commit
29+
# Restore previous cache of precommit
30+
- uses: actions/cache/restore@v4
31+
with:
32+
path: ~/.cache/pre-commit/
33+
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
34+
# Run all the precommit tools (defined into pre-commit-config.yaml). We can force exclusion of some of them here.
35+
- name: Run pre-commit hooks
36+
env:
37+
# SKIP is used by pre-commit to not execute certain hooks
38+
SKIP: mdformat
39+
run: |
40+
set -o pipefail
41+
pre-commit gc
42+
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
43+
44+
- name: Convert Raw Log to Annotations
45+
uses: mdeweerd/[email protected]
46+
if: ${{ failure() }}
47+
with:
48+
in: ${{ env.RAW_LOG }}
49+
50+
# Save the precommit cache
51+
- uses: actions/cache/save@v4
52+
if: ${{ ! cancelled() }}
53+
with:
54+
path: ~/.cache/pre-commit/
55+
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
56+
}}
57+
# Upload result log files of precommit into the Artifact shared store
58+
- name: Provide log as artifact
59+
uses: actions/upload-artifact@v3
60+
if: ${{ always() }}
61+
with:
62+
name: precommit-logs
63+
path: |
64+
${{ env.RAW_LOG }}
65+
${{ env.CS_XML }}
66+
retention-days: 2

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,3 @@ repos:
2525
rev: v2.2.5
2626
hooks:
2727
- id: codespell
28-
args:
29-
# - --builtin=clear,rare,informal,usage,code,names,en-GB_to_en-US
30-
- --builtin=clear,rare,informal,usage,code,names
31-
- --ignore-words-list=aci,master,jupyter,lite,ws,wan,hass,cmak,aks,tim,offen,som,iterm
32-
- --skip="./.*"
33-
- --quiet-level=2

0 commit comments

Comments
 (0)