Skip to content

Commit

Permalink
Merge pull request #469 from robbievanleeuwen/feature/uv-ruff
Browse files Browse the repository at this point in the history
Use uv & ruff in favour of poetry, nox, black, flake8 etc.
  • Loading branch information
robbievanleeuwen authored Oct 26, 2024
2 parents 9a64611 + 61926ba commit 2b92573
Show file tree
Hide file tree
Showing 94 changed files with 5,070 additions and 6,687 deletions.
3 changes: 0 additions & 3 deletions .darglint

This file was deleted.

8 changes: 0 additions & 8 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/section-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.

18 changes: 3 additions & 15 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,24 +50,10 @@ version-resolver:
- "patch"
default: patch

exclude-contributors:
- "robbievanleeuwen"

# Custom text at start of release
header: >
This release contains several important bug fixes and dependency updates.
Python 3.9 support is dropped ahead of the upcoming 3.13 release. Python 3.13 support
will be added once all the core upstream dependencies support 3.13.
A bug in the `CompoundGeometry` offset dilation algorithm was fixed by @connorferster,
a live stream of this fix can be watched [here](https://www.youtube.com/live/hSfsojAAJjc?si=Zuwn7Mr6zXS1wHFF).
Most importantly a critical bug in the plastic moment calculation was found and fixed,
see issue 460. Note that this bug affected plastic moment calculations for composite
sections only, the plastic centroid calculation and geometric-only analyses were
unaffected.
Insert header here...
template: |
Expand Down
194 changes: 194 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
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

- name: Run pre-commit
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} 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 --all-extras

- name: Run pyright
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} 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" }
- { python: "3.12", os: "ubuntu-latest", session: "tests-extended" }

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
if: matrix.session != 'tests-extended'
run: uv sync -p ${{ matrix.python }} --frozen --extra rhino --extra dxf

- name: Install extended test dependencies
if: matrix.session == 'tests-extended'
run: uv sync -p ${{ matrix.python }} --frozen --all-extras

- name: Run pytest
run: uv run -p ${{ matrix.python }} coverage run --parallel-mode -m pytest -m 'not benchmark_suite' --junitxml=junit.xml -o junit_family=legacy

- 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.*"

- name: Upload test results to Codecov
if: matrix.session == 'tests-extended'
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

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 --extra rhino --extra dxf

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

- name: Build docs
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} 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

- 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 }} coverage combine

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

- name: Create coverage report
run: uv run -p ${{ env.DEFAULT_PYTHON_VERSION }} 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
53 changes: 23 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,65 @@ on:
branches:
- master

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

jobs:
release:
name: Release
runs-on: ubuntu-latest

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.12"
version: ${{ env.UV_VERSION }}

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

- name: Install Poetry
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --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
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- 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 }}
Expand Down
Loading

0 comments on commit 2b92573

Please sign in to comment.