Skip to content

Commit

Permalink
scripts/format: add a command to apply clang-format
Browse files Browse the repository at this point in the history
problem: we have to remember how to apply clang-format

solution: add to format script

ci: add clang-format to check-format and enforce

problem: we don't automatically check c/c++ formatting on push

solution: add clang-format to the check-format script

I also renamed "python formatting" to "code formatting" here so that
would stay accurate
  • Loading branch information
trws committed Jul 11, 2024
1 parent 9440d22 commit 367b9b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
uses: crate-ci/typos@bcafd462cb07ef7ba57e34abf458fe20767e808b # v1.19.0

python-format:
name: python format
runs-on: ubuntu-20.04
name: code formatting
runs-on: ubuntu-24.04
steps:
- uses: actions/setup-python@v5
with:
Expand All @@ -34,10 +34,10 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: install black
run: python3 -m pip install 'black==22.3.0' --force-reinstall
- name: check format
run: ./scripts/check-format
- name: install linting and formatting deps
run: pip install -r scripts/requirements-dev.txt
- name: format and linting checks
run: pre-commit run --all-files

python-lint:
name: python lint
Expand Down
14 changes: 0 additions & 14 deletions scripts/check-format

This file was deleted.

11 changes: 3 additions & 8 deletions scripts/format
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#!/bin/bash

if command -v black 2>&1 > /dev/null ; then
# awk cmd copied from:
# https://unix.stackexchange.com/questions/66097/find-all-files-with-a-python-shebang
find src t -path "src/python/fluxion/jsongraph" -prune -o \
-type f \( -name "*.py" -print -o \
-exec awk ' /^#!.*python/{print FILENAME} {nextfile}' {} + \) \
| xargs black
if command -v pre-commit 2>&1 > /dev/null ; then
pre-commit run --all-files
else
echo "black not found, python left unformatted"
echo "pre-commit not found, please install it, if unsure how use pip install -r scripts/requirements-dev.txt"
fi

0 comments on commit 367b9b4

Please sign in to comment.