Skip to content

Commit

Permalink
Merge pull request #1 from spraakbanken/setup-uv
Browse files Browse the repository at this point in the history
setup ci
  • Loading branch information
kod-kristoff authored Feb 3, 2025
2 parents 23753b8 + b6d81b1 commit 3ba8bbd
Show file tree
Hide file tree
Showing 37 changed files with 1,380 additions and 177 deletions.
32 changes: 32 additions & 0 deletions .github/DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Github config and workflows

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-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-uv-make-conf> be used.

## Publish

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-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-uv-ci-conf.git`

To later merge updates to this repo, just run:

```shell
git fetch ci
get merge ci/main
```

This setup is inspired by <https://github.com/jonhoo/rust-ci-conf>.
21 changes: 21 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ref: https://docs.codecov.com/docs/codecovyml-reference
coverage:
# Hold ourselves to a high bar
range: 85..100
round: down
precision: 1
status:
# ref: https://docs.codecov.com/docs/commit-status
project:
default:
# Avoid false negatives
threshold: 1%

# Test files aren't important for coverage
ignore:
- "tests"

# Make comments less noisy
comment:
layout: "files"
require_changes: true
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
ignore:
- dependency-name: "*"
# patch and minor updates don't matter for libraries as consumers of this library build
# with their own lockfile, rather than the version specified in this library's lockfile
# remove this ignore rule if your package has binaries to ensure that the binaries are
# built with the exact set of dependencies and those are up to date.
update-types:
- "version-update:semver-patch"
- "version-update:semver-minor"
94 changes: 94 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Code generated by internal/ci/github/ci_tool.cue; DO NOT EDIT.

name: check
"on":
push:
branches:
- main
pull_request: null
merge_group: null
permissions:
contents: read
env:
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: 0.5.15
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
fmt:
runs-on: ubuntu-latest
name: ubuntu / 3.9 / fmt
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: make install-dev
- name: check formatting
run: make check-fmt
lint:
runs-on: ubuntu-latest
name: ubuntu / 3.9 / lint
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: make install-dev
- name: lint code
run: make lint
type-check:
runs-on: ubuntu-latest
name: ubuntu / 3.9 / type-check
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up the python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install dependencies
run: make install-dev
- name: type-check code
run: make type-check
check-check:
if: always()
needs:
- fmt
- lint
- type-check
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
109 changes: 109 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Code generated by internal/ci/github/ci_tool.cue; DO NOT EDIT.

name: release
"on":
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+
pull_request: null
merge_group: null
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
env:
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: 0.5.15
jobs:
build:
name: ubuntu / 3.9 / build
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up the environment
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Build distribution
run: make build
- uses: actions/upload-artifact@v4
with:
name: pypi_files
path: dist
test-build:
name: ${{ matrix.os }} / 3.9 / test built artifact
needs:
- build
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macos
- windows
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: set up python
uses: actions/setup-python@v5
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
name: pypi_files
path: dist
- run: rm -r src
- run: pip install typing-extensions
- run: pip install -r tests/requirements-testing.lock
- run: pip install karp-api-client --no-index --no-deps --find-links dist --force-reinstall
- run: pytest
release-check:
if: always()
needs:
- build
- test-build
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
publish:
needs:
- test-build
if: success() && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.MINIMUM_PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
name: pypi_files
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
66 changes: 66 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Code generated by internal/ci/github/ci_tool.cue; DO NOT EDIT.

permissions:
contents: read
"on":
push:
branches:
- main
pull_request: null
schedule:
- cron: 7 7 * * *
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: rolling
env:
UV_VERSION: 0.5.15
jobs:
nightly:
runs-on: ubuntu-latest
name: ubuntu / 3.14-dev
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install python
uses: actions/setup-python@v5
with:
python-version: 3.14-dev
- run: python --version
- name: uv lock
if: hashFiles('uv.lock') == ''
run: uv lock
- name: uv sync --dev
run: uv sync --dev --all-packages --all-extras
- name: make test
run: make test
update:
runs-on: ubuntu-latest
name: ubuntu / 3.13 / updates work
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up uv
if: hashFiles('uv.lock') != ''
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
- name: Install 3.13
if: hashFiles('uv.lock') != ''
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: uv sync --dev --upgrade
if: hashFiles('uv.lock') != ''
run: uv sync --dev --upgrade --all-packages --all-extras
- name: make test
if: hashFiles('uv.lock') != ''
run: make test
Loading

0 comments on commit 3ba8bbd

Please sign in to comment.