-
Notifications
You must be signed in to change notification settings - Fork 66
129 lines (109 loc) · 3.58 KB
/
test.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Tests
on:
push:
branches: [main]
pull_request:
release:
types: [published]
workflow_dispatch:
inputs:
task:
type: choice
options: [tests, release, test-release]
default: tests
description: Run tests, release to PyPI, or release to TestPyPI.
jobs:
tests:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
python-version: ["3.10", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install uv
run: pip install uv
- name: Install dependencies
run: |
uv pip install cython --system
python setup.py build_ext --inplace
uv pip install -e .[test] --system
# TODO remove next line installing ase from main branch when FrechetCellFilter is released
uv pip install --upgrade 'ase@git+https://gitlab.com/ase/ase' --system
- name: Run Tests
run: pytest --capture=no --cov --cov-report=xml
env:
CHGNET_DEVICE: cpu
- name: Codacy coverage reporter
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'push' }}
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
build_source_dist:
name: Build source distribution
needs: tests
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
steps:
- name: Check out repo
uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.10"
- name: Build source distribution
run: |
pip install build
python -m build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build_wheels:
name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.os }}
needs: tests
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.task == 'release')
strategy:
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
python-version: ["39", "310", "311", "312"]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp${{ matrix.python-version }}-*
CIBW_ARCHS_MACOS: universal2
- name: Save artifact
uses: actions/upload-artifact@v3
with:
path: wheelhouse
release:
name: Release wheels and source distribution to PyPI
needs: [build_wheels, build_source_dist]
runs-on: ubuntu-latest
permissions:
# For pypi trusted publishing
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish to PyPi or TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
repository-url: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.task == 'test-release' && 'https://test.pypi.org/legacy/' || '' }}