| 1 |
--- |
| 2 |
name: dist |
| 3 |
|
| 4 |
on: |
| 5 |
pull_request: |
| 6 |
push: |
| 7 |
branches: |
| 8 |
- main |
| 9 |
tags: |
| 10 |
- '*' |
| 11 |
|
| 12 |
concurrency: |
| 13 |
group: ${{ github.ref }} |
| 14 |
cancel-in-progress: true |
| 15 |
|
| 16 |
jobs: |
| 17 |
check: |
| 18 |
runs-on: ubuntu-latest |
| 19 |
steps: |
| 20 |
- uses: actions/checkout@v3 |
| 21 |
- uses: psf/black@stable |
| 22 |
|
| 23 |
check-mypy: |
| 24 |
runs-on: ubuntu-latest |
| 25 |
steps: |
| 26 |
- uses: actions/checkout@v3 |
| 27 |
# - uses: jpetrucciani/[email protected] |
| 28 |
# .. can't use that because we need to install pytest |
| 29 |
- uses: actions/setup-python@v4 |
| 30 |
with: |
| 31 |
python-version: 3.8 |
| 32 |
- name: Install requirements |
| 33 |
run: | |
| 34 |
pip --disable-pip-version-check install mypy pytest pcpp |
| 35 |
- name: Run mypy |
| 36 |
run: | |
| 37 |
mypy . |
| 38 |
|
| 39 |
check-doc: |
| 40 |
runs-on: ubuntu-22.04 |
| 41 |
|
| 42 |
steps: |
| 43 |
- uses: actions/checkout@v3 |
| 44 |
with: |
| 45 |
submodules: recursive |
| 46 |
fetch-depth: 0 |
| 47 |
|
| 48 |
- uses: actions/setup-python@v4 |
| 49 |
with: |
| 50 |
python-version: 3.8 |
| 51 |
- name: Sphinx |
| 52 |
run: | |
| 53 |
pip --disable-pip-version-check install -e . |
| 54 |
pip --disable-pip-version-check install -r docs/requirements.txt |
| 55 |
cd docs && make clean html SPHINXOPTS="-W --keep-going" |
| 56 |
|
| 57 |
# |
| 58 |
# Build a wheel |
| 59 |
# |
| 60 |
|
| 61 |
build: |
| 62 |
runs-on: ubuntu-22.04 |
| 63 |
steps: |
| 64 |
- uses: actions/checkout@v3 |
| 65 |
with: |
| 66 |
submodules: recursive |
| 67 |
fetch-depth: 0 |
| 68 |
|
| 69 |
- uses: actions/setup-python@v4 |
| 70 |
with: |
| 71 |
python-version: 3.8 |
| 72 |
|
| 73 |
- run: pipx run build |
| 74 |
|
| 75 |
- name: Upload build artifacts |
| 76 |
uses: actions/upload-artifact@v3 |
| 77 |
with: |
| 78 |
name: dist |
| 79 |
path: dist |
| 80 |
|
| 81 |
test: |
| 82 |
needs: [build] |
| 83 |
runs-on: ${{ matrix.os }} |
| 84 |
strategy: |
| 85 |
matrix: |
| 86 |
os: [windows-latest, macos-latest, ubuntu-20.04] |
| 87 |
python_version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11", "3.12"] |
| 88 |
architecture: [x86, x64] |
| 89 |
exclude: |
| 90 |
- os: macos-latest |
| 91 |
architecture: x86 |
| 92 |
- os: ubuntu-20.04 |
| 93 |
architecture: x86 |
| 94 |
|
| 95 |
steps: |
| 96 |
- uses: actions/checkout@v3 |
| 97 |
with: |
| 98 |
submodules: recursive |
| 99 |
fetch-depth: 0 |
| 100 |
|
| 101 |
- uses: actions/setup-python@v4 |
| 102 |
with: |
| 103 |
python-version: ${{ matrix.python_version }} |
| 104 |
architecture: ${{ matrix.architecture }} |
| 105 |
|
| 106 |
- name: Download build artifacts |
| 107 |
uses: actions/download-artifact@v3 |
| 108 |
with: |
| 109 |
name: dist |
| 110 |
path: dist |
| 111 |
|
| 112 |
- name: Install test dependencies |
| 113 |
run: python -m pip --disable-pip-version-check install -r tests/requirements.txt |
| 114 |
|
| 115 |
- name: Setup MSVC compiler |
| 116 |
uses: ilammy/msvc-dev-cmd@v1 |
| 117 |
if: matrix.os == 'windows-latest' |
| 118 |
|
| 119 |
- name: Test wheel |
| 120 |
shell: bash |
| 121 |
run: | |
| 122 |
cd dist |
| 123 |
python -m pip --disable-pip-version-check install *.whl |
| 124 |
cd ../tests |
| 125 |
python -m pytest |
| 126 |
|
| 127 |
publish: |
| 128 |
runs-on: ubuntu-latest |
| 129 |
needs: [check, check-mypy, check-doc, test] |
| 130 |
permissions: |
| 131 |
id-token: write |
| 132 |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 133 |
|
| 134 |
steps: |
| 135 |
- name: Download build artifacts |
| 136 |
uses: actions/download-artifact@v3 |
| 137 |
with: |
| 138 |
name: dist |
| 139 |
path: dist |
| 140 |
|
| 141 |
- name: Publish to PyPI |
| 142 |
uses: pypa/gh-action-pypi-publish@release/v1 |