diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index 0b86fd4..0000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Black - -on: [workflow_call] - -jobs: - black: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: psf/black@stable - with: - options: "--check --verbose" - version: "24.1.1" diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml index 1fa0ebc..83b166d 100644 --- a/.github/workflows/branch.yml +++ b/.github/workflows/branch.yml @@ -7,9 +7,7 @@ on: - '!main' # ... that is not main jobs: - isort: - uses: ./.github/workflows/isort.yml - black: - uses: ./.github/workflows/black.yml + ruff: + uses: ./.github/workflows/ruff.yml build: uses: ./.github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3b7c54..c35e55f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,4 +30,4 @@ jobs: pip install .[test] - name: Run tests & coverage run: | - coverage run -p -m unittest discover -v -s ./tests + pytest . diff --git a/.github/workflows/external_pr.yml b/.github/workflows/external_pr.yml index bae7869..3a974ce 100644 --- a/.github/workflows/external_pr.yml +++ b/.github/workflows/external_pr.yml @@ -18,15 +18,11 @@ jobs: run: | echo "LOCAL_PR=${{ env.LOCAL_PR }}" >> $GITHUB_OUTPUT - isort: + ruff: needs: variables # if PR is external, trigger the tests on push or new PR if: ${{ needs.variables.outputs.LOCAL_PR == 'false'}} - uses: ./.github/workflows/isort.yml - black: - needs: variables - if: ${{ needs.variables.outputs.LOCAL_PR == 'false' }} - uses: ./.github/workflows/black.yml + uses: ./.github/workflows/ruff.yml build: needs: variables if: ${{ needs.variables.outputs.LOCAL_PR == 'false' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e41f53c..b322ef3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Bump version, create release and deploy +name: Build, test, deploy on: push: @@ -7,15 +7,13 @@ on: jobs: - isort: - uses: ./.github/workflows/isort.yml - black: - uses: ./.github/workflows/black.yml + ruff: + uses: ./.github/workflows/ruff.yml build: uses: ./.github/workflows/build.yml bump: - needs: [isort, black, build] + needs: [ruff, build] runs-on: ubuntu-latest outputs: tag: ${{ steps.semver.outputs.next }} @@ -23,7 +21,7 @@ jobs: steps: - name: Create Github token - uses: actions/create-github-app-token@v1 + uses: actions/create-github-app-token@v2 id: app-token with: app-id: ${{ vars.CODEGEN_APP_ID }} @@ -49,7 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Create Github token - uses: actions/create-github-app-token@v1 + uses: actions/create-github-app-token@v2 id: app-token with: app-id: ${{ vars.CODEGEN_APP_ID }} @@ -92,7 +90,7 @@ jobs: steps: - name: Create Github token - uses: actions/create-github-app-token@v1 + uses: actions/create-github-app-token@v2 id: app-token with: app-id: ${{ vars.CODEGEN_APP_ID }} @@ -144,7 +142,7 @@ jobs: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - name: Create Github token - uses: actions/create-github-app-token@v1 + uses: actions/create-github-app-token@v2 id: app-token with: app-id: ${{ vars.CODEGEN_APP_ID }} @@ -165,11 +163,14 @@ jobs: with: python-version: 3.11 - - name: Install dependencies and build dist + - name: Install uv + uses: astral-sh/setup-uv@v5 + + - name: Build run: | - python -m pip install --upgrade pip - pip install build - python -m build + uv build - name: Publish package distributions to Test.PyPI uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/isort.yml b/.github/workflows/ruff.yml similarity index 62% rename from .github/workflows/isort.yml rename to .github/workflows/ruff.yml index dc47108..4988d86 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/ruff.yml @@ -1,10 +1,10 @@ -name: Isort +name: Ruff on: [workflow_call] jobs: - isort: + ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: isort/isort-action@master + - uses: astral-sh/ruff-action@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 33153b1..ac2dc9c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,15 +2,15 @@ default_install_hook_types: - pre-commit - commit-msg repos: - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.1.1 + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.11.5 hooks: - - id: black - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort (python) + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format - repo: https://github.com/compilerla/conventional-pre-commit rev: v3.3.0 hooks: diff --git a/README.md b/README.md index 4104ec9..59841c5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ +[![Build Status](https://github.com/drodarie/test_actions/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/drodarie/test_actions/actions/workflows/build.yml?query=branch%3Amain) +[![Ruff](https://github.com/drodarie/test_actions/actions/workflows/ruff.yml/badge.svg?branch=main)](https://github.com/drodarie/test_actions/actions/workflows/ruff.yml?query=branch%3Amain) + # test_actions Test Github actions for python project diff --git a/pyproject.toml b/pyproject.toml index 494756f..3d70b21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["poetry-core>=2.0.0,<3.0.0"] -build-backend = "poetry.core.masonry.api" +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" [project] name = "test-actions" @@ -12,20 +12,46 @@ requires-python = ">=3.10" version = "1.3.0" dynamic = ["description"] dependencies = [ - "numpy (>=2.2.3,<3.0.0)", - "scipy (>=1.15.2,<2.0.0)", - "pynrrd (>=1.1.3,<2.0.0)", + "numpy>=2.2.4", + "pynrrd>=1.1.3", + "scipy>=1.15.2", ] [project.optional-dependencies] -test = ["coverage (>=7.6.12,<8.0.0)"] -dev = ["black (>=25.1.0,<26.0.0)", "isort (>=6.0.0,<7.0.0)", "pre-commit (>=4.1.0,<5.0.0)", "bump-my-version (>=0.32.1,<0.33.0)"] +test = [ + "pytest>=8.3.5", + "pytest-cov>=6.1.1", + "pytest-sugar>=1.0.0", +] +dev = [ + "pre-commit>=4.2.0", + "ruff>=0.11.5", +] -[tool.black] +[tool.pytest.ini_options] +addopts = """ + --cov + --cov-report html:'cover/html' + --cov-report xml:'cover/coverage.xml' +""" + +[tool.ruff] +exclude = [".venv"] line-length = 100 +indent-width = 4 + +[tool.ruff.lint] +select = [ "E", "F", "UP", "B", "SIM", "I" ] +ignore = [ ] +fixable = [ "ALL" ] +unfixable = [ ] -[tool.isort] -profile = "black" +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" +docstring-code-line-length = "dynamic" [tool.bumpversion] current_version = "1.3.0" diff --git a/test_actions/__init__.py b/test_actions/__init__.py index 830e8bc..785614e 100644 --- a/test_actions/__init__.py +++ b/test_actions/__init__.py @@ -6,3 +6,6 @@ import nrrd import numpy as np + +np.arange(0, 10, 0.1) +print(nrrd.__version__)