diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml deleted file mode 100644 index 483fd60..0000000 --- a/.github/workflows/Build.yml +++ /dev/null @@ -1,149 +0,0 @@ -on: [push, pull_request] - -name: Build - -jobs: - macos: - runs-on: macos-latest - strategy: - matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: aarch64-apple-darwin - profile: minimal - default: true - - name: Build - run: cargo build --release - - name: Build wheels - x86_64 - uses: messense/maturin-action@v1 - with: - target: x86_64 - args: -i python --release --out dist --sdist - - name: Install built wheel - x86_64 - run: | - pip install python-calamine --no-index --find-links dist --force-reinstall - - name: Build wheels - universal2 - if: ${{ matrix.python-version != '3.7' }} - uses: messense/maturin-action@v1 - with: - args: -i python --release --universal2 --out dist - - name: Install built wheel - universal2 - if: ${{ matrix.python-version != '3.7' }} - run: | - pip install python-calamine --no-index --find-links dist --force-reinstall - - name: Python UnitTest - run: | - pip install pytest - pytest - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: dist - - windows: - runs-on: windows-latest - strategy: - matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - target: [x64, x86] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - architecture: ${{ matrix.target }} - - name: Update rustup - run: rustup self update - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build - if: matrix.target == 'x64' - run: cargo build --release - - name: Build wheels - uses: messense/maturin-action@v1 - with: - target: ${{ matrix.target }} - args: -i python --release --out dist - - name: Install built wheel - run: | - pip install python-calamine --no-index --find-links dist --force-reinstall - - name: Python UnitTest - run: | - pip install pytest - pytest - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: dist - - linux: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - target: [x86_64, i686] - steps: - - uses: actions/checkout@v2 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build - run: cargo build --release - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Build Wheels - uses: messense/maturin-action@v1 - with: - target: ${{ matrix.target }} - manylinux: auto - args: -i python${{ matrix.python-version }} --release --out dist - - name: Python UnitTest - if: matrix.target == 'x86_64' - run: | - pip install python-calamine --no-index --find-links dist --force-reinstall - rm -rf python_calamine - pip install pytest - pytest - - name: Upload wheels - uses: actions/upload-artifact@v2 - with: - name: wheels - path: dist - - release: - name: Release - runs-on: ubuntu-latest - if: "startsWith(github.ref, 'refs/tags/')" - needs: [ macos, windows, linux ] - steps: - - uses: actions/download-artifact@v2 - with: - name: wheels - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Publish to PyPi - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - pip install --upgrade twine - twine upload --skip-existing * diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..56f5f15 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,252 @@ +# some code from https://github.com/pydantic/pydantic-core/blob/d6e7890b36ef21cb28180a7f5b1479da2319012d/.github/workflows/ci.yml +# MIT License, see author list by link + +name: CI + +on: + push: + branches: + - main + tags: + - "**" + pull_request: {} + +jobs: + test: + name: test ${{ matrix.python-version }} rust stable + strategy: + fail-fast: false + matrix: + python-version: + - "3.7" + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "pypy3.7" + - "pypy3.8" + - "pypy3.9" + + runs-on: ubuntu-latest + + env: + PYTHON: ${{ matrix.python-version }} + + steps: + - uses: actions/checkout@v3 + + - run: rm rust-toolchain + + - name: install rust stable + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - id: cache-rust + name: cache rust + uses: Swatinem/rust-cache@v2 + with: + key: v3 + + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - id: cache-py + name: cache python + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: > + py + ${{ runner.os }} + ${{ env.pythonLocation }} + - run: pip install pytest + if: steps.cache-py.outputs.cache-hit != 'true' + + - run: pip install -e . + env: + RUST_BACKTRACE: 1 + + - run: pip freeze + + - run: pytest + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - run: rm rust-toolchain + - name: install rust stable + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: cache rust + uses: Swatinem/rust-cache@v2 + + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - uses: actions/cache@v2 + id: cache-py + name: cache python + with: + path: ${{ env.pythonLocation }} + key: > + py + ${{ env.pythonLocation }} + - run: pip install black flake8 isort + if: steps.cache-py.outputs.cache-hit != 'true' + + - run: pip install . + if: steps.cache-py.outputs.cache-hit != 'true' + + - run: pip freeze + + - run: black --check . + - run: flake8 + - run: isort --check . + + # https://github.com/marketplace/actions/alls-green#why used for branch protection checks + check: + if: always() + needs: [test, lint] + 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: + name: build on ${{ matrix.platform || matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }}) + if: success() + strategy: + fail-fast: false + matrix: + os: [ubuntu, macos, windows] + target: [x86_64, aarch64] + manylinux: [auto] + include: + - os: ubuntu + platform: linux + - os: windows + ls: dir + interpreter: 3.7 3.8 3.9 3.10 3.11 + - os: windows + ls: dir + target: i686 + python-architecture: x86 + interpreter: 3.7 3.8 3.9 3.10 3.11 + - os: macos + target: aarch64 + interpreter: 3.7 3.8 3.9 3.10 3.11 + - os: ubuntu + platform: linux + target: i686 + # GCC 4.8.5 in manylinux2014 container doesn't support c11 atomic + # we use manylinux_2_24 container for aarch64 and armv7 targets instead, + - os: ubuntu + platform: linux + target: aarch64 + container: messense/manylinux_2_24-cross:aarch64 + - os: ubuntu + platform: linux + target: armv7 + container: messense/manylinux_2_24-cross:armv7 + interpreter: 3.7 3.8 3.9 3.10 3.11 + # musllinux + - os: ubuntu + platform: linux + target: x86_64 + manylinux: musllinux_1_1 + - os: ubuntu + platform: linux + target: aarch64 + manylinux: musllinux_1_1 + - os: ubuntu + platform: linux + target: ppc64le + container: messense/manylinux_2_24-cross:ppc64le + interpreter: 3.7 3.8 3.9 3.10 3.11 + - os: ubuntu + platform: linux + target: s390x + container: messense/manylinux_2_24-cross:s390x + interpreter: 3.7 3.8 3.9 3.10 3.11 + exclude: + # Windows on arm64 only supports Python 3.11+ + - os: windows + target: aarch64 + + runs-on: ${{ matrix.os }}-latest + steps: + - uses: actions/checkout@v3 + + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + architecture: ${{ matrix.python-architecture || 'x64' }} + + - run: pip install -U twine + + - name: build sdist + if: ${{ matrix.os == 'ubuntu' && matrix.target == 'x86_64' && matrix.manylinux == 'auto' }} + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + rust-toolchain: stable + + - name: build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + manylinux: ${{ matrix.manylinux || 'auto' }} + container: ${{ matrix.container }} + args: --release --out dist --interpreter ${{ matrix.interpreter || '3.7 3.8 3.9 3.10 3.11 pypy3.7 pypy3.8 pypy3.9' }} + rust-toolchain: stable + + - run: ${{ matrix.ls || 'ls -lh' }} dist/ + + - run: twine check dist/* + + - uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + release: + needs: [build, check] + if: "success() && startsWith(github.ref, 'refs/tags/')" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - run: pip install -U twine + + - name: get dist artifacts + uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + + - run: twine check dist/* + + - name: upload to pypi + run: twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/Lint.yml b/.github/workflows/Lint.yml deleted file mode 100644 index 0df625e..0000000 --- a/.github/workflows/Lint.yml +++ /dev/null @@ -1,73 +0,0 @@ -on: [push, pull_request] - -name: Lint - -jobs: - check: - name: Check Rust - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: actions-rs/cargo@v1 - with: - command: check - - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - black: - name: Black - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install - run: pip install black - - name: Lint - run: black --check . - - flake8: - name: flake8 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install - run: pip install flake8 - - name: Lint - run: flake8 - - isort: - name: isort - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install - run: pip install isort - - name: Lint - run: isort --check .