Skip to content
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

Use uv instead of pdm #33

Merged
merged 31 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f05e4aa
ci: add uv based workflows
kod-kristoff Sep 2, 2024
1704d89
ci: use env namespace
kod-kristoff Sep 2, 2024
6ad6e5d
chore: add uv based Makefile
kod-kristoff Sep 2, 2024
0a9d5c1
ci: remove unused actions
kod-kristoff Sep 2, 2024
15b3c7d
ci(test): fix python-version
kod-kristoff Sep 16, 2024
cb56a6c
ci: bump uv to 0.4.18
kod-kristoff Oct 4, 2024
2b55d17
ci: do not use hashes from workflow file
kod-kristoff Oct 4, 2024
479cbf3
ci: set python 3.9 as minimum version
kod-kristoff Oct 16, 2024
3cae6a5
ci: also test for python 3.13
kod-kristoff Oct 16, 2024
db04c02
ci: also test for python 3.14-dev
kod-kristoff Oct 16, 2024
c6c034d
ci(deps): bump uv to 0.5.1
kod-kristoff Nov 13, 2024
700690f
ci: use setup-uv action
kod-kristoff Nov 18, 2024
aa660f6
ci: bump codecov-action to v5
kod-kristoff Nov 18, 2024
e3ef757
chore: update uv export
kod-kristoff Nov 18, 2024
c75d70b
chore: fix typo
kod-kristoff Nov 18, 2024
2c86ff7
chore: fix uv export
kod-kristoff Nov 18, 2024
6d8852b
chore: do not emit project
kod-kristoff Nov 18, 2024
9ea9fdc
ci: only cache uv, not .venv
kod-kristoff Nov 20, 2024
3a2fff0
ci: add --all-packages to uv sync calls
kod-kristoff Nov 20, 2024
272aaf5
chore: add --all-packages to uv sync calls
kod-kristoff Nov 21, 2024
cf7f0e5
ci: bump codecov-action to v5
kod-kristoff Nov 21, 2024
80a2566
chore: use uv instead of pdm
kod-kristoff Nov 21, 2024
7f43fa2
chore: migrate pre-commit-config
kod-kristoff Nov 21, 2024
7905cb6
Merge remote-tracking branch 'make/main' into use-uv-instead-of-pdm
kod-kristoff Nov 21, 2024
db5004a
chore(word-prediction-kb-bert): use uv instead of pdm
kod-kristoff Nov 21, 2024
fa770df
Merge remote-tracking branch 'ci/main' into use-uv-instead-of-pdm
kod-kristoff Nov 21, 2024
0b10ab9
ci: remove old release-kb-bert
kod-kristoff Nov 21, 2024
df8ea5a
ci: rename release to release-kb-bert
kod-kristoff Nov 21, 2024
ce6eb0c
ci: adapt release-kb-bert.yaml to project
kod-kristoff Nov 21, 2024
ed5246a
chore: config git-cliff to use Keep-a-changelog format
kod-kristoff Nov 21, 2024
94bbc57
chore(dev-deps): add pytest-cov, ruff and mypy
kod-kristoff Nov 21, 2024
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
10 changes: 5 additions & 5 deletions .github/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

In this folder there is configuration for codecoverage, dependabot and ci workflows.

This folder can be merged using a `--allow-unrelated-histories` merge strategy from <https://github.com/spraakbanken/python-pdm-ci-conf> which provides a reasonably sensible base for writing your own ci on. By using this strategy the history of the CI repo is included in your repo, and future updates to the CI can be merged later.
This folder can be merged using a `--allow-unrelated-histories` merge strategy from <https://github.com/spraakbanken/python-uv-ci-conf> which provides a reasonably sensible base for writing your own ci on. By using this strategy the history of the CI repo is included in your repo, and future updates to the CI can be merged later.

The workflows in this folder requires a root Makefile with a couple of targets defined.
As base can the Makefile in <https://github.com/spraakbanken/python-pdm-make-conf> be used.
As base can the Makefile in <https://github.com/spraakbanken/python-uv-make-conf> be used.

## Publish

The `publish`-step in [test.yml](./workflows/test.yml) is configured to use the GitHub environment `release`, create that or change to your preferred environment.
The `publish`-step in [release.yml](./workflows/release.yml) is configured to use the GitHub environment `release`, create that or change to your preferred environment.
To publish to PyPI you must also configure your Pypi-project settings to use Trusted Publisher Management, by setting repo, workflow and environment on PyPI.

To perform this merge run:

```shell
git remote add ci git@github.com:spraakbanken/python-pdm-ci-conf.git
git remote add ci git@github.com:spraakbanken/python-uv-ci-conf.git
git fetch ci
git merge --allow-unrelated-histories ci/main
```

or add the remote as `git remote add ci https://github.com/spraakbanken/python-pdm-ci-conf.git`
or add the remote as `git remote add ci https://github.com/spraakbanken/python-uv-ci-conf.git`

To later merge updates to this repo, just run:

Expand Down
71 changes: 41 additions & 30 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ permissions:
contents: read

env:
MINIMUM_PYTHON_VERSION: "3.8"
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: "0.5.1"

# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that
# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5
Expand All @@ -22,82 +23,93 @@ concurrency:
jobs:
fmt:
runs-on: ubuntu-latest
name: ubuntu / 3.8 / fmt
name: ubuntu / 3.9 / fmt
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: pdm-project/setup-pdm@v4
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}

- name: Load cached venv
id: cached-venv
uses: actions/cache@v4

#----------------------------------------------
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/pdm.lock') }}-${{ hashFiles('.github/workflows/check.yml') }}
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install dependencies
if: steps.cached-venv.outputs.cache-hit != 'true'
run: make install-dev

- name: check formatting
run: make check-fmt

lint:
runs-on: ubuntu-latest
name: ubuntu / 3.8 / lint
name: ubuntu / 3.9 / lint
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: pdm-project/setup-pdm@v4
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: Load cached venv
id: cached-venv
uses: actions/cache@v4

#----------------------------------------------
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/pdm.lock') }}-${{ hashFiles('.github/workflows/check.yml') }}
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install dependencies
if: steps.cached-venv.outputs.cache-hit != 'true'
run: make install-dev

- name: lint code
run: make lint

type-check:
runs-on: ubuntu-latest
name: ubuntu / 3.8 / type-check
name: ubuntu / 3.9 / type-check
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: pdm-project/setup-pdm@v4
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: Load cached venv
id: cached-venv
uses: actions/cache@v4

#----------------------------------------------
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/pdm.lock') }}-${{ hashFiles('.github/workflows/check.yml') }}
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install dependencies
if: steps.cached-venv.outputs.cache-hit != 'true'
run: make install-dev

- name: type-check code
run: make type-check

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check-check:
if: always()
needs:
needs:
- fmt
- lint
- type-check
Expand All @@ -108,4 +120,3 @@ jobs:
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
allowed-failures: upload-coverage
42 changes: 27 additions & 15 deletions .github/workflows/release-kb-bert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
tags:
- 'word-prediction-kb-bert-v[0-9]+.[0-9]+.[0-9]+'
- "word-prediction-kb-bert-v[0-9]+.[0-9]+.[0-9]+"
pull_request:
merge_group:

Expand All @@ -16,13 +16,14 @@ permissions:
contents: read

env:
MINIMUM_PYTHON_VERSION: "3.8"
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: "0.5.1"

jobs:
build:
# This action builds distribution files for upload to PyPI

name: ubuntu / 3.8 / build
name: ubuntu / 3.9 / build
runs-on: ubuntu-latest
steps:
#----------------------------------------------
Expand All @@ -32,16 +33,25 @@ jobs:
uses: actions/checkout@v4
with:
submodules: true

#----------------------------------------------
# ----- setup python -----
#----------------------------------------------
- name: Set up the environment
uses: pdm-project/setup-pdm@v4
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}


#----------------------------------------------
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

#----------------------------------------------
# ----- build distribution -----
#----------------------------------------------
Expand All @@ -54,20 +64,22 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: pypi_files
path: word-prediction-kb-bert/dist
path: dist

test-build:
# This action runs the test suite on the built artifact in the `build` action.
# The default is to run this in ubuntu, macos and windows

name: ${{ matrix.os }} / 3.8 / test built artifact
name: ${{ matrix.os }} / 3.9 / test built artifact
needs: [build]

strategy:
fail-fast: false
matrix:
os:
os:
- ubuntu
- macos
- windows

runs-on: ${{ matrix.os }}-latest
steps:
Expand All @@ -87,15 +99,15 @@ jobs:
path: dist

- run: rm -r word-prediction-kb-bert/src
# - run: pip install typing-extensions
- run: pip install typing-extensions
- run: pip install -r word-prediction-kb-bert/tests/requirements-testing.lock
- run: pip install sparv-sbx-word-prediction-kb-bert --no-index --no-deps --find-links dist --force-reinstall
- run: pytest word-prediction-kb-bert/tests

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
release-check:
if: always()
needs:
needs:
- build
- test-build
runs-on: ubuntu-latest
Expand All @@ -108,11 +120,11 @@ jobs:
# allowed-failures: coverage

publish:
# This action publishes the built and tested artifact to PyPI, but only on a tag
# This action publishes the built and tested artifact to PyPI, but only on a tag

needs:
needs:
- test-build
if: success() && startsWith(github.ref, 'refs/tags/word-prediction-kb-bert-v')
if: success() && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: release
permissions:
Expand Down
36 changes: 22 additions & 14 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,52 @@ on:
branches: [main]
pull_request:
schedule:
- cron: '7 7 * * *'
- cron: "7 7 * * *"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

name: rolling

env:
UV_VERSION: "0.5.1"

jobs:

# https://twitter.com/alcuadrado/status/1571291687837732873
update:
# This action checks that updating the dependencies of this crate to the latest available that
# satisfy the versions in Cargo.toml does not break this crate. This is important as consumers
# satisfy the versions in pyproject.toml does not break this crate. This is important as consumers
# of this crate will generally use the latest available crates. This is subject to the standard
# Cargo semver rules (i.e cargo does not update to a new major version unless explicitly told
# to).
runs-on: ubuntu-latest
continue-on-error: true # TODO remove this when python 3.8 is dropped
name: ubuntu / 3.12 / updates work
# There's no point running this if no Cargo.lock was checked in in the first place, since we'd
# There's no point running this if no uv.lock was checked in in the first place, since we'd
# just redo what happened in the regular test job. Unfortunately, hashFiles only works in if on
# steps, so we repeat it.
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up uv
if: hashFiles('uv.lock') != ''
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Install 3.12
if: hashFiles('pdm.lock') != ''
uses: pdm-project/setup-pdm@v4
if: hashFiles('uv.lock') != ''
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: pdm update
if: hashFiles('pdm.lock') != ''
run: pdm update
- name: pdm sync --dev
if: hashFiles('pdm.lock') != ''
run: pdm sync --dev

- name: uv sync --dev --upgrade
if: hashFiles('uv.lock') != ''
run: uv sync --dev --upgrade --all-packages

- name: make test
if: hashFiles('pdm.lock') != ''
if: hashFiles('uv.lock') != ''
run: make test
Loading
Loading