Skip to content

Commit

Permalink
Merge pull request slaclab#1028 from nstelter-slac/formatting_linting
Browse files Browse the repository at this point in the history
Format and lint code, and establish standard tools for doing so
  • Loading branch information
jbellister-slac authored Sep 13, 2023
2 parents 32262f5 + e23a335 commit 712e3d5
Show file tree
Hide file tree
Showing 192 changed files with 7,582 additions and 6,588 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
11 changes: 2 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
python-version: [3.8, 3.9]
pyqt-version: [5.12.3, 5.15.7]
env:
DISPLAY: ':99.0'
Expand Down Expand Up @@ -49,19 +49,12 @@ jobs:
shell: bash -el {0}
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt install xvfb herbstluftwm libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
sudo apt install xvfb herbstluftwm libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
sudo /sbin/start-stop-daemon --start --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
sleep 3
sudo /sbin/start-stop-daemon --start --pidfile /tmp/custom_herbstluftwm_99.pid --make-pidfile --background --exec /usr/bin/herbstluftwm
sleep 1
fi
- name: Lint with flake8
shell: bash -el {0}
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-line-length=120 --statistics
- name: Test with pytest
shell: bash -el {0}
run: |
Expand Down
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
files: '\.(py|txt)$' # Only run on .py and .txt files
- id: trailing-whitespace
files: '\.(py|txt)$' # Only run on .py and .txt files
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
args: [--line-length, '120']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
args: [--line-length, '120', --fix, --exit-non-zero-on-fix]
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pytest-cov
pytest-timeout
p4p
pyca
pre-commit
Loading

0 comments on commit 712e3d5

Please sign in to comment.