Skip to content

Commit

Permalink
Add uv & ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
robbievanleeuwen committed Oct 27, 2024
1 parent 9ba26df commit 817b83a
Show file tree
Hide file tree
Showing 27 changed files with 2,817 additions and 4,788 deletions.
3 changes: 0 additions & 3 deletions .darglint

This file was deleted.

10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ tick all *appropriate* boxes. But please read our
[contribution guide](https://github.com/robbievanleeuwen/concrete-properties/blob/master/CONTRIBUTING.md)
at least once, it will save you unnecessary review cycles! -->

- [ ] Added a description of your pull request below.
- [ ] Added **tests** for changed code.
- [ ] Updated **documentation** for changed code.
- [ ] Run the **Nox** test suite to check for errors and warnings.
- [ ] Run `uv run pre-commit run --all-files` and `uv run pyright` to ensure code quality.

<!-- If you have *any* questions to *any* of the points above, just **submit and ask**!
This checklist is here to *help* you, not to deter you from contributing! -->

<!-- PR descrtiption below -->
24 changes: 0 additions & 24 deletions .github/dependabot.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ categories:
- "build"

category-template: "### $TITLE"
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"

version-resolver:
major:
Expand All @@ -48,13 +50,10 @@ version-resolver:
- "patch"
default: patch

exclude-contributors:
- "robbievanleeuwen"

# Custom text at start of release
header: |
This release adds python 3.12 support!
Insert header here...
template: |
Expand Down
182 changes: 182 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: CI

on:
push:
branches:
- master
pull_request:
types: [opened, reopened, synchronize]

env:
UV_VERSION: "0.4.27"
DEFAULT_PYTHON_VERSION: "3.12"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Install uv version ${{ env.UV_VERSION }}
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install python ${{ env.DEFAULT_PYTHON_VERSION }} using uv
run: uv python install ${{ env.DEFAULT_PYTHON_VERSION }}

- name: Install dependencies
run: uv sync -p ${{ env.DEFAULT_PYTHON_VERSION }} --frozen --only-group lint

- name: Run pre-commit
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} --no-sync pre-commit run --all-files --color always --show-diff-on-failure

type-checking:
name: type-checking
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Install uv version ${{ env.UV_VERSION }}
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install python ${{ env.DEFAULT_PYTHON_VERSION }} using uv
run: uv python install ${{ env.DEFAULT_PYTHON_VERSION }}

- name: Install dependencies
run: uv sync -p ${{ env.DEFAULT_PYTHON_VERSION }} --frozen --no-group test --no-group docs

- name: Run pyright
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} --no-sync pyright

tests:
name: ${{ matrix.session }} ${{ matrix.python }} [${{ matrix.os }}]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { python: "3.12", os: "ubuntu-latest", session: "tests" }
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
- { python: "3.12", os: "windows-latest", session: "tests" }
- { python: "3.11", os: "windows-latest", session: "tests" }
- { python: "3.10", os: "windows-latest", session: "tests" }
- { python: "3.12", os: "macos-latest", session: "tests" }
- { python: "3.11", os: "macos-latest", session: "tests" }
- { python: "3.10", os: "macos-latest", session: "tests" }
- { python: "3.12", os: "macos-13", session: "tests" }
- { python: "3.11", os: "macos-13", session: "tests" }
- { python: "3.10", os: "macos-13", session: "tests" }

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Install uv version ${{ env.UV_VERSION }}
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install python ${{ matrix.python }} using uv
run: uv python install ${{ matrix.python }}

- name: Install test dependencies
run: uv sync -p ${{ matrix.python }} --frozen --no-group docs --no-group lint

- name: Run pytest
run: uv run -p ${{ matrix.python }} --no-sync coverage run --parallel-mode -m pytest

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.session }}-${{ matrix.os }}-${{ matrix.python }}
include-hidden-files: true
path: ".coverage.*"

docs-build:
name: docs-build
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Install uv version ${{ env.UV_VERSION }}
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install python ${{ env.DEFAULT_PYTHON_VERSION }} using uv
run: uv python install ${{ env.DEFAULT_PYTHON_VERSION }}

- name: Install dependencies
run: uv sync -p ${{ env.DEFAULT_PYTHON_VERSION }} --frozen --no-group test --no-group lint

- name: Install pandoc
uses: pandoc/actions/setup@v1

- name: Build docs
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} --no-sync sphinx-build --color docs docs/_build

- name: Upload docs
uses: actions/upload-artifact@v4
with:
name: docs
path: docs/_build

coverage:
name: coverage
runs-on: ubuntu-latest
needs: tests

steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Install uv version ${{ env.UV_VERSION }}
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install python ${{ env.DEFAULT_PYTHON_VERSION }} using uv
run: uv python install ${{ env.DEFAULT_PYTHON_VERSION }}

- name: Install dependencies
run: uv sync -p ${{ env.DEFAULT_PYTHON_VERSION }} --frozen --only-group test

- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage data
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} --no-sync coverage combine

- name: Display coverage report
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} --no-sync coverage report -i

- name: Create coverage report
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} --no-sync coverage xml -i

- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
5 changes: 0 additions & 5 deletions .github/workflows/constraints.txt

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
uses: actions/checkout@v4

- name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v5.0.0
uses: crazy-max/ghaction-github-labeler@v5
with:
skip-delete: true
63 changes: 27 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,65 @@ on:
branches:
- master

env:
UV_VERSION: "0.4.27"
DEFAULT_PYTHON_VERSION: "3.12"

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write

steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv version ${{ env.UV_VERSION }}
uses: astral-sh/setup-uv@v3
with:
python-version: "3.11"

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
version: ${{ env.UV_VERSION }}

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install python ${{ env.DEFAULT_PYTHON_VERSION }} using uv
run: uv python install ${{ env.DEFAULT_PYTHON_VERSION }}

- name: Check if there is a parent commit
id: check-parent-commit
run: |
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
- name: Get previous commit SHA
run: echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_ENV

- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@v2.0.3
if: ${{ env.sha }}
uses: salsify/action-detect-and-tag-new-version@v2
with:
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
version-command: echo $(grep "^version =" pyproject.toml | sed 's/version = "\(.*\)"/\1/')

- name: Bump version for developmental release
- name: Bump version for dev release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
poetry version $version.dev.$(date +%s)
VERSION=$(grep "^version =" pyproject.toml | sed 's/version = "\(.*\)"/\1/')
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION.dev.$(date +%s)
- name: Build package
run: |
poetry build --ansi
run: uv build

- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/gh-action-pypi-publish@v1.10.3
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/gh-action-pypi-publish@v1.10.3
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/release-drafter@v6.0.0
uses: release-drafter/release-drafter@v6
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 817b83a

Please sign in to comment.