Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ci: ruff format, isort, and lint #409

Merged
merged 14 commits into from
Nov 30, 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
60 changes: 60 additions & 0 deletions .github/workflows/check-styles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Check ruff format and isort applied correctly

name: Style checking

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
ruff-format:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install ruff
run: |
pip3 install ruff --break-system-packages
- name: Run ruff
run: |
set +e # Do not exit shell on ruff failure
out=$(ruff format --check --diff . 2> app_stderr.txt)

exit_code=$?
err=$(<app_stderr.txt)

# Display the raw output in the step
echo "${out}"
echo "${err}"

# Display the Markdown output in the job summary
{ echo "\`\`\`diff"; echo "${out}"; echo "${err}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"

# Exit with the exit-code returned by ruff
exit ${exit_code}

ruff-isort:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install ruff
run: |
pip3 install ruff --break-system-packages
- name: Run ruff
run: |
set +e # Do not exit shell on ruff failure
out=$(ruff check --select I --diff . 2> app_stderr.txt)

exit_code=$?
err=$(<app_stderr.txt)

# Display the raw output in the step
echo "${out}"
echo "${err}"

# Display the Markdown output in the job summary
{ echo "\`\`\`diff"; echo "${out}"; echo "${err}"; echo "\`\`\`"; } >> "$GITHUB_STEP_SUMMARY"

# Exit with the exit-code returned by ruff
exit ${exit_code}
14 changes: 6 additions & 8 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
if: "!contains(github.event.head_commit.message, 'noci')"
strategy:
matrix:
python-version: ["3.11"]
python-version: ['3.11']

steps:
- uses: actions/checkout@v4
Expand All @@ -26,18 +26,16 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8 pytest coverage
pip install -e .
pip install -e .[test]
- name: Lint with flake8
pip install -e '.[test]'
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
ruff check . --config=ruff_essential.toml --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --statistics
ruff check . --exit-zero --statistics
- name: Test with pytest and coverage
run: |
coverage run --source=pdb2pqr -m pytest
coverage run -m pytest
coverage report -m | tee coverage.txt
coverage html
- name: Upload coverage results
Expand Down
Loading