Merge pull request #163 from GavinHuttley/develop #185
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Format code using ruff | |
# modified from https://towardsdatascience.com/black-with-git-hub-actions-4ffc5c61b5fe | |
# caching https://stackoverflow.com/questions/59127258/how-can-i-use-pip-cache-in-github-actions | |
# black integration https://black.readthedocs.io/en/stable/integrations/github_actions.html | |
# isort integration https://pycqa.github.io/isort/docs/configuration/github_action.html | |
# copied from cogent3/cogent3/.github | |
on: | |
push: | |
branches-ignore: | |
- master | |
pull_request: | |
branches-ignore: | |
- master | |
jobs: | |
linters: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install tomli | |
export ruff_version=$(python -c 'import tomli; print([line for line in tomli.load(open("pyproject.toml","rb"))["project"]["optional-dependencies"]["dev"] if "ruff" in line][0])') | |
echo "Click version: ruff_version" | |
python -m pip install $ruff_version | |
- name: Format code using ruff | |
run: ruff check --fix-only . && ruff format . | |
- name: Commit changes | |
uses: EndBug/add-and-commit@v9 | |
with: | |
author_name: ${{ github.actor }} | |
author_email: ${{ github.actor }}@users.noreply.github.com | |
message: "STY: pre-commit linting with ruff" | |
add: "." |