Skip to content

temporarily make tests shorter #139

temporarily make tests shorter

temporarily make tests shorter #139

Workflow file for this run

name: CI
on:
push:
branches:
- main
tags:
- '**'
pull_request: {}
jobs:
test-py:
name: test ${{ matrix.python-version }} on ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
# os: [ubuntu, macos, windows]
os: [ubuntu]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
runs-on: ${{ matrix.os }}-latest
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: install rust
uses: dtolnay/rust-toolchain@nightly
- id: cache-rust
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
# TODO: some actual testing!
- run: pip install -vvv -e .
test-rust:
name: test against ${{ matrix.rust-toolchain }} rust
strategy:
fail-fast: true
matrix:
rust-toolchain: ['stable', 'nightly']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install --upgrade pip
- name: install rust ${{ matrix.rust-toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-toolchain }}
- id: cache-rust-tests
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
- name: test rust
run: cargo test
lint-rust:
name: perform rust lint and style checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install --upgrade pip
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- id: cache-rust-lint
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
- name: fmt rust
run: cargo fmt --check
- name: clippy rust
run: cargo clippy
lint-py:
name: perform python lint and style checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install --upgrade pip
- uses: isort/isort-action@master
with:
sortPaths: "py"
check-versions:
name: ensure package versions all correspond to the most recent tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install --upgrade pip
- run: sudo apt install jq
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: extract python setup requires in order to extract the version (lol)
run: |
python -c 'import tomllib; t = tomllib.load(open("pyproject.toml", "rb")); print("\n".join(t["build-system"]["requires"]));' > build-requires.txt
pip install -r build-requires.txt
- name: extract all the versions from across the repo
run: |
set -o pipefail
git describe --tags --abbrev=0 > latest-tag.version
printf 'v%s\n' "$(python setup.py --dry-run --version 2>/dev/null)" > pypi-medusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "libmedusa-zip") | "v" + .version' > libmedusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "pymedusa-zip") | "v" + .version' > pymedusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "medusa-zip") | "v" + .version' > cli-medusa-zip.version
cargo metadata --format-version 1 | jq -r '.packages[] | .dependencies[] | select(.name == "libmedusa-zip") | .req' | sed -re 's#^\^#v#' > internal-deps.version
- name: check that all the versions match up across the workspace
run: |
num_separate_versions="$(cat *.version | sort -u | wc -l)"
if [[ "$num_separate_versions" -gt 1 ]]; then
echo '::error::versions are out of sync:'
for f in *.version; do
echo "::error::${f} => $(<"$f" tr '\n' ',' | sed -re "s#,\$#\n#")"
done
exit 1
fi
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [test-py, test-rust, lint-rust, lint-py, check-versions]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
build-sdist:
name: Build source distribution
# NB: we have decided that releases are tags starting with a 'v'!
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
name: sdist-artifact
path: dist/*.tar.gz
if-no-files-found: error
build-bdists-ubuntu:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }}/${{ matrix.libc-type }} on linux
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
python-version: ['37', '38', '39', '310', '311']
py-impl: ['cp', 'pp']
libc-type: ['manylinux', 'musllinux']
exclude:
# PyPy does not appear to support musl: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
libc-type: musllinux
# PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
python-version: 311
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install --upgrade pip
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-${{ matrix.libc-type }}*
- uses: actions/upload-artifact@v3
with:
name: linux-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
build-bdists-macos-x86_64:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }} on macos x86_64
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
python-version: ['37', '38', '39', '310', '311']
py-impl: ['cp', 'pp']
exclude:
# PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
python-version: 311
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install --upgrade pip
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_MACOS: x86_64
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-*
- uses: actions/upload-artifact@v3
with:
name: macos-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
build-bdists-macos-arm64:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }} on macos arm64
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
# "Only CPython 3.8 and newer support universal2 and arm64 wheels."
# See https://cibuildwheel.readthedocs.io/en/stable/faq/#how-to-cross-compile
python-version: ['38', '39', '310', '311']
py-impl: ['cp']
# PyPy currently cannot be built for arm64 on macos! We get this extremely obtuse and frustrating error when we try:
# https://github.com/pypa/cibuildwheel/blob/4135c0a01dc11910ce118f58acc7caf4ac5c524a/cibuildwheel/macos.py#L92-L112
# py-impl: ['cp', 'pp']
# exclude:
# # PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
# - py-impl: pp
# python-version: 311
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- run: pip install --upgrade pip
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_MACOS: arm64
# This target isn't added by the rustup command in tool.cibuildwheel.before-all.
CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-*
- uses: actions/upload-artifact@v3
with:
name: macos-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
build-bdists-windows:
name: build bdist for ${{ matrix.python-version }}/${{ matrix.py-impl }}/${{ matrix.arch }} on windows
# run on releases, and on PRs with the label 'Full Build'
if: success() && (startsWith(github.ref, 'refs/tags/') || contains(github.event.pull_request.labels.*.name, 'Full Build'))
strategy:
fail-fast: true
matrix:
python-version: ['37', '38', '39', '310', '311']
py-impl: ['cp', 'pp']
arch: ['AMD64']
# FIXME: figure out how to get ARM64 windows builds working!
# arch: ['AMD64', 'ARM64']
exclude:
# PyPy only goes up to 3.10: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
- py-impl: pp
python-version: 311
# FIXME: figure out how to get ARM64 windows builds working!
# Windows does not support ARM64 until 3.8: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
# - python-version: 37
# arch: ARM64
# - python-version: 38
# arch: ARM64
# # Windows PyPy does not support ARM64: https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip.
# - py-impl: pp
# arch: ARM64
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: build wheels
uses: pypa/cibuildwheel@v2.14.1
env:
CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.py-impl }}${{ matrix.python-version }}-win_${{ matrix.arch }}
# CIBW_BEFORE_ALL: "rmdir C:\\Users\\runneradmin\\.cargo /s /q && curl.exe --url https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe --output rustup-init.exe && .\\rustup-init.exe --default-toolchain nightly --default-host aarch64-pc-windows-msvc -y && rustup.exe target add aarch64-pc-windows-msvc"
- uses: actions/upload-artifact@v3
with:
name: windows-bdist-artifacts
path: ./wheelhouse/*.whl
if-no-files-found: error
upload-pypi-assets:
name: upload it to pypi
# NB: we have decided that releases are tags starting with a 'v'!
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [check, build-sdist, build-bdists-ubuntu, build-bdists-macos-x86_64, build-bdists-macos-arm64, build-bdists-windows]
environment: pypi
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: get sdist artifact
uses: actions/download-artifact@v3
with:
name: sdist-artifact
path: dist
- name: get linux bdist artifacts
uses: actions/download-artifact@v3
with:
name: linux-bdist-artifacts
path: dist
- name: get macos bdist artifacts
uses: actions/download-artifact@v3
with:
name: macos-bdist-artifacts
path: dist
- name: get windows bdist artifacts
uses: actions/download-artifact@v3
with:
name: windows-bdist-artifacts
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
publish-cargo-packages:
name: publish cargo packages
# NB: we have decided that releases are tags starting with a 'v'!
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [check]
environment: crates-io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly
- id: cache-rust-publish
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
- env:
CARGO_REGISTRY_TOKEN: ${{ secrets.MEDUSA_ONLY_TOKEN }}
run: |
cargo publish -p libmedusa-zip
cargo publish -p pymedusa-zip
cargo publish -p medusa-zip