diff --git a/.github/workflows/dci-merge.yml b/.github/workflows/dci-merge.yml index 5605d82a6..1b946f2ee 100644 --- a/.github/workflows/dci-merge.yml +++ b/.github/workflows/dci-merge.yml @@ -6,7 +6,7 @@ on: jobs: dci-job: - name: "DCI" + name: "DCI Merge Job" runs-on: bos2 steps: @@ -19,7 +19,9 @@ jobs: git fetch origin ${{ github.event.merge_group.base_sha }} git fetch origin ${{ github.event.merge_group.head_sha }} if git diff --name-only ${{ github.event.merge_group.base_sha }} ${{ github.event.merge_group.head_sha }} | grep -E 'roles/|plugins/'; then - ./hack/dci-merge.sh + echo "Starting DCI job" + export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} + ./hack/dci-merge.sh ${{ github.event.merge_group.head_sha }} else echo "No code change" fi diff --git a/hack/dci-merge.sh b/hack/dci-merge.sh index 4d4e48b72..882a2d8f4 100755 --- a/hack/dci-merge.sh +++ b/hack/dci-merge.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright (C) 2023 Red Hat, Inc. +# Copyright (C) 2023, 2024 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -16,6 +16,9 @@ # script called from a merge queue branch of the redhatci/ansible-collection-redhatci-ocp repo +HEAD_SHA="$1" +GITHUB_JOBNAME="DCI / DCI Job" +STATUSES_URL="https://api.github.com/repos/redhatci/ansible-collection-redhatci-ocp/statuses/$HEAD_SHA" VIRT= DCI_QUEUE= SNO_DCI_QUEUE= @@ -38,6 +41,12 @@ GH_HEADERS=( "Authorization: token ${GITHUB_TOKEN}" ) +send_status() { + curl -s "${GH_HEADERS[@]/#/-H}" -X POST -d "{\"state\":\"$1\",\"context\":\"$GITHUB_JOBNAME\"}" "$STATUSES_URL" +} + +set -x + # Lookup the merge commits and get their PR descriptions to detect Test-Hints: strings COMMIT=HEAD VIRT= @@ -143,6 +152,12 @@ export DCI_SILENT=1 cd "$DIR" || exit 1 # shellcheck disable=SC2086 -dci-queue schedule --block -C "$DCI_QUEUE" -- env DCI_SILENT=$DCI_SILENT UPGRADE_ARGS="$UPGRADE_ARGS" RES=@RESOURCE APP_NAME=$APP_NAME APP_ARGS="$APP_ARGS" $BASEDIR/test-runner $VIRT $FORCE_CHECK $TAG $UPGRADE $NO_COMMENT $DIR "$@" $OPTS +if dci-queue schedule --block -C "$DCI_QUEUE" -- env DCI_SILENT=$DCI_SILENT UPGRADE_ARGS="$UPGRADE_ARGS" RES=@RESOURCE APP_NAME=$APP_NAME APP_ARGS="$APP_ARGS" $BASEDIR/test-runner $VIRT $FORCE_CHECK $TAG $UPGRADE $NO_COMMENT $DIR "$@" $OPTS; then + send_status success + exit 0 +else + send_status failure + exit 1 +fi # dci-merge.sh ends here