-
Notifications
You must be signed in to change notification settings - Fork 3
Initial ruff config and azure setup #74
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
Changes from all commits
6587408
cfb0ec2
cf139a7
4e0ef9e
84bc181
5944a7d
42bf31a
a786a41
f569244
bae7499
1147ca4
4e24546
1aed3c5
7d639d3
d17cc8a
b422d2d
fe87ae4
fcd2e93
c0c2e18
fe2dbee
119b9d8
cb9f196
0fda72f
560863f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| format-and-lint: | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: 3.12 | ||
| - name: Install dependencies | ||
| run: | | ||
| wget https://raw.githubusercontent.com/mdolab/.github/main/.pre-commit-config.yaml | ||
| pip install pre-commit | ||
| # If there's already a ruff.toml file in the repo, we should rename the file we're downloading to ruff.toml-global, then put the line `extend = "ruff.toml-global"` at the top of the local ruff.toml so that ruff will use both configurations. | ||
| url=https://raw.githubusercontent.com/mdolab/.github/main/ruff.toml | ||
| if [[ -f "ruff.toml" ]]; then | ||
| wget $url -O ruff.toml-global; | ||
| sed -i '1s/^/extend = "ruff.toml-global" \n/' ruff.toml | ||
| else | ||
| wget $url | ||
| fi | ||
| echo "Ruff config:" | ||
| if [[ -f "ruff.toml-global" ]]; then | ||
| cat ruff.toml-global | ||
| fi | ||
| cat ruff.toml | ||
| - name: Run pre-commit checks | ||
| run: | | ||
| pre-commit run --all-files --show-diff-on-failure | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the idea that we check all files with all these? This seems to be going through everything, including fortran files and other source and config files, generating loads of errors. Maybe this is fine since these are mostly whitespace issues, but ideally we should have tools specifically for fortran to avoid any clashes.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think we should be running this on all files. I often find myself unwittingly commiting a bunch of whitespace changes to files I didn't mean to edit because my editor automatically trims whitespace and fixes the ends of files. Enforcing these checks will avoid that. |
||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-json | ||
| - id: mixed-line-ending | ||
| - id: check-merge-conflict | ||
| - id: debug-statements | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| # Ruff version. | ||
| rev: v0.12.10 | ||
| hooks: | ||
| # Run the linter. | ||
| - id: ruff-check | ||
| args: [ --fix, --exit-non-zero-on-fix ] | ||
| # Run the formatter. | ||
| - id: ruff-format | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to the above comment, for users that are developing locally and want to run the same thing, its seems like they would need to manually add
extend = <path-to-global-ruff.toml>to all project files? We could add/have a script that does this automatically that could be used both here and locally.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's annoying, but currently they'd have to do the same thing for our repos with local flake8 configs so I don't think this is any worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not quite as difficult with
flake8since on the CLI you can just add the--append-configflag with the extra config file. No file editing needed. This does not seem to exist inruff.