-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathaction.yaml
More file actions
91 lines (81 loc) · 2.54 KB
/
action.yaml
File metadata and controls
91 lines (81 loc) · 2.54 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Test Python
description: Common steps for testing Python packages
inputs:
directory:
description: The directory containing the Python package to test
required: true
test:
description: Whether to run pytest
required: false
default: "true"
coverage:
description: Whether to collect and upload coverage
required: false
default: "false"
coverage_module:
description: The module name for pytest --cov (e.g., alamos, freighter, synnax)
required: false
default: ""
coverage_flag:
description: The codecov flag for this module
required: false
default: ""
type_check:
description: Whether to run mypy type checking
required: false
default: "true"
type_check_dir:
description: The directory to run mypy type checking in
required: false
default: "."
format_check:
description: Whether to run formatting checks (isort, black)
required: false
default: "true"
runs:
using: composite
steps:
- name: Validate inputs
if: inputs.test != 'true' && inputs.coverage == 'true'
shell: bash
run: |
echo "::error::Invalid input combination: coverage cannot be true when test is false"
exit 1
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version-file: ${{ inputs.directory }}/pyproject.toml
- name: Check import order
if: inputs.format_check == 'true'
run: uv run isort -c .
shell: bash
working-directory: ${{ inputs.directory }}
- name: Check formatting
if: inputs.format_check == 'true'
run: uv run black --check --diff --color .
shell: bash
working-directory: ${{ inputs.directory }}
- name: Check types
if: inputs.type_check == 'true'
run: uv run mypy ${{ inputs.type_check_dir }}
shell: bash
working-directory: ${{ inputs.directory }}
- name: Test
if: inputs.test == 'true' && inputs.coverage != 'true'
run: uv run pytest
shell: bash
working-directory: ${{ inputs.directory }}
- name: Test with coverage
if: inputs.test == 'true' && inputs.coverage == 'true'
run: uv run pytest --cov=${{ inputs.coverage_module }} --cov-report=xml
shell: bash
working-directory: ${{ inputs.directory }}
- name: Upload coverage
if: inputs.coverage == 'true'
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
flags: ${{ inputs.coverage_flag }}
directory: ${{ inputs.directory }}