Added MacOS support for pdfalto binary #185
Workflow file for this run
This file contains hidden or 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
| name: CI Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| DOCKER_IMAGE_NAME: ghcr.io/elifepathways/sciencebeam-parser | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v5 | |
| - name: Set tags | |
| id: set_tags | |
| run: | | |
| DOCKER_IMAGE="${{ env.DOCKER_IMAGE_NAME }}" | |
| VERSION="" | |
| GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}} | |
| SHORT_SHA=${GITHUB_SHA::8} | |
| TIMESTAMP=`date --utc +%Y%m%d.%H%M` | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| fi | |
| TAG_LINES="" | |
| if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
| PYTHON_PACKAGE_VERSION="${VERSION}" | |
| IMAGE_NAME="${DOCKER_IMAGE}" | |
| IMAGE_TAG="${VERSION}" | |
| TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest" | |
| CV_TAGS="${DOCKER_IMAGE}:${VERSION}-cv,${DOCKER_IMAGE}:latest-cv" | |
| else | |
| PYTHON_PACKAGE_VERSION=`./scripts/dev/get-test-pypi-version.sh ${GITHUB_SHA}` | |
| IMAGE_NAME="${DOCKER_IMAGE}_unstable" | |
| IMAGE_TAG="${GITHUB_SHA}" | |
| TAGS="${DOCKER_IMAGE}_unstable:${GITHUB_SHA},${DOCKER_IMAGE}_unstable:${GIT_BRANCH}-${SHORT_SHA}-${TIMESTAMP},${DOCKER_IMAGE}_unstable:latest" | |
| CV_TAGS="${DOCKER_IMAGE}_unstable:${GITHUB_SHA}-cv,${DOCKER_IMAGE}_unstable:${GIT_BRANCH}-${SHORT_SHA}-${TIMESTAMP}-cv,${DOCKER_IMAGE}_unstable:latest-cv" | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser.tags=${IMAGE_NAME}:${GIT_BRANCH}-${SHORT_SHA}-${TIMESTAMP}\n" | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser-cv.tags=${IMAGE_NAME}:${GIT_BRANCH}-${SHORT_SHA}-${TIMESTAMP}-cv\n" | |
| fi | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser.tags=${IMAGE_NAME}:${IMAGE_TAG}\n" | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser.tags=${IMAGE_NAME}:latest\n" | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser-cv.tags=${IMAGE_NAME}:${IMAGE_TAG}-cv\n" | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser-cv.tags=${IMAGE_NAME}:latest-cv\n" | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser-dev.tags=${IMAGE_NAME}:${IMAGE_TAG}-dev\n" | |
| TAG_LINES="${TAG_LINES}sciencebeam-parser-dev.tags=${IMAGE_NAME}:latest-dev\n" | |
| echo -e "tag_lines<<EOF\n${TAG_LINES}EOF" >> $GITHUB_OUTPUT | |
| echo "PYTHON_PACKAGE_VERSION=${PYTHON_PACKAGE_VERSION}" | |
| echo "python_package_version=${PYTHON_PACKAGE_VERSION}" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| buildkitd-config-inline: |- | |
| [worker.oci] | |
| gc = false | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Show determined Python package version | |
| run: echo "${{ steps.set_tags.outputs.python_package_version }}" | |
| - name: Bake build for all targets (push if not PR) | |
| uses: docker/bake-action@v6 | |
| with: | |
| files: docker-bake.hcl | |
| targets: builder,builder-cv,sciencebeam-parser-dev,python-dist,lint-flake8,lint-pylint,lint-mypy,pytest,end-to-end-tests,sciencebeam-parser,sciencebeam-parser-cv | |
| set: | | |
| ${{ steps.set_tags.outputs.tag_lines }} | |
| python-dist.args.python_package_version=${{ steps.set_tags.outputs.python_package_version }} | |
| python-dist.output=type=local,dest=./dist-export | |
| ${{ github.event_name != 'pull_request' && 'sciencebeam-parser.output=type=registry' || '' }} | |
| ${{ github.event_name != 'pull_request' && 'sciencebeam-parser-cv.output=type=registry' || '' }} | |
| *.cache-from+=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-builder | |
| *.cache-from+=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-builder-cv | |
| *.cache-from+=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-dev | |
| *.cache-from+=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-runtime | |
| *.cache-from+=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-runtime-cv | |
| builder.cache-to=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-builder,mode=max | |
| builder-cv.cache-to=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-builder-cv,mode=max | |
| sciencebeam-parser-dev.cache-to=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-dev,mode=max | |
| sciencebeam-parser-cv.cache-to=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-runtime,mode=max | |
| sciencebeam-parser.cache-to=type=registry,ref=ghcr.io/elifepathways/sciencebeam-parser_unstable:buildcache-runtime-cv,mode=max | |
| push: false | |
| load: false | |
| - name: List dist-export contents | |
| run: ls -R -l ./dist-export | |
| - name: Upload python package artifacts | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: python-package-distributions | |
| path: ./dist-export/dist/ | |
| native-test: | |
| strategy: | |
| matrix: | |
| include: | |
| - runs-on: macos-latest | |
| install-poppler: brew install poppler | |
| pytest-ignore-args: --ignore=tests/cv_models | |
| - runs-on: ubuntu-24.04-arm | |
| install-poppler: sudo apt-get install -y poppler-utils | |
| pytest-ignore-args: tests/external/pdfalto/url_test.py tests/external/pdfalto/parser_test.py tests/document tests/utils tests/config tests/lookup | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Check out repository code | |
| uses: actions/checkout@v5 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install poppler (required by pdf2image) | |
| run: ${{ matrix.install-poppler }} | |
| - name: Install dependencies | |
| run: uv sync --frozen --group dev --extra delft | |
| if: runner.os != 'Linux' || runner.arch != 'ARM64' | |
| - name: Install dependencies (Linux arm64 - skip delft extras with no arm64 wheels) | |
| run: | | |
| uv sync --frozen --group dev | |
| uv pip install "sciencebeam-trainer-delft>=0.0.36" | |
| if: runner.os == 'Linux' && runner.arch == 'ARM64' | |
| - name: Run pytest | |
| run: uv run python -m pytest -p no:cacheprovider ${{ matrix.pytest-ignore-args }} | |
| testpypi-publish: | |
| if: github.ref == 'refs/heads/main' | |
| needs: ["build-and-test"] | |
| name: Upload release to Test PyPI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download dists | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish package distributions to Test PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ | |
| verbose: true | |
| password: ${{ secrets.TEST_PYPI_CREDENTIALS }} | |
| pypi-publish: | |
| if: startsWith(github.ref, 'refs/tags') | |
| needs: ["build-and-test"] | |
| name: Upload release to PyPI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download dists | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_CREDENTIALS }} |