diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57124d4..b1fc9b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,46 +13,17 @@ on: workflow_dispatch: jobs: - build_docker_x86_64: - 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 x86_64 - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64 - build-args: "ARCH=x86_64" - tags: mv-extractor:local-x86_64 - outputs: type=docker,dest=/tmp/image-x86_64.tar - cache-from: type=registry,ref=lubo1994/mv-extractor:buildcache-x86_64 - cache-to: type=registry,ref=lubo1994/mv-extractor:buildcache-x86_64,mode=max - - - name: Upload x86_64 Docker image as artifact - uses: actions/upload-artifact@v4 - with: - name: mv-extractor-image-x86_64 - path: /tmp/image-x86_64.tar - - build_docker_aarch64: - name: Build Docker image + build_docker: + name: Build Docker image ${{ matrix.arch }} runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - arch: x86_64 + platform_tag: linux/amd64 + - arch: aarch64 + platform_tag: linux/arm64 steps: - name: Checkout @@ -70,55 +41,54 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and export aarch64 + - name: Build and export ${{ matrix.arch }} uses: docker/build-push-action@v6 with: context: . - platforms: linux/arm64 - build-args: "ARCH=aarch64" - tags: mv-extractor:local-aarch64 - outputs: type=docker,dest=/tmp/image-aarch64.tar - cache-from: type=registry,ref=lubo1994/mv-extractor:buildcache-aarch64 - cache-to: type=registry,ref=lubo1994/mv-extractor:buildcache-aarch64,mode=max - - - name: Upload aarch64 Docker image as artifact + platforms: ${{ matrix.platform_tag }} + build-args: "ARCH=${{ matrix.arch }}" + tags: mv-extractor:local-${{ matrix.arch }} + outputs: type=docker,dest=/tmp/image-${{ matrix.arch }}.tar + cache-from: type=registry,ref=lubo1994/mv-extractor:buildcache-${{ matrix.arch }} + cache-to: type=registry,ref=lubo1994/mv-extractor:buildcache-${{ matrix.arch }},mode=max + + - name: Upload ${{ matrix.arch }} Docker image as artifact uses: actions/upload-artifact@v4 with: - name: mv-extractor-image-aarch64 - path: /tmp/image-aarch64.tar - - test_docker_x86_64: - name: Run unit tests in Docker container (only for the Python version used in the Dockerfile command) - runs-on: ubuntu-latest - needs: - - build_docker_x86_64 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Download x86_64 Docker image - uses: actions/download-artifact@v4 - with: - name: mv-extractor-image-x86_64 - path: /tmp - - - name: Load Docker image - run: | - docker load --input /tmp/image-x86_64.tar - - - name: Run unit tests - run: | - docker run -v ${{ github.workspace }}:/home/video_cap \ - mv-extractor:local-x86_64 \ - python3.12 -m unittest discover -s tests -p "*tests.py" + name: mv-extractor-image-${{ matrix.arch }} + path: /tmp/image-${{ matrix.arch }}.tar + + # test_docker_x86_64: + # name: Run unit tests in x86_64 Docker container (only for the Python version used in the Dockerfile command) + # runs-on: ubuntu-latest + # needs: + # - build_docker_x86_64 + + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + + # - name: Download x86_64 Docker image + # uses: actions/download-artifact@v4 + # with: + # name: mv-extractor-image-x86_64 + # path: /tmp + + # - name: Load Docker image + # run: | + # docker load --input /tmp/image-x86_64.tar + + # - name: Run unit tests + # run: | + # docker run -v ${{ github.workspace }}:/home/video_cap \ + # mv-extractor:local-x86_64 \ + # python3.12 -m unittest discover -s tests -p "*tests.py" build_and_test_wheels: name: Build wheels for cp${{ matrix.python }}-${{ matrix.platform_id }} runs-on: ${{ matrix.os }} needs: - - build_docker_x86_64 - - build_docker_aarch64 + - build_docker strategy: # Ensure that a wheel builder finishes even if another fails fail-fast: false @@ -212,47 +182,25 @@ jobs: name: python-wheel-${{ matrix.python }} path: ./wheelhouse/*.whl - push_docker_x86_64: - name: Push Docker images to DockerHub - if: github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - needs: - - build_docker_x86_64 - - test_docker_x86_64 - - build_and_test_wheels - - steps: - - name: Download x86_64 Docker image - uses: actions/download-artifact@v4 - with: - name: mv-extractor-image-x86_64 - path: /tmp - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Load and push x86_64 Docker image - run: | - docker load --input /tmp/image-x86_64.tar - docker tag mv-extractor:local-x86_64 lubo1994/mv-extractor:dev-x86_64 - docker push lubo1994/mv-extractor:dev-x86_64 - - push_docker_aarch64: - name: Push Docker images to DockerHub + push_docker: + name: Push ${{ matrix.arch }} Docker image to DockerHub if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest needs: - - build_docker_aarch64 + - build_docker - build_and_test_wheels + strategy: + fail-fast: false + matrix: + include: + - arch: x86_64 + - arch: aarch64 steps: - - name: Download aarch64 Docker image + - name: Download ${{ matrix.arch }} Docker image uses: actions/download-artifact@v4 with: - name: mv-extractor-image-aarch64 + name: mv-extractor-image-${{ matrix.arch }} path: /tmp - name: Login to DockerHub @@ -261,8 +209,8 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Load and push aarch64 Docker image + - name: Load and push ${{ matrix.arch }} Docker image run: | - docker load --input /tmp/image-aarch64.tar - docker tag mv-extractor:local-aarch64 lubo1994/mv-extractor:dev-aarch64 - docker push lubo1994/mv-extractor:dev-aarch64 \ No newline at end of file + docker load --input /tmp/image-${{ matrix.arch }}.tar + docker tag mv-extractor:local-${{ matrix.arch }} lubo1994/mv-extractor:dev-${{ matrix.arch }} + docker push lubo1994/mv-extractor:dev-${{ matrix.arch }} \ No newline at end of file