diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8786588..4fd00f5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -39,7 +39,30 @@ jobs: with: images: ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }} + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3.11.1 + + - name: Build and push by digest + if: github.event_name == 'pull_request' + uses: docker/build-push-action@v6.18.0 + with: + file: ./docker/Dockerfile + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + tags: ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }} + outputs: type=docker,push-by-digest=true,name-canonical=true,push=true + + - name: Run tests + if: github.event_name == 'pull_request' + shell: bash + run: | + docker run -t ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}:latest bash -c " \ + pip install pytest nbmake; \ + find . -name '*.ipynb' | pytest --nbmake --nbmake-timeout=3600 --ignore=answers; " + - name: Authenticate with GHCR + if: github.event_name != 'pull_request' id: auth uses: docker/login-action@v3.6.0 with: @@ -47,11 +70,8 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.BUILD_TOKEN }} - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3.11.1 - - name: Build and push by digest + if: github.event_name != 'pull_request' id: build uses: docker/build-push-action@v6.18.0 with: @@ -61,7 +81,8 @@ jobs: tags: ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }} outputs: type=image,push-by-digest=true,name-canonical=true,push=true - - name: Test notebooks + - name: Run tests + if: github.event_name != 'pull_request' shell: bash run: | docker run -t ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}@${{ steps.build.outputs.digest }} bash -c " \ @@ -69,12 +90,14 @@ jobs: find . -name '*.ipynb' | pytest --nbmake --nbmake-timeout=3600 --ignore=answers; " - name: Export digest + if: github.event_name != 'pull_request' run: | mkdir -p ${{ runner.temp }}/digests digest="${{ steps.build.outputs.digest }}" touch "${{ runner.temp }}/digests/${digest#sha256:}" - name: Upload digest + if: github.event_name != 'pull_request' uses: actions/upload-artifact@v5.0.0 with: name: digests-${{ env.PLATFORM_PAIR }}