Skip to content

Commit

Permalink
chore: replace poetry with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
leifwar committed Jan 4, 2025
1 parent 031090f commit ccc6103
Show file tree
Hide file tree
Showing 7 changed files with 440 additions and 729 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,9 @@ jobs:
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
56 changes: 27 additions & 29 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,37 @@
name: Deploy to PyPI

on:
release:
types: [created]
workflow_call:
inputs:
build_docs:
required: false
type: boolean
default: false
deploy_docs:
required: false
type: boolean
default: false

jobs:
Deploying:
build_and_publish_pypi:
runs-on: ubuntu-latest

if: github.repository_owner == 'statnett'
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.10

- name: Get full python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Install and configure Poetry
uses: abatilo/[email protected]
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: build package
run: uv build
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1.10
with:
poetry-version: 1.8.3

- name: Install dynamic versioning
run: poetry self add "poetry-dynamic-versioning[plugin]"

- name: Install dependencies
shell: bash
run: poetry install

- name: Build and publish to PyPI
run: |
poetry config pypi-token.pypi ${{ secrets.pypi_push_token }}
poetry publish --build
repository-url: https://test.pypi.org/legacy/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.10 # Use v1.10 https://github.com/pypa/twine/pull/1172
64 changes: 19 additions & 45 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Get full python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Install and configure Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.8.3

- name: Set poetry virtualenv to local
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: poetry install --no-interaction
run: uv sync

- name: Linting
run: poetry run pre-commit run --all-files
run: uvx pre-commit run --all-files

Tests:
needs: Linting
Expand All @@ -47,8 +30,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: ['3.10', '3.11', '3.12']
poetry-version: [1.8.3]
python-version: ['3.10', '3.11', '3.12', '3.13']

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -59,40 +41,32 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Set poetry virtualenv to local
run: poetry config virtualenvs.in-project true
- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Get full python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install --no-interaction
run: uv sync

- name: Static type checking
uses: jakebailey/[email protected]
with:
version: 1.1.367
continue-on-error: true

- name: Run pytest
if: ${{ ( runner.os != 'Linux' ) || ( matrix.python-version != '3.10' ) }}
run: poetry run pytest -q tests
run: uv run pytest -q tests

- name: Run pytest with coverage
if: ${{ ( runner.os == 'Linux' ) && ( matrix.python-version == '3.10' ) }}
run: poetry run pytest -q --cov=rawxio --cov-report=xml tests
run: uv run pytest -q --cov=cimsparql --cov-report=xml tests

- name: Upload coverage
if: ${{ ( runner.os == 'Linux' ) && ( matrix.python-version == '3.10' ) }}
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-json
- id: check-merge-conflict
Expand All @@ -13,7 +13,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.8.5
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
Loading

0 comments on commit ccc6103

Please sign in to comment.