DO NOT MERGE - gh workflow: add poc to show different onnxruntime results on windows #162
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
# This file is autogenerated by maturin v1.7.4 and manually modified by ia0. | |
name: Python - build package | |
on: | |
pull_request: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'python-v*' | |
schedule: | |
- cron: '12 3 * * 4' # Refresh the cache weekly. | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ${{ matrix.platform.runner }} | |
strategy: | |
matrix: | |
platform: | |
- runner: ubuntu-latest | |
target: x86_64 | |
- runner: windows-latest | |
target: x64 | |
- runner: macos-14 | |
target: aarch64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # pin@v5 | |
with: | |
python-version: '3.12' | |
- name: Install uv | |
run: curl -LsSf https://astral.sh/uv/0.4.7/install.sh | sh | |
- if: matrix.platform.runner == 'ubuntu-latest' | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
with: | |
path: rust/onnx/runtime/build/Linux | |
key: maturin-${{ matrix.platform.target }}-${{ hashFiles('rust/onnx/build.sh') }} | |
- run: python3 ./python/scripts/fix_package_version.py | |
- if: matrix.platform.runner == 'ubuntu-latest' | |
name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out=../dist | |
before-script-linux: "${{ github.workspace }}/rust/onnx/maturin.sh" | |
manylinux: 2_28 | |
working-directory: python | |
- if: matrix.platform.runner != 'ubuntu-latest' | |
name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
args: --release --out=../dist | |
working-directory: python | |
- if: matrix.platform.runner != 'windows-latest' | |
name: Check that `uv add magika.whl` works | |
run: mkdir /tmp/test-uv && cp -vR dist/*.whl /tmp/test-uv && cd /tmp/test-uv && uv init && uv add ./$(\ls -1 *.whl | head -n 1) | |
- if: matrix.platform.runner == 'windows-latest' | |
name: Check that magika install with uv works on Windows | |
shell: pwsh | |
run: | | |
mkdir C:\test-uv | |
Copy-Item -Path dist\*.whl -Destination C:\test-uv | |
cd C:\test-uv | |
uv init | |
$wheel = Get-ChildItem -Filter *.whl | Select-Object -ExpandProperty Name | |
uv add ".\$wheel" | |
- name: Install wheels | |
run: python3 -m pip install $(python -c "import glob; print(glob.glob('dist/*.whl')[0])") | |
- run: magika --version | |
- run: "python3 -c 'import magika; m = magika.Magika(); print(m)'" | |
- run: magika -r tests_data/basic | |
- run: python3 ./python/scripts/run_quick_test_magika_cli.py | |
# Windows' onnxruntime/ort returns different results wrt. Linux/MacOS. For | |
# now keep building even in case of misdetections. | |
# TODO(https://github.com/google/magika/issues/892): remove when this is fixed. | |
continue-on-error: ${{ matrix.platform.runner == 'windows-latest' }} | |
- run: python3 ./python/scripts/run_quick_test_magika_module.py | |
# TODO(https://github.com/google/magika/issues/892): same as above, | |
# remove when this is fixed. | |
continue-on-error: ${{ matrix.platform.runner == 'windows-latest' }} | |
- name: Upload wheels | |
if: github.event_name != 'pull_request' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }} | |
path: dist | |
sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: python3 ./python/scripts/fix_package_version.py | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out=../dist | |
working-directory: python | |
- name: Upload sdist | |
if: github.event_name != 'pull_request' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-sdist | |
path: dist |