Skip to content

Commit 23914ab

Browse files
authored
Use a pre-commit workflow to check style (precice#478)
1 parent b695af0 commit 23914ab

File tree

6 files changed

+50
-76
lines changed

6 files changed

+50
-76
lines changed

.github/workflows/check-markdown.yml

-22
This file was deleted.

.github/workflows/check-pep8.yml

-23
This file was deleted.

.github/workflows/check-scripts.yaml

-22
This file was deleted.

.github/workflows/check-style.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Check style
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
pull_request:
8+
branches:
9+
- master
10+
- develop
11+
jobs:
12+
check_style:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout preCICE
16+
uses: actions/checkout@v4
17+
- name: Setup python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.10'
21+
check-latest: true
22+
- name: Install pre-commit
23+
run: pip install pre-commit
24+
- name: Run checks
25+
run: pre-commit run -a -v
26+
- name: Git status
27+
if: always()
28+
run: git status
29+
- name: Full diff
30+
if: always()
31+
run: git diff

.pre-commit-config.yaml

+17-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ repos:
88
rev: v0.30.0
99
hooks:
1010
- id: markdownlint
11-
files: "^(.*/)?README.md"
11+
exclude: changelog-entries
1212
- id: markdownlint-fix
13-
files: "^(.*/)?README.md"
13+
exclude: changelog-entries
1414
- repo: https://github.com/hhatto/autopep8
1515
rev: v2.0.4
1616
hooks:
@@ -20,15 +20,25 @@ repos:
2020
rev: 'v8.0.1'
2121
hooks:
2222
- id: clang-format
23+
- repo: https://github.com/koalaman/shellcheck-precommit
24+
rev: v0.10.0
25+
hooks:
26+
- id: shellcheck
27+
args: [ --external-sources, --exclude=SC1091 ]
2328
- repo: local
2429
hooks:
2530
- id: check-image-naming
2631
name: check image names
2732
language: python
2833
entry: tools/check-image-names.py
2934
files: ".*/images/.*"
30-
- repo: https://github.com/koalaman/shellcheck-precommit
31-
rev: v0.10.0
32-
hooks:
33-
- id: shellcheck
34-
args: [ --external-sources, --exclude=SC1091 ]
35+
- id: check-size
36+
name: check sizes
37+
language: script
38+
entry: tools/check-size.sh
39+
pass_filenames: false
40+
- id: check-names
41+
name: check file names
42+
language: script
43+
entry: tools/check.sh
44+
pass_filenames: false

tools/check.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tutorials=$(find . -maxdepth 1 -type d -not -name ".*" | grep -vE $IGNORE | sed
99

1010
for tutorial in $tutorials; do
1111
# Check permalinks
12-
docs=$(find "./$tutorial" -maxdepth 1 -type f -name "*.md" -print0 | xargs grep -l "permalink:" | sed "s/^.\///")
12+
docs=$(find "./$tutorial" -maxdepth 1 -type f -name "*.md" -print0 | xargs -0 grep -l "permalink:" | sed "s/^.\///")
1313
for doc in $docs; do
1414
link=$(grep "permalink:" "$doc" | sed "s/permalink: \+//")
1515
prefix="tutorials-$tutorial"
@@ -40,7 +40,7 @@ for tutorial in $tutorials; do
4040
done
4141

4242
# Check quickstart
43-
docs=$(find ./quickstart -maxdepth 1 -type f -name "*.md" -print0 | xargs grep -l "permalink:" | sed "s/^.\///")
43+
docs=$(find ./quickstart -maxdepth 1 -type f -name "*.md" -print0 | xargs -0 grep -l "permalink:" | sed "s/^.\///")
4444
for doc in $docs; do
4545
link=$(grep "permalink:" "$doc" | sed "s/permalink: \+//")
4646
prefix="quickstart"

0 commit comments

Comments
 (0)