Skip to content

Commit

Permalink
ci: only cache uv
Browse files Browse the repository at this point in the history
  • Loading branch information
kod-kristoff committed Nov 19, 2024
1 parent 1b1ca6d commit c023069
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
55 changes: 26 additions & 29 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ permissions:
env:
MINIMUM_PYTHON_VERSION: "3.9"
UV_VERSION: "0.5.1"
UV_CACHE_DIR: /tmp/.uv-cache

jobs:
coverage:
Expand All @@ -36,7 +37,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
# - "3.13" TODO tokenizers need to be at version >=0.20.2 to support python 3.13

runs-on: ${{ matrix.os }}-latest
env:
Expand All @@ -47,32 +48,33 @@ jobs:
with:
submodules: true

- name: Set up uv
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: Load cached venv
id: cached-venv
- 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
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/uv.lock') }}
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
if: steps.cached-venv.outputs.cache-hit != 'true'
run: uv sync --all-extras --dev
run: uv sync --all-extras --all-packages --dev

- 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@v5
with:
Expand Down Expand Up @@ -105,27 +107,25 @@ jobs:
with:
submodules: true

- name: Set up uv
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: Load cached venv
id: cached-venv
- 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
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/pyproject.toml') }}-${{ hashFiles('**/uv.lock') }}
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install dependencies
if: steps.cached-venv.outputs.cache-hit != 'true'
run: uv sync --all-extras --dev
#----------------------------------------------
# Run tests and upload coverage
Expand Down Expand Up @@ -164,10 +164,7 @@ jobs:
submodules: true

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

- name: Set up Python ${{ env.MINIMUM_PYTHON_VERSION }}
id: setup-python
Expand All @@ -176,7 +173,7 @@ jobs:
python-version: ${{ env.MINIMUM_PYTHON_VERSION }}

- name: install lowest direct dependencies
run: uv sync --resolution lowest-direct --all-extras --dev
run: uv sync --resolution lowest-direct --all-extras --all-packages --dev

- name: make test
run: make test
Expand Down
15 changes: 9 additions & 6 deletions ocr-correction-viklofg-sweocr/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ classifiers = [
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependency-groups]
dev = [
"pytest>=8.3.3",
"syrupy>=4.7.2",
"sparv-pipeline-testing @ git+https://github.com/spraakbanken/[email protected]",
]

[project.entry-points."sparv.plugin"]
sbx_ocr_correction_viklofg_sweocr = "sbx_ocr_correction_viklofg_sweocr"

Expand All @@ -59,9 +66,5 @@ packages = ["src/sbx_ocr_correction_viklofg_sweocr"]
[tool.hatch.metadata]
allow-direct-references = true

[dependency-groups]
dev = [
"pytest>=8.3.3",
"syrupy>=4.7.2",
"sparv-pipeline-testing @ git+https://github.com/spraakbanken/[email protected]",
]
[tool.uv]
package = true

0 comments on commit c023069

Please sign in to comment.