-
Notifications
You must be signed in to change notification settings - Fork 9
96 lines (92 loc) · 2.68 KB
/
python.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
name: python
on:
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
release:
types:
- published
permissions:
contents: read # Required when overriding permissions
pull-requests: write # For posting coverage report
checks: write
# Newer commits should cancel old runs
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
black:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--check -v"
src: "python/neml2 python/tests"
build-test:
name: Build and test Python bindings
needs: black
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: "3.28"
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Install PyTorch
run: pip install torch==2.2.2
- run: pip install -v .
- run: pytest --junitxml=pytest.xml python/tests
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: matrix.os == 'ubuntu-latest'
with:
files: pytest.xml
check_name: Python Binding Test Results (${{ matrix.os }})
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: matrix.os == 'macos-12'
with:
files: pytest.xml
check_name: Python Binding Test Results (${{ matrix.os }})
sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build SDist
run: pipx run build --sdist
- name: Upload SDist
uses: actions/upload-artifact@v4
if: github.event_name == 'release' && github.event.action == 'published'
with:
name: package-sdist
path: dist/*.tar.gz
PyPI:
needs: sdist
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: package-sdist
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1