Skip to content

Commit

Permalink
Merge pull request #11 from spraakbanken/9-add-method-for-connecting-…
Browse files Browse the repository at this point in the history
…token-based-on-index

feat: connect isolated tokens based on index
  • Loading branch information
kod-kristoff authored Nov 18, 2024
2 parents 9cbd2bc + 558887f commit 9d49f1c
Show file tree
Hide file tree
Showing 25 changed files with 242 additions and 535 deletions.
51 changes: 14 additions & 37 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ permissions:

env:
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: "0.4.18"
UV_CACHE_DIR: /tmp/.uv-cache
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 @@ -40,16 +39,10 @@ jobs:
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh

- name: Restore uv cache
uses: actions/cache@v4
uses: astral-sh/setup-uv@v3
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Load cached venv
id: cached-venv
Expand All @@ -65,8 +58,6 @@ jobs:
- name: check formatting
run: make check-fmt

- name: Minimize uv cache
run: uv cache prune --ci
lint:
runs-on: ubuntu-latest
name: ubuntu / 3.9 / lint
Expand All @@ -84,32 +75,25 @@ jobs:
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh

- name: Restore uv cache
uses: actions/cache@v4
uses: astral-sh/setup-uv@v3
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
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('**/uv.lock') }}

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

- name: lint code
run: make lint

- name: Minimize uv cache
run: uv cache prune --ci

type-check:
runs-on: ubuntu-latest
name: ubuntu / 3.9 / type-check
Expand All @@ -127,32 +111,25 @@ jobs:
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh

- name: Restore uv cache
uses: actions/cache@v4
uses: astral-sh/setup-uv@v3
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
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('**/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

- name: Minimize uv cache
run: uv cache prune --ci

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check-check:
if: always()
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ permissions:

env:
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: "0.4.18"
UV_CACHE_DIR: /tmp/.uv-cache
UV_VERSION: "0.5.1"

jobs:
build:
Expand Down Expand Up @@ -48,16 +47,10 @@ jobs:
# ----- setup uv and load cache -----
#----------------------------------------------
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh

- name: Restore uv cache
uses: actions/cache@v4
uses: astral-sh/setup-uv@v3
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
version: ${{ env.UV_VERSION }}
enable-cache: true

#----------------------------------------------
# ----- build distribution -----
Expand All @@ -73,9 +66,6 @@ jobs:
name: pypi_files
path: dist

- name: Minimize uv cache
run: uv cache prune --ci

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
Expand Down
60 changes: 42 additions & 18 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,75 @@ concurrency:
name: rolling

env:
UV_VERSION: "0.4.18"
UV_CACHE_DIR: /tmp/.uv-cache
UV_VERSION: "0.5.1"

jobs:
# https://twitter.com/mycoliza/status/1571295690063753218
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@v3
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

- 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.
steps:
- uses: actions/checkout@v4
with:
submodules: true

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

- name: Install 3.12
if: hashFiles('uv.lock') != ''
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: uv sync --dev --upgrade
if: hashFiles('uv.lock') != ''
run: uv sync --dev --upgrade

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

- name: Minimize uv cache
if: hashFiles('uv.lock') != ''
run: uv cache prune --ci
57 changes: 15 additions & 42 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ permissions:

env:
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: "0.4.18"
UV_CACHE_DIR: /tmp/.uv-cache
UV_VERSION: "0.5.1"

jobs:
coverage:
Expand Down Expand Up @@ -49,23 +48,17 @@ jobs:
submodules: true

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Load cached venv
id: cached-venv
uses: actions/cache@v4
Expand All @@ -80,11 +73,8 @@ jobs:
- name: Run tests for coverage
run: make test-w-coverage cov_report=xml

- name: Minimize uv cache
run: uv cache prune --ci

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
# directory: ./coverage
Expand Down Expand Up @@ -116,23 +106,17 @@ jobs:
submodules: true

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

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

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Load cached venv
id: cached-venv
uses: actions/cache@v4
Expand All @@ -149,9 +133,6 @@ jobs:
- name: make doc-tests
run: make doc-tests cov_report=xml

- name: Minimize uv cache
run: uv cache prune --ci

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down Expand Up @@ -181,33 +162,25 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh
uses: astral-sh/setup-uv@v3
with:
version: ${{ env.UV_VERSION }}
enable-cache: true

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

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: install lowest direct dependencies
run: uv sync --resolution lowest-direct --all-extras --dev

- name: make test
run: make test

- name: Minimize uv cache
run: uv cache prune --ci

# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
test-check:
if: always()
Expand Down
Loading

0 comments on commit 9d49f1c

Please sign in to comment.