diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bd881aef..04ac8538 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: Docker build +name: Docker build & smoke test on: workflow_dispatch: @@ -24,41 +24,89 @@ jobs: contents: read packages: write steps: - - name: Checkout repository - uses: actions/checkout@v5 - with: - fetch-depth: 200 - fetch-tags: true + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 200 + fetch-tags: true - - name: Setup Docker buildx - uses: docker/setup-buildx-action@v3 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64 - cache-from: | - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TARGET_BRANCH }} - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }} - cache-to: type=inline - env: - TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64 + cache-from: | + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TARGET_BRANCH }} + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }} + cache-to: type=inline + env: + TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} + + smoke-test: + runs-on: docker + steps: + - uses: actions/checkout@v5 + - uses: astral-sh/setup-uv@v6 + - name: Install dependencies + run: | + sudo apt update + sudo apt install -y --no-install-recommends graphviz + - name: Check if data needs to be pulled + run: | + if [ ! -d "test/data" ]; then + echo "Fetching data..." + uv run petprep/scripts/collect_test_data.py -o bids -d smriprep freesurfer + fi + - name: Install PETPrep wrapper + run: | + uv tool install petprep/wrapper + - name: Run PETPrep smoke test + run: | + uvx petprep_wrapper bids derivatives/output participant -i $PETPREP_DOCKER_IMAGE --participant-label 01 + env: + PETPREP_DOCKER_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }} + + push-container: + if: github.event_name != 'pull_request' + needs: build-container + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64