From 20976a5567a965a9e56acab780ffdd419d6eae8f Mon Sep 17 00:00:00 2001 From: Edwin Hermans Date: Mon, 20 May 2024 22:39:19 -0400 Subject: [PATCH] Switch from black to ruff --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 49 ------------------------------------- .pre-commit-config.yaml | 11 ++++++--- 3 files changed, 58 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ec5e92a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +--- +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["pypy3.9", "pypy3.10", "3.8", "3.9", "3.10", "3.11", "3.12"] + + permissions: + pull-requests: write + + steps: + - uses: actions/checkout@v4 + - uses: eifinger/setup-rye@v3 + id: setup-rye + with: + enable-cache: true + cache-prefix: ${{ matrix.python-version }} + - name: pin python-version ${{ matrix.python-version }} + if: steps.setup-rye.outputs.cache-hit != 'true' + run: rye pin ${{ matrix.python-version }} + - name: install dependencies + if: steps.setup-rye.outputs.cache-hit != 'true' + run: | + rye sync --no-lock + - name: run ruff + uses: chartboost/ruff-action@v1 + - name: run tests + run: | + echo '```' > pytest.log + rye test | tee -a pytest.log + echo '```' >> pytest.log + - name: PR comment pytest output + uses: thollander/actions-comment-pull-request@v2 + with: + filePath: pytest.log + if: github.event_name == 'pull_request' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index cbabb66..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,49 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Test - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - workflow_dispatch: - -permissions: - contents: read - -jobs: - test: - name: Test and lint the application - runs-on: ubuntu-latest - - permissions: - pull-requests: write - - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: "3.10" - cache: 'pip' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Lint with Ruff - run: | - pip install ruff - ruff check --output-format=github . - - name: Test with pytest-cov - run: | - pip install pytest-cov - echo '```' > pytest.log - pytest --cov | tee -a pytest.log - echo '```' >> pytest.log - - name: PR comment pytest output - uses: thollander/actions-comment-pull-request@v2 - with: - filePath: pytest.log - if: github.event_name == 'pull_request' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf50f5a..4d068e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,10 +10,15 @@ repos: - id: check-merge-conflict - id: check-json - id: no-commit-to-branch -- repo: https://github.com/psf/black - rev: 22.10.0 +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.4.4 hooks: - - id: black + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.10.0 hooks: