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

bump minimum python to 39 #48

Merged
merged 49 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 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
0d00936
chore: remove old Makefiles and CI
kod-kristoff Oct 22, 2024
27a512e
chore: add uv based Makefile
kod-kristoff Sep 2, 2024
e718bda
chore: adapt Makefile
kod-kristoff Oct 22, 2024
c0f0a20
ci: add uv based workflows
kod-kristoff Sep 2, 2024
c447d42
ci: use env namespace
kod-kristoff Sep 2, 2024
064d777
ci: remove unused actions
kod-kristoff Sep 2, 2024
f98cd27
ci(test): fix python-version
kod-kristoff Sep 16, 2024
a6c69f8
ci: bump uv to 0.4.18
kod-kristoff Oct 4, 2024
46d743e
ci: do not use hashes from workflow file
kod-kristoff Oct 4, 2024
3272def
ci: set python 3.9 as minimum version
kod-kristoff Oct 16, 2024
0c21efd
ci: also test for python 3.13
kod-kristoff Oct 16, 2024
6e4fa59
ci: also test for python 3.14-dev
kod-kristoff Oct 16, 2024
6cd4bad
ci: rename release workflow
kod-kristoff Oct 22, 2024
64bb33e
chore: migrate dependencies from pdm
kod-kristoff Oct 22, 2024
91ac118
fix: use unambigous regex replacement
kod-kristoff Oct 23, 2024
c6c034d
ci(deps): bump uv to 0.5.1
kod-kristoff Nov 13, 2024
f5717da
chore: use dependency-groups
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
0060f85
Merge remote-tracking branch 'ci/main' into bump-minimum-python-to-39
kod-kristoff Nov 18, 2024
2064b50
ci: move workflow
kod-kristoff Nov 18, 2024
e19899f
chore: update pre-commit-config
kod-kristoff Nov 18, 2024
07bf238
ci: adapt release workflow
kod-kristoff Nov 18, 2024
c75d70b
chore: fix typo
kod-kristoff Nov 18, 2024
2c86ff7
chore: fix uv export
kod-kristoff Nov 18, 2024
c7cf08b
Merge remote-tracking branch 'make/main' into bump-minimum-python-to-39
kod-kristoff Nov 18, 2024
1769f80
chore: adapt Makefiles
kod-kristoff Nov 18, 2024
a339607
chore: make mypy happy
kod-kristoff Nov 18, 2024
8436d1f
chore: use sparv-pipeline's ruff config
kod-kristoff Nov 18, 2024
d5fa2c3
docs: add docstrings
kod-kristoff Nov 18, 2024
188bc57
chore(deps): bump parallel-corpus
kod-kristoff Nov 19, 2024
edbe9fe
chore: update install-dev target
kod-kristoff Nov 19, 2024
a5510a3
chore: use Tab in makefile
kod-kristoff Nov 19, 2024
99256b1
test: lock testing deps
kod-kristoff Nov 19, 2024
9d1c678
fix: restrict transformers<4.45 workaround
kod-kristoff Nov 19, 2024
1b1ca6d
chore: add os classifiers
kod-kristoff Nov 19, 2024
9713e8e
ci: only cache uv
kod-kristoff Nov 19, 2024
902a396
ci: remove doctests job
kod-kristoff Nov 20, 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 [email protected]:spraakbanken/python-pdm-ci-conf.git
git remote add ci [email protected]: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
64 changes: 50 additions & 14 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,117 @@ 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 }}


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

- name: Load cached venv
id: cached-venv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/check.yml') }}
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/uv.lock') }}

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

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

- name: Load cached venv
id: cached-venv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/check.yml') }}
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/uv.lock') }}

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

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

- name: Load cached venv
id: cached-venv
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('.github/workflows/check.yml') }}
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/uv.lock') }}

- 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 Down
36 changes: 24 additions & 12 deletions .github/workflows/release-viklofg-sweocr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
tags:
- 'ocr-correction-viklofg-sweocr-v[0-9]+.[0-9]+.[0-9]+'
- "ocr-correction-viklofg-sweocr-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 @@ -60,14 +70,16 @@ jobs:
# 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 @@ -91,11 +103,11 @@ jobs:
- run: pip install -r ocr-correction-viklofg-sweocr/tests/requirements-testing.lock
- run: pip install sparv-sbx-ocr-correction-viklofg-sweocr --no-index --no-deps --find-links dist --force-reinstall
- run: pytest ocr-correction-viklofg-sweocr/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,9 +120,9 @@ 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/ocr-correction-viklofg-sweocr-v')
runs-on: ubuntu-latest
Expand Down
64 changes: 40 additions & 24 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,84 @@ 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/mycoliza/status/1571295690063753218
nightly:
runs-on: ubuntu-latest
name: ubuntu / 3.13-dev
continue-on-error: true # allow failure until py3.8 is dropped
name: ubuntu / 3.14-dev
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install pdm
uses: pdm-project/setup-pdm@v4

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

- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.13-dev"
python-version: "3.14-dev"

- run: python --version
- name: pdm lock
if: hashFiles('pdm.lock') == ''
run: pdm lock
- name: pdm sync --dev
run: pdm sync --dev

- name: uv lock
if: hashFiles('uv.lock') == ''
run: uv lock

- name: uv sync --dev
run: uv sync --dev

- name: make test
run: make test

# 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
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.
continue-on-error: true # allow failure until py3.8 is dropped
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

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