Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
👷 Enhance CI workflow with manylinux container
Browse files Browse the repository at this point in the history
  • Loading branch information
mnixry committed Jan 3, 2025
1 parent 33783ea commit c86e47f
Showing 1 changed file with 102 additions and 31 deletions.
133 changes: 102 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ on:

jobs:
build-opencv:
name: Build OpenCV
name: Build OpenCV (${{ matrix.os.artifact-name || matrix.os.runner }})

strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-13
- macos-latest
- runner: ubuntu-latest
container: quay.io/pypa/manylinux_2_34_x86_64
artifact-name: linux
- runner: ubuntu-latest
container: quay.io/pypa/musllinux_1_2_x86_64
artifact-name: linux-musl
- runner: windows-latest
- runner: macos-13
- runner: macos-latest

defaults:
run:
Expand All @@ -26,28 +31,36 @@ jobs:
env:
SCCACHE_GHA_ENABLED: true

runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os.runner }}
container: ${{ matrix.os.container }}

steps:
- name: Get latest release
id: latest-release
run: |
curl -s https://api.github.com/repos/opencv/opencv/releases/latest \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
| jq -r '.tag_name' | tee latest-release.txt
curl -Ls -o /dev/null -w %{url_effective} \
https://github.com/opencv/opencv/releases/latest \
| sed 's#.*tag/\(.*\)$#\1#' > latest-release.txt
echo "tag=$(cat latest-release.txt)" >> $GITHUB_OUTPUT
- uses: actions/checkout@main
with:
repository: opencv/opencv
ref: ${{ steps.latest-release.outputs.tag }}

- uses: seanmiddleditch/gha-setup-ninja@master
id: setup-ninja
if: matrix.os.artifact-name != 'linux-musl'

- name: Manually install ninja
if: steps.setup-ninja.conclusion == 'skipped'
run: apk add ninja-build

- uses: mozilla-actions/sccache-action@main

- uses: ilammy/msvc-dev-cmd@v1
id: msvc-env
if: startsWith(matrix.os, 'windows')
if: startsWith(matrix.os.runner, 'windows')

- name: Setup MSVC environment
if: steps.msvc-env.conclusion == 'success'
Expand Down Expand Up @@ -81,24 +94,29 @@ jobs:
-D WITH_PNG=OFF \
-D WITH_TIFF=OFF
cmake --build . --target install --parallel 4
cmake --build . --target install --parallel $(nproc)
- uses: actions/upload-artifact@main
with:
name: opencv-${{ matrix.os }}
name: opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
path: ./opencv

build:
name: Build Wheel
name: Build Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
needs: [build-opencv]

strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-13
- macos-latest
- runner: ubuntu-latest
container: quay.io/pypa/manylinux_2_34_x86_64
artifact-name: linux
- runner: ubuntu-latest
container: quay.io/pypa/musllinux_1_2_x86_64
artifact-name: linux-musl
- runner: windows-latest
- runner: macos-13
- runner: macos-latest
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
exclude:
- os: macos-latest
Expand All @@ -111,27 +129,56 @@ jobs:
run:
shell: bash

runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os.runner }}
container: ${{ matrix.os.container }}

steps:
- uses: actions/checkout@main

- uses: actions/download-artifact@main
with:
name: opencv-${{ matrix.os }}
name: opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
path: ./opencv

- uses: pdm-project/setup-pdm@main
id: install-pdm
if: ${{ !matrix.os.container }}
with:
python-version: ${{ matrix.python }}
cache: true

- name: Manually install PDM
if: steps.install-pdm.conclusion == 'skipped'
run: |
set -xve
pipx install pdm
set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
echo "$PYTHONPATH" >> $GITHUB_PATH
echo "$PYTHONPATH/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
echo "PYTHON3_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
- name: Install dependencies
run: pdm install -G :all --no-self

- uses: seanmiddleditch/gha-setup-ninja@master
id: setup-ninja
if: matrix.os.artifact-name != 'linux-musl'

- name: Manually install ninja
if: steps.setup-ninja.conclusion == 'skipped'
run: apk add ninja-build

- uses: ilammy/msvc-dev-cmd@v1
id: msvc-env
if: startsWith(matrix.os, 'windows')
if: startsWith(matrix.os.runner, 'windows')

- name: Setup MSVC environment
if: steps.msvc-env.conclusion == 'success'
Expand All @@ -151,20 +198,25 @@ jobs:

- uses: actions/upload-artifact@main
with:
name: wheel-${{matrix.os}}-${{matrix.python}}
name: wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
path: ./dist/*.whl

test:
name: Test Wheel
name: Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
needs: [build]

strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-13
- macos-latest
- runner: ubuntu-latest
container: quay.io/pypa/manylinux_2_34_x86_64
artifact-name: linux
- runner: ubuntu-latest
container: quay.io/pypa/musllinux_1_2_x86_64
artifact-name: linux-musl
- runner: windows-latest
- runner: macos-13
- runner: macos-latest
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
exclude:
- os: macos-latest
Expand All @@ -177,26 +229,46 @@ jobs:
run:
shell: bash

runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os.runner }}
container: ${{ matrix.os.container }}

steps:
- uses: actions/checkout@main

- name: Download wheel
uses: actions/download-artifact@main
with:
name: wheel-${{matrix.os}}-${{matrix.python}}
name: wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
path: ./dist

- uses: pdm-project/setup-pdm@main
id: install-pdm
if: ${{ !matrix.os.container }}
with:
python-version: ${{ matrix.python }}
cache: true

- name: Manually install PDM
if: steps.install-pdm.conclusion == 'skipped'
run: |
set -xve
pipx install pdm
set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
echo "$PYTHONPATH" >> $GITHUB_PATH
echo "$PYTHONPATH/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
- name: Install dependencies
run: |
pdm install -G test --no-self
pdm add dist/*.whl --no-lock
pdm add -v dist/*.whl --frozen-lockfile
- name: Run tests
run: |
Expand Down Expand Up @@ -246,7 +318,6 @@ jobs:

- uses: pdm-project/setup-pdm@main
with:
python-version: "3"
cache: true

- name: Publish to PyPI
Expand Down

0 comments on commit c86e47f

Please sign in to comment.