-
Notifications
You must be signed in to change notification settings - Fork 2
103 lines (96 loc) · 2.59 KB
/
build-reusable.yml
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
92
93
94
95
96
97
98
99
100
101
102
103
---
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
- name: Type check with Pyright
if: ${{ inputs.lint }}
run: |
pyright hypothesis_torch
- name: Type check with Mypy
if: ${{ inputs.lint }}
run: |
mypy hypothesis_torch
- uses: stefanzweifel/git-auto-commit-action@v5
if: ${{ inputs.lint }}
with:
commit_message: 'style fixes by ruff'
- name: Download example database
uses: dawidd6/action-download-artifact@v6
with:
name: hypothesis-example-db
path: .hypothesis/examples
if_no_artifact_found: warn
workflow_conclusion: completed
- name: Run tests
run: |
set -o pipefail
python -m pytest \
--junitxml=pytest.xml \
--cov-report=term-missing:skip-covered \
--cov=hypothesis_torch \
tests | tee pytest-coverage.txt
- name: Upload example database
uses: actions/upload-artifact@v3
if: always()
with:
name: hypothesis-example-db
path: .hypothesis/examples
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml