Added test_traj; debloat #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: "CI & CD" | |
on: | |
workflow_dispatch: | |
pull_request: | |
release: | |
types: | |
- published | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
CIBW_BUILD: cp310-* cp311-* cp312-* | |
CIBW_TEST_EXTRAS: test | |
CIBW_TEST_COMMAND: pytest {project} | |
CIBW_DEPENDENCY_VERSIONS: "pinned" | |
# Once GHA and cibuildwheel are updated this can be removed | |
# mussllinux takes 6+ hrs to build and test so ignore it | |
CIBW_TEST_SKIP: "*musllinux* *-macosx_arm64" | |
jobs: | |
lint: | |
name: Check code style | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install ruff | |
run: pip install ruff | |
- name: Check code formatting | |
run: ruff format --diff | |
- name: Lint code base | |
run: ruff check | |
- name: Check for trailing whitespace and newlines at the file ends | |
run: ruff check --preview --select W291,W292,W391 * | |
generate-wheels-matrix: | |
name: "Generate wheels matrix" | |
runs-on: "ubuntu-latest" | |
outputs: | |
include: ${{ steps.set-matrix.outputs.include }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install cibuildwheel | |
# MAKE SURE THIS STAYS IN SYNC WITH THE LOWER GHA cibuildwheel | |
run: pipx install cibuildwheel==2.19.1 | |
- id: set-matrix | |
run: | | |
MATRIX=$( | |
{ | |
cibuildwheel --print-build-identifiers --platform linux \ | |
| jq -nRc '{"dist": inputs, "os": "ubuntu-latest"}' \ | |
&& cibuildwheel --print-build-identifiers --platform macos \ | |
| jq -nRc '{"dist": inputs, "os": "macos-latest"}' \ | |
&& cibuildwheel --print-build-identifiers --platform windows \ | |
| jq -nRc '{"dist": inputs, "os": "windows-latest"}' | |
} | jq -sc | |
) | |
echo "include=$MATRIX" | tee -a $GITHUB_OUTPUT | |
env: | |
CIBW_ARCHS_LINUX: "x86_64" | |
CIBW_ARCHS_MACOS: "x86_64 arm64" | |
CIBW_ARCHS_WINDOWS: "x86 AMD64" | |
# Skip musllinux because it takes too long to compile on GHA | |
# since it is emulated. (6+ hours) | |
# *note* most of the build time is actually numpy for musllinux | |
CIBW_SKIP: "*musllinux* *-manylinux_i686 *-musllinux_i686 *-win32 pp*" | |
test-and-build: | |
name: "Build & Test" | |
needs: "generate-wheels-matrix" | |
strategy: | |
matrix: | |
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
# QEMU enables building/testing for non-native architectures (ie arm64) | |
# at the cost of speed | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Build & (optionally) test wheels | |
# MAKE SURE THIS STAYS IN SYNC WITH THE UPPER pipx call to cibuildwheel | |
uses: pypa/cibuildwheel@v2.19.1 | |
with: | |
only: ${{ matrix.dist }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release-${{ matrix.dist }} | |
path: ./wheelhouse/*.whl | |
make-sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build source distribution | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: release-sdist | |
path: dist//*.tar.gz | |
upload-package: | |
name: Upload package to GitHub Releases & PyPI | |
permissions: | |
contents: write | |
needs: | |
- lint | |
- test-and-build | |
- make-sdist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: release-* | |
merge-multiple: true | |
path: dist | |
- name: List distributions to be uploaded | |
run: ls dist | |
- name: Upload to GitHub Releases | |
uses: softprops/action-gh-release@v2.0.5 | |
if: github.event_name == 'release' && github.event.action == 'published' | |
with: | |
files: dist//* | |
- name: Upload to PyPI | |
uses: pypa/gh-action-pypi-publish@v1.9.0 | |
if: github.event_name == 'release' && github.event.action == 'published' | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} |