|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `build` job of |
| 5 | +# https://github.com/firecrawl/pdf-inspector/blob/32555d23356f7892762a38edb3a5b0cad7ec326b/.github/workflows/publish-pypi.yml |
| 6 | +name: Build pdf-inspector wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/pdf-inspector.yaml not released yet' |
| 13 | + required: false |
| 14 | + default: '' |
| 15 | + pull_request: |
| 16 | + branches: [main] |
| 17 | + paths: |
| 18 | + - '.github/workflows/build-pdf-inspector.yml' |
| 19 | + - 'docs/packages/pdf-inspector.yaml' |
| 20 | + push: |
| 21 | + branches: [main] |
| 22 | + paths: |
| 23 | + - '.github/workflows/build-pdf-inspector.yml' |
| 24 | + - 'docs/packages/pdf-inspector.yaml' |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +permissions: |
| 31 | + contents: read # to fetch code (actions/checkout) |
| 32 | + |
| 33 | +env: |
| 34 | + # Upstream pushed no v1.17.0 tag, so pin the release commit "chore(release): |
| 35 | + # bump package versions to 1.17.0 (#450)", whose tree matches the 1.17.0 PyPI |
| 36 | + # sdist. Update it alongside PDF_INSPECTOR_VERSION (1.18.0+ are tagged v<ver>). |
| 37 | + PDF_INSPECTOR_REF: 32555d23356f7892762a38edb3a5b0cad7ec326b |
| 38 | + |
| 39 | +jobs: |
| 40 | + setup: |
| 41 | + uses: $/.github/workflows/_setup.yml |
| 42 | + with: |
| 43 | + package: pdf-inspector |
| 44 | + version: ${{ inputs.version }} |
| 45 | + |
| 46 | + build_wheel: |
| 47 | + needs: [setup] |
| 48 | + if: needs.setup.outputs.versions != '[]' |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: |
| 52 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 53 | + name: Build pdf-inspector ${{ matrix.version }} cp38-abi3-manylinux_riscv64 |
| 54 | + runs-on: ubuntu-24.04-riscv |
| 55 | + timeout-minutes: 180 |
| 56 | + |
| 57 | + env: |
| 58 | + PDF_INSPECTOR_VERSION: ${{ matrix.version }} |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Checkout pdf-inspector ${{ env.PDF_INSPECTOR_VERSION }} |
| 62 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 63 | + with: |
| 64 | + repository: firecrawl/pdf-inspector |
| 65 | + ref: ${{ env.PDF_INSPECTOR_REF }} |
| 66 | + persist-credentials: false |
| 67 | + |
| 68 | + - name: Build wheel |
| 69 | + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0 |
| 70 | + with: |
| 71 | + target: riscv64gc-unknown-linux-gnu |
| 72 | + args: --release --out dist |
| 73 | + manylinux: '2_39' |
| 74 | + |
| 75 | + - name: Verify the wheel ships the compiled extension |
| 76 | + run: | |
| 77 | + set -euo pipefail |
| 78 | + python3 - dist/*.whl <<'EOF' |
| 79 | + import sys, zipfile |
| 80 | + names = zipfile.ZipFile(sys.argv[1]).namelist() |
| 81 | + sos = [n for n in names if n.endswith(".so")] |
| 82 | + assert "pdf_inspector/pdf_inspector.abi3.so" in sos, sos |
| 83 | + assert any(n.endswith(".dist-info/licenses/LICENSE") for n in names), names |
| 84 | + print(sys.argv[1], "->", sos) |
| 85 | + EOF |
| 86 | +
|
| 87 | + - name: Install uv |
| 88 | + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 |
| 89 | + with: |
| 90 | + enable-cache: false |
| 91 | + |
| 92 | + # Upstream's CI never runs tests/test_python.py; it is the binding's own suite. |
| 93 | + # The encrypted fixture fails on every arch at 1.17.0 (password-less call); |
| 94 | + # upstream fixed the test in firecrawl/pdf-inspector#489. |
| 95 | + - name: Run tests/test_python.py |
| 96 | + run: | |
| 97 | + set -euo pipefail |
| 98 | + for py in 3.12 3.13 3.14; do |
| 99 | + venv="$RUNNER_TEMP/venv-$py" |
| 100 | + uv venv --python "$py" "$venv" |
| 101 | + uv pip install --python "$venv/bin/python" dist/*.whl pytest |
| 102 | + "$venv/bin/python" -m pytest -v tests/test_python.py \ |
| 103 | + --deselect 'tests/test_python.py::TestMultipleFixtures::test_process_all_fixtures[encrypted-secret123.pdf]' |
| 104 | + done |
| 105 | +
|
| 106 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 107 | + with: |
| 108 | + name: pdf-inspector-${{ env.PDF_INSPECTOR_VERSION }}-cp38-abi3-manylinux_riscv64 |
| 109 | + path: dist/*.whl |
| 110 | + if-no-files-found: error |
| 111 | + |
| 112 | + publish: |
| 113 | + name: Publish pdf-inspector ${{ matrix.version }} |
| 114 | + needs: [setup, build_wheel] |
| 115 | + if: needs.setup.outputs.versions != '[]' |
| 116 | + strategy: |
| 117 | + fail-fast: false |
| 118 | + matrix: |
| 119 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 120 | + permissions: |
| 121 | + contents: write |
| 122 | + pull-requests: write |
| 123 | + uses: $/.github/workflows/_publish-wheel.yml |
| 124 | + secrets: |
| 125 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 126 | + with: |
| 127 | + artifact-pattern: pdf-inspector-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments