-
Notifications
You must be signed in to change notification settings - Fork 74
111 lines (110 loc) · 3.72 KB
/
test.yml
File metadata and controls
111 lines (110 loc) · 3.72 KB
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
name: Test
on:
pull_request:
types:
- opened
- synchronize
push:
branches:
- main
tags:
- '*'
jobs:
test:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
compiler: ["default", "mingw", "msvc"]
exclude:
# MinGW and MSVC are Windows-only
- os: "ubuntu-latest"
compiler: "mingw"
- os: "ubuntu-latest"
compiler: "msvc"
- os: "macos-latest"
compiler: "mingw"
- os: "macos-latest"
compiler: "msvc"
- os: "windows-latest"
compiler: "default"
name: Test (${{ matrix.python-version }}, ${{ matrix.os }}${{ matrix.os == 'windows-latest' && format(', {0}', matrix.compiler) || '' }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'pwsh' || 'bash -l {0}' }}
steps:
- uses: actions/checkout@v6
- uses: conda-incubator/setup-miniconda@v3
with:
channels: conda-forge
conda-remove-defaults: true
activate-environment: cppimport
environment-file: environment.yml
python-version: ${{ matrix.python-version }}
- name: Install MinGW-w64 compiler (Windows MinGW)
if: ${{ matrix.os == 'windows-latest' && matrix.compiler == 'mingw' }}
run: |
conda install -y -c conda-forge gxx_win-64
- name: Install cppimport
run: |
pip install --no-deps -e .
- name: Lint with flake8
run: |
flake8 .
- name: Check formatting with black
run: |
black --check .
- name: Check import ordering with isort
run: |
isort --check .
- name: Test (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run: |
CFLAGS='-stdlib=libc++' pytest --cov=./ --cov-report=xml
- name: Test (Windows MinGW)
if: ${{ matrix.os == 'windows-latest' && matrix.compiler == 'mingw' }}
run: |
pytest --cov=./ --cov-report=xml
- name: Test (Windows MSVC)
if: ${{ matrix.os == 'windows-latest' && matrix.compiler == 'msvc' }}
run: |
pytest --cov=./ --cov-report=xml
- name: Test (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
pytest --cov=./ --cov-report=xml
build-and-publish:
# based on https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# also see: https://github.com/marketplace/actions/pypi-publish#advanced-release-management
needs: test
name: Build and publish Python distributions to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: conda-incubator/setup-miniconda@v3
with:
channels: conda-forge
conda-remove-defaults: true
activate-environment: cppimport
environment-file: environment.yml
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Build sdist
run: >-
pip install build && python -m build --sdist
- name: Publish distribution 📦 to TestPyPI
if: github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}