From 670c7c42a4d031da7317e27ca74e9bfb30a1ed44 Mon Sep 17 00:00:00 2001 From: Nate Kean <14845347+garlic-os@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:38:51 -0500 Subject: [PATCH 1/4] Add autoformatting GitHub Action --- .github/workflows/autoformat.yml | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/autoformat.yml diff --git a/.github/workflows/autoformat.yml b/.github/workflows/autoformat.yml new file mode 100644 index 000000000..a85a78e79 --- /dev/null +++ b/.github/workflows/autoformat.yml @@ -0,0 +1,34 @@ +name: Auto-format with autopep8 + +on: + pull_request: + branches: + - main + - dev + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install autopep8 + run: pip install autopep8 + + - name: Run autopep8 + run: autopep8 --in-place --recursive . + + - name: Check for uncommitted changes + run: | + if [[ $(git status --porcelain) ]]; then + echo "Uncommitted changes found. Please format your code with autopep8." + git --no-pager diff + exit 1 + fi From ba3d730b2d3f92126f9fc15b2e341f4173a08f9d Mon Sep 17 00:00:00 2001 From: Nate Kean <14845347+garlic-os@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:51:43 -0500 Subject: [PATCH 2/4] Ignore E5 --- .github/workflows/{autoformat.yml => autopep8.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{autoformat.yml => autopep8.yml} (91%) diff --git a/.github/workflows/autoformat.yml b/.github/workflows/autopep8.yml similarity index 91% rename from .github/workflows/autoformat.yml rename to .github/workflows/autopep8.yml index a85a78e79..c9cfd1b53 100644 --- a/.github/workflows/autoformat.yml +++ b/.github/workflows/autopep8.yml @@ -23,7 +23,7 @@ jobs: run: pip install autopep8 - name: Run autopep8 - run: autopep8 --in-place --recursive . + run: autopep8 --in-place --recursive --ignore=E5 . - name: Check for uncommitted changes run: | From fa12efdbc3a0600512093211d730828d58c6b422 Mon Sep 17 00:00:00 2001 From: Nate Kean <14845347+garlic-os@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:02:27 -0500 Subject: [PATCH 3/4] Add entry to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22d2856f6..ed57d40d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +* [650](https://github.com/dbekaert/RAiDER/pull/650) - add automatic code formatting + ## [0.5.1] ### Changed * Use hyp3-lib v3* to download orbits to be able to distribute load across ESA and ASF. Can be easily swapped out for `sentineleof` in future release. From dd03b0c229f3970d0e6d2d1e6b43c6bb4b37c7f2 Mon Sep 17 00:00:00 2001 From: Nate Kean <14845347+garlic-os@users.noreply.github.com> Date: Tue, 9 Jul 2024 17:30:44 -0500 Subject: [PATCH 4/4] Replace autopep8 runner with reusable-ruff Changes made per instructions at https://github.com/ASFHyP3/actions/#reusable-ruffyml --- .github/workflows/autopep8.yml | 34 ----------------------------- .github/workflows/reusable-ruff.yml | 7 ++++++ pyproject.toml | 24 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 34 deletions(-) delete mode 100644 .github/workflows/autopep8.yml create mode 100644 .github/workflows/reusable-ruff.yml diff --git a/.github/workflows/autopep8.yml b/.github/workflows/autopep8.yml deleted file mode 100644 index c9cfd1b53..000000000 --- a/.github/workflows/autopep8.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Auto-format with autopep8 - -on: - pull_request: - branches: - - main - - dev - -jobs: - format: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - - name: Install autopep8 - run: pip install autopep8 - - - name: Run autopep8 - run: autopep8 --in-place --recursive --ignore=E5 . - - - name: Check for uncommitted changes - run: | - if [[ $(git status --porcelain) ]]; then - echo "Uncommitted changes found. Please format your code with autopep8." - git --no-pager diff - exit 1 - fi diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml new file mode 100644 index 000000000..9c912ff46 --- /dev/null +++ b/.github/workflows/reusable-ruff.yml @@ -0,0 +1,7 @@ +name: Static analysis + +on: push + +jobs: + call-ruff-workflow: + uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.11.2 diff --git a/pyproject.toml b/pyproject.toml index d5815cdb2..8939e8bc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,3 +66,27 @@ multi_line_output = 5 default_section = "THIRDPARTY" [tool.setuptools_scm] + +[tool.ruff] +line-length = 120 +src = ["tools", "test"] + +[tool.ruff.format] +indent-style = "space" +quote-style = "single" + +[tool.ruff.lint] +extend-select = [ + "I", # isort: https://docs.astral.sh/ruff/rules/#isort-i + "UP", # pyupgrade: https://docs.astral.sh/ruff/rules/#pyupgrade-up + "D", # pydocstyle: https://docs.astral.sh/ruff/rules/#pydocstyle-d + "ANN", # annotations: https://docs.astral.sh/ruff/rules/#flake8-annotations-ann + "PTH", # use-pathlib-pth: https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth +] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.isort] +case-sensitive = true +lines-after-imports = 2