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

Use a pre-commit workflow to check style #478

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .github/workflows/check-markdown.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/check-pep8.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/check-scripts.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/check-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check style
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
check_style:
runs-on: ubuntu-latest
steps:
- name: Checkout preCICE
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.10'
check-latest: true
- name: Install pre-commit
run: pip install pre-commit
- name: Run checks
run: pre-commit run -a -v
- name: Git status
if: always()
run: git status
- name: Full diff
if: always()
run: git diff
24 changes: 17 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ repos:
rev: v0.30.0
hooks:
- id: markdownlint
files: "^(.*/)?README.md"
exclude: changelog-entries
- id: markdownlint-fix
files: "^(.*/)?README.md"
exclude: changelog-entries
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
hooks:
Expand All @@ -20,15 +20,25 @@ repos:
rev: 'v8.0.1'
hooks:
- id: clang-format
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
args: [ --external-sources, --exclude=SC1091 ]
- repo: local
hooks:
- id: check-image-naming
name: check image names
language: python
entry: tools/check-image-names.py
files: ".*/images/.*"
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
- id: shellcheck
args: [ --external-sources, --exclude=SC1091 ]
- id: check-size
name: check sizes
language: script
entry: tools/check-size.sh
pass_filenames: false
- id: check-names
name: check file names
language: script
entry: tools/check.sh
pass_filenames: false
4 changes: 2 additions & 2 deletions tools/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tutorials=$(find . -maxdepth 1 -type d -not -name ".*" | grep -vE $IGNORE | sed

for tutorial in $tutorials; do
# Check permalinks
docs=$(find "./$tutorial" -maxdepth 1 -type f -name "*.md" -print0 | xargs grep -l "permalink:" | sed "s/^.\///")
docs=$(find "./$tutorial" -maxdepth 1 -type f -name "*.md" -print0 | xargs -0 grep -l "permalink:" | sed "s/^.\///")
MakisH marked this conversation as resolved.
Show resolved Hide resolved
for doc in $docs; do
link=$(grep "permalink:" "$doc" | sed "s/permalink: \+//")
prefix="tutorials-$tutorial"
Expand Down Expand Up @@ -40,7 +40,7 @@ for tutorial in $tutorials; do
done

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