-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (106 loc) · 3.68 KB
/
Copy pathpython-package.yml
File metadata and controls
124 lines (106 loc) · 3.68 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
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Python Package
# Builds the naja-schematic wheel/sdist (Python backend + the WASM viewer
# bundle), tests it against published najaeda, and on a `v<version>`
# tag publishes it to PyPI.
#
# Publishing uses PyPI trusted publishing (no token): the PyPI project must
# list this repository, this workflow file and the `pypi` environment as a
# trusted publisher.
on:
push:
branches: [ main ]
tags: [ "v*" ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
# imgui for the build, naja only for its version header
# (CMakeLists.txt reads NajaVersion.h.in); not recursive.
submodules: true
- name: Set up Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: latest
- name: Build the viewer bundle
run: |
emcmake cmake -S . -B build-wasm-module \
-DCMAKE_BUILD_TYPE=Release \
-DNAJA_SCHEMATIC_WASM_MODULE=ON
cmake --build build-wasm-module -j
cp build-wasm-module/naja-schematic.js python/naja_schematic/static/
cp LICENSE python/LICENSE
- name: Check the tag matches the package version
if: startsWith(github.ref, 'refs/tags/v')
run: |
version=$(sed -n 's/^__version__ = "\(.*\)"$/\1/p' python/naja_schematic/__init__.py)
test "v$version" = "${GITHUB_REF_NAME}" || {
echo "Tag ${GITHUB_REF_NAME} does not match __version__ $version"; exit 1; }
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheel and sdist
run: |
python -m pip install build
python -m build python --outdir dist
- name: Check the bundle is in both archives
run: |
unzip -l dist/*.whl | grep -q 'naja_schematic/static/naja-schematic.js'
tar tzf dist/*.tar.gz | grep -q 'naja_schematic/static/naja-schematic.js'
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
python-version: [ "3.10", "3.13" ]
# Oldest najaeda the package declares support for, and the newest.
najaeda: [ "==0.7.25", "" ]
steps:
- name: Checkout code
uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Install the built wheel
shell: bash
run: |
python -m pip install "$(ls dist/*.whl)[test]" "najaeda${{ matrix.najaeda }}"
- name: Run tests against the installed package
# From outside python/, so the tests import the installed wheel
# rather than the source tree.
working-directory: ${{ runner.temp }}
run: python -m pytest -v ${{ github.workspace }}/python/tests
- name: Smoke-test the CLI
shell: bash
run: |
echo '{"request":"load_root"}' \
| naja-schematic --xilinx --verilog python/tests/data/design.v --stdio \
| grep -q '"root_response"'
publish:
needs: [ build, test ]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1