-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (60 loc) · 1.91 KB
/
python-test.yml
File metadata and controls
67 lines (60 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Python Test
#
# Reusable workflow that installs dependencies with uv and runs pytest.
#
# uv sync --frozen installs all dependencies from the lockfile without
# modifying it. The Python version is resolved from the project's
# pyproject.toml / .python-version file by uv automatically.
#
# Usage in a consuming repository:
#
# # Defaults: runs pytest from the repo root
# jobs:
# test:
# uses: orangitfi/platform-tooling/.github/workflows/python-test.yml@<sha>
#
# # Custom test extras and command
# jobs:
# test:
# uses: orangitfi/platform-tooling/.github/workflows/python-test.yml@<sha>
# with:
# uv-sync-args: "--extra test"
# test-command: "pytest tests/ -v --tb=short"
name: Python Test
on:
workflow_call:
inputs:
working-directory:
description: "Directory containing pyproject.toml"
required: false
default: "."
type: string
test-command:
description: "Command to run tests via uv run (e.g. pytest, pytest tests/ -v)"
required: false
default: "pytest"
type: string
uv-sync-args:
description: "Extra arguments passed to uv sync (e.g. --extra test --extra dev)"
required: false
default: ""
type: string
permissions:
contents: read
jobs:
pytest:
name: pytest
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install uv
uses: orangitfi/platform-tooling/.github/actions/setup-uv@a4ca46b0de8eda2f61573cfbd4164e538a7775a1 # pt-sha
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: uv sync --frozen ${{ inputs.uv-sync-args }}
- name: Run tests
shell: bash
working-directory: ${{ inputs.working-directory }}
run: uv run ${{ inputs.test-command }}