From 3f2fa0dd7e8c54b9e871a1d8d0aa84cdcc706fd8 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Wed, 5 Feb 2025 16:05:33 -0900 Subject: [PATCH] use mamba for ruff, update ruff settings --- .github/workflows/reusable-ruff.yml | 10 ++-------- CHANGELOG.md | 12 ++++++++++++ README.md | 15 +++++++++++++-- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/reusable-ruff.yml b/.github/workflows/reusable-ruff.yml index ffd9433..3e48683 100644 --- a/.github/workflows/reusable-ruff.yml +++ b/.github/workflows/reusable-ruff.yml @@ -7,15 +7,9 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Python - uses: actions/setup-python@v5 + - uses: mamba-org/setup-micromamba@v2 with: - python-version: 3.x - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install ruff + environment-file: environment.yml - name: ruff check run: ruff check --output-format=github || (echo 'Run `ruff check --fix` to automatically fix errors where possible.' && exit 1) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d50e66..3f678f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,18 @@ 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). +## [0.17.0] + +### Changed +- The [`reusable-ruff`](.github/workflows/reusable-ruff.yml) workflow now runs inside a mamba environment and assumes the presence of a `environment.yml` file. +- We now recommend pinning to an exact version for both `ruff` and `mypy` in your project dependencies, to avoid unexpected static analysis errors due to unpinned dependency upgrades. +- We now recommend adding the following lines to `pyproject.toml`, to bring our recommended `ruff` settings in line with [hyp3-cookiecutter](https://github.com/ASFHyP3/hyp3-cookiecutter/blob/v0.3.3/%7B%7Bcookiecutter.__project_name%7D%7D/pyproject.toml#L56-L84): + + ```toml + [tool.ruff.lint.extend-per-file-ignores] + "tests/*" = ["D100", "D103", "ANN"] + ``` + ## [0.16.0] ### Changed diff --git a/README.md b/README.md index f78177f..d772096 100644 --- a/README.md +++ b/README.md @@ -208,9 +208,13 @@ on: push jobs: call-ruff-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.16.0 + uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.17.0 ``` +Runs inside a mamba environment and assumes the presence of an `environment.yml` file. +We recommend pinning to an exact version of `ruff` in your project dependencies, +because upgrading `ruff` may result in new errors being reported by the `check` and `format` commands. + Make sure that `pyproject.toml` contains the appropriate Python version specifier (see the [ruff docs](https://docs.astral.sh/ruff/settings/#target-version)), e.g: @@ -250,6 +254,9 @@ convention = "google" [tool.ruff.lint.isort] case-sensitive = true lines-after-imports = 2 + +[tool.ruff.lint.extend-per-file-ignores] +"tests/*" = ["D100", "D103", "ANN"] ``` ### [`reusable-mypy.yml`](./.github/workflows/reusable-mypy.yml) @@ -263,9 +270,13 @@ on: push jobs: call-mypy-workflow: - uses: ASFHyP3/actions/.github/workflows/reusable-mypy.yml@v0.16.0 + uses: ASFHyP3/actions/.github/workflows/reusable-mypy.yml@v0.17.0 ``` +Runs inside a mamba environment and assumes the presence of an `environment.yml` file. +We recommend pinning to an exact version of `mypy` in your project dependencies, +because upgrading `mypy` may result in new type errors being reported. + To use our recommended configuration options, add the following to `pyproject.toml`: