Skip to content

switch to uv #1001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 49 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,63 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# See: https://github.com/pdm-project/pdm/issues/1879
env:
PDM_DEPS: 'urllib3<2'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.1"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
run: uv python install ${{ matrix.python-version }}
- name: Install the project
run: uv sync --all-extras --dev
- name: Run tests
# For example, using `pytest`
run: uv run just coverage
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
python-version: ${{ matrix.python-version }}
- uses: pdm-project/setup-pdm@v4
name: Setup PDM
files: coverage.xml # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
token: ${{ secrets.CODECOV_TOKEN }} # required
- name: Archive code coverage results
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
python-version: ${{ matrix.python-version }} # Version range or exact version of a Python version to use, the same as actions/setup-python
# well we use virtualenv here
# prerelease: true # Allow prerelease versions to be installed
# enable-pep582: true # Enable PEP 582 package loading globally
- name: Install dependencies
run: pdm install # Then you can use pdm in the following steps.
- name: Test with pytest & generate coverage
run: |
pdm test
name: code-coverage-report
path: coverage.xml
retention-days: 2
post:
runs-on: ubuntu-latest
needs: build
if: github.event.pull_request
steps:
- uses: actions/checkout@v4
- name: download covearge
uses: actions/download-artifact@v4
with:
name: code-coverage-report
- name: check coverage
run: |
if [ -f coverage.xml ]; then
echo "Coverage file exists"
else
echo "Coverage file does not exist"
exit 1
fi
- name: post covearge
uses: orgoro/coverage@v3.2
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
44 changes: 0 additions & 44 deletions .github/workflows/cov.yml

This file was deleted.

23 changes: 9 additions & 14 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# See: https://github.com/pdm-project/pdm/issues/1879
env:
PDM_DEPS: 'urllib3<2'

jobs:
documentation:
name: Deploy dev documentation
Expand All @@ -20,16 +16,15 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: pdm-project/setup-pdm@v4
name: Setup PDM
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.12
- name: Install dependencies
run: pdm install -G doc
# Install a specific version of uv.
version: "0.5.1"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install Documentation dependencies
run: uv sync --group doc
- name: Set up build cache
uses: actions/cache@v4
id: cache
Expand All @@ -50,4 +45,4 @@ jobs:
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
run: |
git fetch origin gh-pages --depth=1
pdm run mike deploy -p dev
uv run mike deploy -p dev
19 changes: 9 additions & 10 deletions .github/workflows/deploy_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.12
- uses: pdm-project/setup-pdm@v4
name: Setup PDM
with:
python-version: 3.12
- name: Install dependencies
run: pdm install -G doc
# Install a specific version of uv.
version: "0.5.1"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install Documentation dependencies
run: uv sync --group doc
- name: Set up build cache
uses: actions/cache@v4
id: cache
Expand All @@ -63,4 +62,4 @@ jobs:
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
run: |
git fetch origin gh-pages --depth=1
pdm run mike deploy --update-alias --push ${TAG_VERSION} latest
uv run mike deploy --update-alias --push ${TAG_VERSION} latest
33 changes: 10 additions & 23 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Documentation(preview)
name: Documentation (preview)
on:
pull_request:
types:
Expand All @@ -10,33 +10,21 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# See: https://github.com/pdm-project/pdm/issues/1879
env:
PDM_DEPS: 'urllib3<2'

jobs:
documentation:
name: Deploy preview documentation
runs-on: ubuntu-latest
steps:
- name: Wait for dev documentation to deploy
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: main
check-name: 'Deploy dev documentation'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: pdm-project/setup-pdm@v4
name: Setup PDM
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.12
- name: Install dependencies
run: pdm install -G doc
# Install a specific version of uv.
version: "0.5.1"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install Documentation dependencies
run: uv sync --group doc
- name: Set up build cache
uses: actions/cache@v4
id: cache
Expand All @@ -48,9 +36,8 @@ jobs:
- name: Depoly documentation
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
run: |
pdm run doc_build
uv run mkdocs build
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/pdm.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/publish.yml

This file was deleted.

95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on:
push:
tags:
- "v**"

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
# Install a specific version of uv.
version: "0.5.5"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install the project
run: uv sync --all-extras --dev
- name: Build distribution 📦
run: uv build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/bloqade-analog # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
Loading
Loading