Merge pull request #44 from LukasBommes/remove_comments_from_workflow #10
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
# On a push to any branch this workflow: | |
# - builds the Docker image, | |
# - build wheels for different Python versions, | |
# - installs the wheel for each Python version and runs the unit tests. | |
# On manual dispatch this workflow: | |
# - pushes the previously built Docker image to DockerHub with tag "dev". | |
name: ci and release | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build_docker: | |
name: Build Docker image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and export | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
tags: mv-extractor:local | |
outputs: type=docker,dest=/tmp/image.tar | |
cache-from: type=registry,ref=lubo1994/mv-extractor:buildcache | |
cache-to: type=registry,ref=lubo1994/mv-extractor:buildcache,mode=max | |
- name: Upload Docker image as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mv-extractor-docker-image | |
path: /tmp/image.tar | |
test_docker: | |
name: Run unit tests in Docker container (only for the Python version used in the Dockerfile command) | |
runs-on: ubuntu-latest | |
needs: build_docker | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download artifact containing Docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: mv-extractor-docker-image | |
path: /tmp | |
- name: Load Docker image | |
run: | | |
docker load --input /tmp/image.tar | |
- name: Run unit tests | |
run: | | |
docker run -v ${{ github.workspace }}:/home/video_cap \ | |
mv-extractor:local \ | |
python3.10 tests/tests.py | |
build_and_test_wheels: | |
name: Build wheels for cp${{ matrix.python }}-${{ matrix.platform_id }} | |
runs-on: ${{ matrix.os }} | |
needs: | |
- build_docker | |
strategy: | |
# Ensure that a wheel builder finishes even if another fails | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
python: 39 | |
bitness: 64 | |
platform_id: manylinux_x86_64 | |
manylinux_image: mv-extractor:local | |
- os: ubuntu-latest | |
python: 310 | |
bitness: 64 | |
platform_id: manylinux_x86_64 | |
manylinux_image: mv-extractor:local | |
- os: ubuntu-latest | |
python: 311 | |
bitness: 64 | |
platform_id: manylinux_x86_64 | |
manylinux_image: mv-extractor:local | |
- os: ubuntu-latest | |
python: 312 | |
bitness: 64 | |
platform_id: manylinux_x86_64 | |
manylinux_image: mv-extractor:local | |
- os: ubuntu-latest | |
python: 313 | |
bitness: 64 | |
platform_id: manylinux_x86_64 | |
manylinux_image: mv-extractor:local | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download artifact containing Docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: mv-extractor-docker-image | |
path: /tmp | |
- name: Load Docker image | |
run: | | |
docker load --input /tmp/image.tar | |
- name: Build and test wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_PLATFORM: linux | |
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} | |
# Disable building PyPy wheels on all platforms | |
CIBW_SKIP: pp* | |
CIBW_ARCHS: x86_64 | |
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }} | |
#CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }} | |
CIBW_BUILD_FRONTEND: build | |
CIBW_TEST_COMMAND: VIDEO_URL={project}/vid_h264.mp4 python3 {project}/tests/tests.py | |
CIBW_BUILD_VERBOSITY: 1 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: python-wheel-${{ matrix.python }} | |
path: ./wheelhouse/*.whl | |
push_docker: | |
name: Push Docker image to DockerHub | |
if: github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
needs: | |
- build_docker | |
- test_docker | |
- build_and_test_wheels | |
steps: | |
- name: Download artifact containing Docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: mv-extractor-docker-image | |
path: /tmp | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Load and push Docker image | |
run: | | |
docker load --input /tmp/image.tar | |
docker tag mv-extractor:local lubo1994/mv-extractor:dev | |
docker push lubo1994/mv-extractor:dev |