-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: convert workflow to reusable workflow for simplicity
- Loading branch information
1 parent
46e3516
commit b1aa17a
Showing
2 changed files
with
84 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
name: Lint and Test | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
description: 'Python version' | ||
required: true | ||
type: string | ||
lint: | ||
description: 'Run linter' | ||
required: false | ||
default: false | ||
type: boolean | ||
torch-version: | ||
description: 'PyTorch version' | ||
required: false | ||
default: '' | ||
type: string | ||
|
||
env: | ||
HYPOTHESIS_PROFILE: "ci" | ||
UV_SYSTEM_PYTHON: "true" | ||
|
||
permissions: | ||
contents: write | ||
checks: write | ||
pull-requests: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
id: cache-uv | ||
with: | ||
path: ~/.cache/uv | ||
key: ${{ runner.os }}-python-${{ inputs.python-version }}-uv | ||
- name: Set up Python ${{ inputs.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
- name: Install uv | ||
run: | | ||
python -m pip install --upgrade uv | ||
- name: Install Specific PyTorch version | ||
if: ${{ inputs.torch-version != '' }} | ||
run: | | ||
uv pip install torch==${{ inputs.torch-version }} | ||
- name: Install dependencies | ||
run: | | ||
uv pip install ".[dev,huggingface]" | ||
- name: Lint with ruff | ||
if: ${{ inputs.lint }} | ||
run: | | ||
ruff check --fix | ||
- name: Format with ruff | ||
if: ${{ inputs.lint }} | ||
run: | | ||
ruff format | ||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
if: ${{ inputs.lint }} | ||
with: | ||
commit_message: 'style fixes by ruff' | ||
- name: Run tests | ||
run: | | ||
python -m pytest \ | ||
--junitxml=pytest.xml \ | ||
--cov-report=term-missing:skip-covered \ | ||
--cov=hypothesis_torch \ | ||
tests \ | ||
| tee pytest-coverage.txt | ||
- name: Pytest coverage comment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
pytest-coverage-path: ./pytest-coverage.txt | ||
junitxml-path: ./pytest.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters