Skip to content

Commit a87f59f

Browse files
committed
consolidate workflows, add cargo release step and create release pixi env
1 parent 07a21fc commit a87f59f

6 files changed

Lines changed: 163 additions & 232 deletions

File tree

.github/workflows/build_and_test.yaml

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -8,107 +8,4 @@ concurrency:
88

99
jobs:
1010
build-and-test:
11-
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os.base }}-${{ matrix.os.version }}
12-
strategy:
13-
fail-fast: false
14-
# NOTE: In the matrix below, we call out macos 15 and latest (> 15) explicitly. This is to enable running on both Intel and Apple Silicon for Mac.
15-
matrix:
16-
os:
17-
- base: ubuntu
18-
version: latest
19-
- base: macos
20-
version: "15-intel"
21-
arch: "x86_64"
22-
- base: macos
23-
version: "latest"
24-
arch: "arm64"
25-
- base: windows
26-
version: latest
27-
arch: "amd64"
28-
python-version:
29-
# https://devguide.python.org/versions/#status-of-python-versions
30-
- "10"
31-
- "11"
32-
- "12"
33-
- "13"
34-
- "14"
35-
# - "15" # Re-enable when py315 pixi environment can be solved across platforms
36-
include:
37-
- os:
38-
base: ubuntu
39-
version: latest
40-
platform: linux
41-
- os:
42-
base: windows
43-
version: latest
44-
ls: dir
45-
runs-on: ${{ format('{0}-{1}', matrix.os.base, matrix.os.version) }}
46-
env:
47-
CARGO_HTTP_MULTIPLEXING: "false"
48-
steps:
49-
- uses: actions/checkout@v4
50-
51-
- name: Set up Pixi
52-
uses: prefix-dev/setup-pixi@v0.8.14
53-
with:
54-
environments: py3${{ matrix.python-version }}
55-
56-
- name: Check version consistency
57-
if: matrix.os.base == 'ubuntu' && matrix.python-version == '11'
58-
run: pixi run -e py3${{ matrix.python-version }} python python/fastsim/utils/check_versions.py
59-
60-
- name: Update minimum supported MacOS for Wheels for MacOS 15-intel (Intel Mac)
61-
run: echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV
62-
if: matrix.os.base == 'macos' && matrix.os.version == '15-intel'
63-
64-
- name: run cargo tests
65-
run: pixi run -e py3${{ matrix.python-version }} cargo test --release
66-
67-
- name: install python dependencies
68-
run: pixi run -e py3${{ matrix.python-version }} python -m pip install --upgrade pip setuptools wheel twine cibuildwheel pytest
69-
70-
- name: build source distribution
71-
if: matrix.os.base == 'ubuntu' && matrix.python-version == '10'
72-
run: |
73-
pixi run -e py3${{ matrix.python-version }} python -m pip install -U setuptools-rust
74-
pixi run -e py3${{ matrix.python-version }} python -c "import setuptools; setuptools.setup()" sdist
75-
76-
- name: install FASTSim python
77-
run: pixi run -e py3${{ matrix.python-version }} python -m pip install --group test .
78-
79-
- name: run pytest
80-
timeout-minutes: 20
81-
run: pixi run -e py3${{ matrix.python-version }} pytest -v
82-
83-
- name: build ${{ matrix.platform || matrix.os.base }} binaries
84-
run: pixi run -e py3${{ matrix.python-version }} cibuildwheel --output-dir dist
85-
env:
86-
CIBW_BUILD: "cp3${{ matrix.python-version }}-*"
87-
CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64"
88-
CIBW_PLATFORM: ${{ matrix.platform || matrix.os.base }}
89-
CIBW_TEST_REQUIRES: pytest
90-
CIBW_TEST_COMMAND: "pytest {project}/python/fastsim/tests"
91-
CIBW_ARCHS_MACOS: "${{ matrix.os.arch }}"
92-
# see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2
93-
CIBW_TEST_SKIP: "*_universal2:arm64"
94-
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
95-
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
96-
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
97-
CIBW_MANYLINUX_I686_IMAGE: "manylinux2014"
98-
CIBW_BEFORE_BUILD: >
99-
pip install -U setuptools-rust &&
100-
rustup default stable &&
101-
rustup show
102-
CIBW_BEFORE_BUILD_LINUX: >
103-
yum -y install openssl openssl-devel &&
104-
pip install -U setuptools-rust &&
105-
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y &&
106-
rustup show
107-
108-
- name: list dist files
109-
run: ${{ matrix.ls || 'ls -lh' }} dist/
110-
111-
- uses: actions/upload-artifact@v4
112-
with:
113-
name: fastsim-${{ matrix.platform || matrix.os.base }}-${{ matrix.os.version }}-py3.${{ matrix.python-version }}-${{ strategy.job-index }}
114-
path: ./dist/*
11+
uses: ./.github/workflows/shared_build_test.yaml

.github/workflows/release.yaml

Lines changed: 29 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,65 @@
1-
name: release
1+
name: Release
22

33
on:
44
release:
55
types: [published]
66
workflow_dispatch:
77

8-
# NOTE: parts inspired by https://cibuildwheel.pypa.io/en/stable/setup/
9-
108
jobs:
119
build:
12-
name: build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
13-
strategy:
14-
fail-fast: true
15-
matrix:
16-
os:
17-
- ubuntu-latest
18-
- macos-15-intel # Intel runner
19-
- macos-latest # Apple Silicon runner
20-
- windows-latest
21-
python-version:
22-
- "10"
23-
- "11"
24-
- "12"
25-
include:
26-
- os: ubuntu-latest
27-
platform: linux
28-
- os: windows-latest
29-
ls: dir
30-
31-
env:
32-
FASTSIM_DISABLE_NETWORK_TESTS: 1
33-
34-
runs-on: ${{ matrix.os }}
35-
steps:
36-
- uses: actions/checkout@v4
37-
38-
- name: set up rust
39-
uses: dtolnay/rust-toolchain@stable
40-
41-
- name: install rust target for MacOS 14+ (Apple Silicon)
42-
run: rustup target add aarch64-apple-darwin
43-
if: matrix.os == 'macos-latest'
44-
45-
- name: install rust target for MacOS 15-intel (Intl Mac)
46-
run: rustup target add x86_64-apple-darwin aarch64-apple-darwin
47-
if: matrix.os == 'macos-15-intel'
48-
49-
- name: set up Python
50-
uses: actions/setup-python@v4
51-
# uses: actions/setup-python@v5
52-
with:
53-
python-version: "3.${{ matrix.python-version }}"
54-
55-
- name: run cargo tests
56-
run: cargo test
57-
58-
- name: Upgrade to latest pip
59-
run: python -m pip install --upgrade pip
60-
61-
- name: install Python dependencies
62-
run: python -m pip install --upgrade setuptools wheel twine cibuildwheel pytest
63-
64-
- name: build source distribution
65-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '10'
66-
run: |
67-
pip install -U setuptools-rust
68-
python -c "import setuptools; setuptools.setup()" sdist
69-
70-
- name: Update minimum supported MacOS for Wheels for MacOS 15-intel (Intel Mac)
71-
run: echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV
72-
if: matrix.os == 'macos-15-intel'
73-
74-
- name: build ${{ matrix.platform || matrix.os }} binaries
75-
uses: pypa/cibuildwheel@v2.22.0
76-
env:
77-
CIBW_BUILD: "cp3${{ matrix.python-version }}-*"
78-
CIBW_SKIP: "*-win32 *-musllinux* *i686 *ppc64le *s390x *aarch64"
79-
# CIBW_PLATFORM: ${{ matrix.platform || matrix.os }}
80-
# TODO: why doesn't pytest work with cibuildwheel?
81-
# CIBW_TEST_COMMAND: "pytest -v {project}/python/fastsim/tests"
82-
CIBW_TEST_COMMAND: "python -m unittest discover {project}/python/fastsim/tests"
83-
# CIBW_ARCHS_MACOS: "universal2"
84-
# see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2
85-
CIBW_TEST_SKIP: "*_universal2:arm64"
86-
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
87-
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
88-
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
89-
CIBW_MANYLINUX_I686_IMAGE: "manylinux2014"
90-
CIBW_BEFORE_BUILD: >
91-
pip install -U setuptools-rust &&
92-
rustup default stable &&
93-
rustup show
94-
CIBW_BEFORE_BUILD_LINUX: >
95-
yum -y install openssl openssl-devel &&
96-
pip install -U setuptools-rust &&
97-
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y &&
98-
rustup show
99-
CIBW_BEFORE_BUILD_MACOS: >
100-
rustup target add x86_64-apple-darwin
101-
# - name: build windows 32bit binaries
102-
# if: matrix.os == 'windows'
103-
# run: cibuildwheel --output-dir dist
104-
# env:
105-
# CIBW_BUILD: 'cp3${{ matrix.python-version }}-win32'
106-
# CIBW_PLATFORM: windows
107-
# CIBW_TEST_REQUIRES: 'pytest'
108-
# CIBW_TEST_COMMAND: 'pytest {project}/tests -s'
109-
# CIBW_ENVIRONMENT: 'PATH="$UserProfile\.cargo\bin;$PATH"'
110-
# CIBW_BEFORE_BUILD: >
111-
# pip install -U setuptools-rust &&
112-
# rustup toolchain install nightly-i686-pc-windows-msvc &&
113-
# rustup default nightly-i686-pc-windows-msvc &&
114-
# rustup override set nightly-i686-pc-windows-msvc &&
115-
# rustup show
116-
117-
- name: list wheelhouse files
118-
run: ${{ matrix.ls || 'ls -lh' }} ./wheelhouse/
119-
120-
- uses: actions/upload-artifact@v4
121-
with:
122-
name: artifact-py3.${{ matrix.python-version }}-${{ matrix.os }}-${{ strategy.job-index }}
123-
path: ./wheelhouse/*.whl
10+
uses: ./.github/workflows/reusable_build.yaml
12411

12512
release:
12613
needs: build
127-
name: release files to PyPI
14+
name: Publish release artifacts
12815
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
shell: pixi run -e release bash -e {0}
12919
# Protection Strategies -- use ONE of the following two lines:
13020
# publish on via explicit publish
13121
if: github.event_name == 'release' && github.event.action == 'published'
13222
# publish on tag starting w/ 'v'
13323
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
13424
steps:
135-
- name: download files
25+
- uses: actions/checkout@v4
26+
27+
- name: Download files
13628
uses: actions/download-artifact@v4
13729
with:
13830
merge-multiple: true
13931
path: artifact
14032

141-
- name: set up Python 3.11
142-
uses: actions/setup-python@v4
33+
- name: Set up Pixi
34+
uses: prefix-dev/setup-pixi@v0.8.14
14335
with:
144-
python-version: "3.11"
36+
environments: release
14537

146-
- run: pip install twine
38+
- name: Check distribution with Twine
39+
run: python -m twine check ./artifact/*
14740

148-
- run: twine check ./artifact/*
41+
- name: Dry-run Rust crate publish
42+
run: |
43+
cargo publish --manifest-path fastsim-core/fastsim-proc-macros/Cargo.toml --locked --dry-run
44+
cargo publish --manifest-path fastsim-core/Cargo.toml --locked --dry-run
45+
# cargo publish --manifest-path fastsim-cli/Cargo.toml --locked --dry-run
14946

15047
- name: Publish distribution to Test PyPI
151-
run: twine upload -r testpypi ./artifact/*
48+
run: python -m twine upload -r testpypi ./artifact/*
15249
env:
15350
TWINE_USERNAME: __token__
15451
TWINE_PASSWORD: ${{ secrets.FASTSIM_TEST_PYPI_TOKEN }}
15552

53+
- name: Publish Rust crates to crates.io
54+
run: |
55+
cargo publish --manifest-path fastsim-core/fastsim-proc-macros/Cargo.toml --locked
56+
cargo publish --manifest-path fastsim-core/Cargo.toml --locked
57+
# cargo publish --manifest-path fastsim-cli/Cargo.toml --locked
58+
env:
59+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
60+
15661
- name: Upload files to PyPI
157-
run: twine upload ./artifact/*
62+
run: python -m twine upload ./artifact/*
15863
env:
15964
TWINE_USERNAME: __token__
16065
TWINE_PASSWORD: ${{ secrets.fastsim_pypi_token }}

0 commit comments

Comments
 (0)