diff --git a/.github/workflows/ci-Dockerfile.yml b/.github/workflows/ci-Dockerfile.yml new file mode 100644 index 0000000000..419cb613fb --- /dev/null +++ b/.github/workflows/ci-Dockerfile.yml @@ -0,0 +1,93 @@ +name: CI (test image build for a PR with a Dockerfile change) + +on: + pull_request: + branches: + - "main" + - "release-*" + +jobs: + checks: + runs-on: ubuntu-latest + outputs: + run-test-image-build: ${{ steps.dockerChanged.outputs.flag }} + + steps: + - uses: actions/checkout@v4 + + - name: Check if the `Dockerfile` has been changed by a PR + id: dockerChanged + env: + IS_PR: ${{ !!github.event.pull_request }} + PR: ${{ github.event.pull_request }} + run: | + cat >> "$GITHUB_STEP_SUMMARY" <> "$GITHUB_STEP_SUMMARY" < git show --raw HEAD + $(git show --raw HEAD) + \`\`\` + EOF + + INCLUDES_DOCKERFILE=$( + if [[ $(git show --raw --oneline HEAD -- Dockerfile | wc --lines) -eq 0 ]]; then + echo "false" + else + echo "true" + fi + ) + + TEST_IMAGE_BUILD=$( + if [[ $IS_PR == true ]] && [[ $INCLUDES_DOCKERFILE == true ]]; then + echo "true" + else + echo "false" + fi + ) + + cat >> "$GITHUB_STEP_SUMMARY" <> "$GITHUB_OUTPUT" + + # + # Based on: + # - image-build.yaml + # - konveyor/release-tools/.github/workflows/build-push-images.yaml@main + # + # Only test the image build, no push to quay is required. + # + test-image-build: + runs-on: ubuntu-latest + needs: checks + if: ${{ needs.checks.outputs.run-test-image-build == true }} + + strategy: + fail-fast: true + matrix: + architecture: + - amd64 + - arm64 + + steps: + - name: Checkout merge commit for PR${{ github.event.pull_request.number }} + uses: actions/checkout@v4 + + - name: Test build image on ${{ matrix.architecture }} + id: test-build + uses: redhat-actions/buildah-build@main + with: + image: "tackle2-ui" + tags: PR${{ github.event.pull_request.number }}-${{ matrix.architecture }} + extra-args: "--no-cache --rm --ulimit nofile=4096:4096" + archs: ${{ matrix.architecture }} + labels: "" + containerfiles: "./Dockerfile" + context: "." diff --git a/.github/workflows/ci-repo.yml b/.github/workflows/ci-repo.yml index e5cc1c63ee..1677e134f5 100644 --- a/.github/workflows/ci-repo.yml +++ b/.github/workflows/ci-repo.yml @@ -17,10 +17,11 @@ on: workflow_dispatch: jobs: - unit-test-lookup-image: + unit-test-lookups: runs-on: ubuntu-latest outputs: builder-image: ${{ steps.grepBuilder.outputs.builder }} + steps: - uses: actions/checkout@v4 @@ -33,10 +34,10 @@ jobs: unit-test: runs-on: ubuntu-latest - needs: unit-test-lookup-image + needs: unit-test-lookups # Use the same container as the Dockerfile's "FROM * as builder" - container: ${{ needs.unit-test-lookup-image.outputs.builder-image }} + container: ${{ needs.unit-test-lookups.outputs.builder-image }} steps: - uses: actions/checkout@v4