Skip to content

Commit

Permalink
CI: Add linting action that uses pre-commit and ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
zssherman committed Jan 25, 2024
1 parent 14fde26 commit 29646c3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: linting

on:
push:
pull_request:
workflow_dispatch:

jobs:
pre-job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'false'
do_not_skip: '["workflow_dispatch", "schedule"]'
linting:
needs: pre-job
runs-on: ubuntu-latest
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: pre-commit/[email protected]
29 changes: 6 additions & 23 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,36 +247,19 @@ An example:
Code Style
----------

ACT follows PEP8 coding standards. To make sure your code follows the
PEP8 style, you can use a variety of tools that can check for you. Two
popular PEP8 check modules are flake8 and pylint. (Note: ACT's continuous
integration uses flake8).
Py-ART uses pre-commit for linting, which applies a variety of pep8 and other
code style rules.

For more on pep8 style:

- https://www.python.org/dev/peps/pep-0008/

To install flake8::
To install pre-commit hooks for the Py-ART repo::

conda install -c conda-forge flake8
pre-commit install

To use flake8::

flake8 path/to/code/to/check.py

To install pylint::

conda install pylint

To use pylint::

pylint path/to/code/to/check.py

Both of these tools are highly configurable to suit a user's taste. Refer to
the tools documentation for details on this process.

- https://flake8.pycqa.org/en/latest/
- https://www.pylint.org/
Afterwards, pre-commit will run on every commit to the repository. It will
re-format files as neccessary.

Naming Convenction
----------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion continuous_integration/environment_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ dependencies:
- coveralls
- pandas
- shapely
- pip
- lazy_loader
- cmweather
- arm-test-data
- moviepy
- ruff
- pip
- pip:
- mpl2nc
- metpy
Expand Down

0 comments on commit 29646c3

Please sign in to comment.