From c26f33bc19dd1e44294211bfb0a54f68fb249444 Mon Sep 17 00:00:00 2001 From: Yanick Fratantonio Date: Fri, 24 Jan 2025 11:44:53 +0000 Subject: [PATCH 1/4] gh workflow: test the built wheels with different versions of python --- .github/workflows/python-build-package.yml | 59 ++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-build-package.yml b/.github/workflows/python-build-package.yml index 7f48420c..0a6ecb08 100644 --- a/.github/workflows/python-build-package.yml +++ b/.github/workflows/python-build-package.yml @@ -86,9 +86,62 @@ jobs: - name: Upload wheels uses: actions/upload-artifact@v4 with: - name: wheels-${{ matrix.platform.runner }}-${{ matrix.platform.target }} + name: wheel-${{ matrix.platform.runner }}-${{ matrix.platform.target }} path: dist + # Download, install, and test the wheels with different versions of python + test-wheels: + needs: [build-wheels] + runs-on: ${{ matrix.platform.runner }} + strategy: + matrix: + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] + platform: + - runner: ubuntu-latest + target: x86_64 + - runner: windows-latest + target: x64 + - runner: macos-14 + target: aarch64 + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: wheel-${{ matrix.platform.runner }}-${{ matrix.platform.target }} + path: dist + - name: Setup Python + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # pin@v5 + with: + python-version: '${{ matrix.python-version }}' + - name: Install uv + run: curl -LsSf https://astral.sh/uv/0.5.22/install.sh | sh + - 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 `uv add magika.whl` works + shell: pwsh + run: | + mkdir C:\test-uv + Copy-Item -Path dist\*.whl -Destination C:\test-uv + cd C:\test-uv + $env:PATH += ";$HOME/.local/bin" + uv init + $wheel = Get-ChildItem -Filter *.whl | Select-Object -ExpandProperty Name + uv add ".\$wheel" + - name: Install the wheel + 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 + - run: python3 ./python/scripts/run_quick_test_magika_module.py + build-pure-python-wheel: runs-on: ubuntu-latest steps: @@ -117,7 +170,7 @@ jobs: - name: Upload wheel uses: actions/upload-artifact@v4 with: - name: wheels-pure-python + name: wheel-pure-python path: dist # Download, install, and test the pure python wheel on multiple platforms @@ -137,7 +190,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: - name: wheels-pure-python + name: wheel-pure-python path: dist - name: Setup Python uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # pin@v5 From 9e15949775b2a562874d6e189641a2df98e5f0c2 Mon Sep 17 00:00:00 2001 From: Yanick Fratantonio Date: Fri, 24 Jan 2025 11:52:04 +0000 Subject: [PATCH 2/4] gh workflow: disable fail fast for testing --- .github/workflows/python-build-package.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python-build-package.yml b/.github/workflows/python-build-package.yml index 0a6ecb08..5a7f452c 100644 --- a/.github/workflows/python-build-package.yml +++ b/.github/workflows/python-build-package.yml @@ -93,6 +93,8 @@ jobs: test-wheels: needs: [build-wheels] runs-on: ${{ matrix.platform.runner }} + # We want to know in which exact situation the tests fail + fail-fast: false strategy: matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] @@ -176,6 +178,8 @@ jobs: # Download, install, and test the pure python wheel on multiple platforms test-pure-python-wheel: needs: [build-pure-python-wheel] + # We want to know in which exact situation the tests fail + fail-fast: false runs-on: ${{ matrix.platform.runner }} strategy: matrix: From 02aa4aaaf6e35e232d3d1ef75b48450e53520832 Mon Sep 17 00:00:00 2001 From: Yanick Fratantonio Date: Fri, 24 Jan 2025 11:52:26 +0000 Subject: [PATCH 3/4] gh workflow: add testing with many python versions for the pure python wheel --- .github/workflows/python-build-package.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-build-package.yml b/.github/workflows/python-build-package.yml index 5a7f452c..ef82f79a 100644 --- a/.github/workflows/python-build-package.yml +++ b/.github/workflows/python-build-package.yml @@ -183,6 +183,7 @@ jobs: runs-on: ${{ matrix.platform.runner }} strategy: matrix: + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] platform: - runner: ubuntu-latest target: x86_64 @@ -199,7 +200,7 @@ jobs: - name: Setup Python uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # pin@v5 with: - python-version: '3.12' + python-version: '${{ matrix.python-version }}' - name: Install uv run: curl -LsSf https://astral.sh/uv/0.5.22/install.sh | sh - if: matrix.platform.runner != 'windows-latest' From fa0ce8d589d8da6f512e1e51db9872bef8db07d0 Mon Sep 17 00:00:00 2001 From: Yanick Fratantonio Date: Fri, 24 Jan 2025 11:59:20 +0000 Subject: [PATCH 4/4] gh workflow: fix failure in adding fail-fast --- .github/workflows/python-build-package.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-build-package.yml b/.github/workflows/python-build-package.yml index ef82f79a..0d209ea1 100644 --- a/.github/workflows/python-build-package.yml +++ b/.github/workflows/python-build-package.yml @@ -93,9 +93,9 @@ jobs: test-wheels: needs: [build-wheels] runs-on: ${{ matrix.platform.runner }} - # We want to know in which exact situation the tests fail - fail-fast: false strategy: + # We want to know in which exact situation the tests fail + fail-fast: false matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] platform: @@ -178,10 +178,10 @@ jobs: # Download, install, and test the pure python wheel on multiple platforms test-pure-python-wheel: needs: [build-pure-python-wheel] - # We want to know in which exact situation the tests fail - fail-fast: false runs-on: ${{ matrix.platform.runner }} strategy: + # We want to know in which exact situation the tests fail + fail-fast: false matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] platform: