diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 840760e..de8d0e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,7 @@ permissions: env: MINIMUM_PYTHON_VERSION: "3.9" UV_VERSION: "0.5.1" + UV_CACHE_DIR: /tmp/.uv-cache jobs: coverage: @@ -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: @@ -117,15 +119,7 @@ jobs: with: python-version: ${{ env.MINIMUM_PYTHON_VERSION }} - - 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: uv sync --all-extras --dev #---------------------------------------------- # Run tests and upload coverage @@ -164,10 +158,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 diff --git a/ocr-correction-viklofg-sweocr/pyproject.toml b/ocr-correction-viklofg-sweocr/pyproject.toml index 5ebde73..bd9d590 100644 --- a/ocr-correction-viklofg-sweocr/pyproject.toml +++ b/ocr-correction-viklofg-sweocr/pyproject.toml @@ -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/sparv-pipeline-testing.git@v0.1.7", +] + [project.entry-points."sparv.plugin"] sbx_ocr_correction_viklofg_sweocr = "sbx_ocr_correction_viklofg_sweocr" @@ -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/sparv-pipeline-testing.git@v0.1.7", -] +[tool.uv] +package = true