Skip to content

Commit d22fd45

Browse files
committed
Update test workflow to take in input commands
1 parent 6c379ca commit d22fd45

6 files changed

Lines changed: 85 additions & 9 deletions

File tree

.github/docs/Lint (Ruff).md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ This workflow runs ``ruff check`` on the project with ``UV``.
1414

1515
**Inputs:**
1616

17-
- ``runner-label`` (optional): runner to use - default: to "eng-tools"
17+
- ``runner-label`` (optional): runner to use
18+
- default: to "eng-tools"
19+
- ``ruff-commands`` (optional): commands to run with ruff
20+
- default: ``ruff check``
1821

1922
**Outputs:** N/A
2023

2124
## Examples
2225

23-
### Example 1: Ruff Check
26+
### Example 1: Ruff Check Default
2427

2528
**workflow.yml**
2629
```yml
@@ -41,3 +44,27 @@ jobs:
4144
4245
- runs ``ruff check`` on the project whenever a PR is created to merge into dev or main
4346
47+
### Example 2: Ruff Check Commands
48+
49+
**workflow.yml**
50+
```yml
51+
name: Lint
52+
53+
on:
54+
pull_request:
55+
branches:
56+
- main
57+
- dev
58+
59+
jobs:
60+
lint:
61+
uses: AllenNeuralDynamics/.github/.github/workflows/test-lint-ruff-python.yml@main
62+
with:
63+
ruff-commands: check --fix
64+
```
65+
66+
**Results:**
67+
68+
- runs ``ruff check --fix`` on the project whenever a PR is created to merge into dev or main
69+
70+

.github/docs/Test (PyTest).md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ This workflow runs ``pytest tests/`` on the project with ``UV``.
1414

1515
**Inputs:**
1616

17-
- ``runner-label`` (optional): runner to use - default: to "eng-tools"
17+
- ``runner-label`` (optional): runner to use
18+
- default: to "eng-tools"
19+
- ``pytest-commands`` (optional): pytest commands to run
20+
- default: ``pytest tests/``
1821

1922
**Outputs:** N/A
2023

@@ -41,3 +44,27 @@ jobs:
4144
4245
- runs ``pytest tests/`` on the project whenever a PR is created to merge into dev or main
4346
47+
### Example 1: Test Custom
48+
49+
**workflow.yml**
50+
```yml
51+
name: Test
52+
53+
on:
54+
pull_request:
55+
branches:
56+
- main
57+
- dev
58+
59+
jobs:
60+
test:
61+
uses: AllenNeuralDynamics/.github/.github/workflows/test-pytest-python.yml@main
62+
with:
63+
pytest-commands: tests/test_unit_1.py
64+
```
65+
66+
**Results:**
67+
68+
- runs ``pytest tests/test_unit_1.py`` on the project whenever a PR is created to merge into dev or main
69+
70+

.github/docs/Type (mypy).md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ This workflow runs ``mypy`` on the project with ``UV``.
1414

1515
**Inputs:**
1616

17-
- ``runner-label`` (optional): runner to use - default: to "eng-tools"
17+
- ``mypy-commands`` (required): mypy command to run
18+
- ``runner-label`` (optional): runner to use
19+
- default: to "eng-tools"
1820

1921
**Outputs:** N/A
2022

@@ -35,9 +37,11 @@ on:
3537
jobs:
3638
type:
3739
uses: AllenNeuralDynamics/.github/.github/workflows/test-type-mypy-python.yml@main
40+
with:
41+
mypy-commands: src/mypackage --strict
3842
```
3943
4044
**Results:**
4145
42-
- runs ``mypy`` on the project whenever a PR is created to merge into dev or main
46+
- runs ``mypy src/mypackage --strict`` on the project whenever a PR is created to merge into dev or main
4347

.github/workflows/test-lint-ruff-python.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
description: 'Runner to use'
88
type: string
99
default: 'ubuntu-latest'
10+
ruff-commands:
11+
description: 'ruff commands to run'
12+
type: string
1013

1114
jobs:
1215
lint_check:
@@ -17,4 +20,8 @@ jobs:
1720
- name: Install UV
1821
uses: astral-sh/setup-uv@v5
1922
- name: Lint with Ruff
20-
run: uv run ruff check
23+
if: ${{ inputs.ruff-commands == '' }}
24+
run: uv run ruff check
25+
- name: Lint with Ruff (custom)
26+
if: ${{ inputs.ruff-commands != '' }}
27+
run: uv run ruff ${{ inputs.ruff-commands }}

.github/workflows/test-pytest-python.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
description: 'Runner to use'
88
type: string
99
default: 'ubuntu-latest'
10+
pytest-commands:
11+
description: 'pytest commands to run'
12+
type: string
1013

1114
jobs:
1215
run-tests:
@@ -16,5 +19,9 @@ jobs:
1619
uses: actions/checkout@v4
1720
- name: Install UV
1821
uses: astral-sh/setup-uv@v5
19-
- name: Unit test with PyTest
20-
run: uv run pytest tests/
22+
- name: Test with pytest
23+
if: ${{ inputs.pytest-commands == '' }}
24+
run: uv run pytest tests/
25+
- name: Test with pytest (custom)
26+
if: ${{ inputs.pytest-commands != '' }}
27+
run: uv run pytest ${{ inputs.pytest-commands }}

.github/workflows/test-type-mypy-python.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: 'Runner to use'
88
type: string
99
default: 'ubuntu-latest'
10+
mypy-commands:
11+
description: 'mypy commands to run'
12+
required: true
13+
type: string
1014

1115
jobs:
1216
type_check:
@@ -18,4 +22,4 @@ jobs:
1822
uses: astral-sh/setup-uv@v5
1923
- name: Type check with mypy
2024
run: |
21-
uv run mypy src/mypackage --strict
25+
uv run mypy ${{ inputs.mypy-commands }}

0 commit comments

Comments
 (0)