Skip to content

Commit

Permalink
Merge pull request #48 from spraakbanken/bump-minimum-python-to-39
Browse files Browse the repository at this point in the history
bump minimum python to 39
  • Loading branch information
kod-kristoff authored Nov 20, 2024
2 parents d1e1eca + 902a396 commit 4db5a05
Show file tree
Hide file tree
Showing 23 changed files with 2,859 additions and 5,238 deletions.
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

0 comments on commit 4db5a05

Please sign in to comment.