trigger-cloud-tests-pr #5337
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Tests for PR | |
env: | |
TOKEN: ${{ secrets.CLOUD_TESTS_REMOTE_DISPATCH_TOKEN }} | |
TRIGGER_REPOSITORY: ${{ github.event.client_payload.triggerRepo }} | |
PR_HEAD_SHA: ${{ github.event.client_payload.prHeadSha }} | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [trigger-cloud-tests-pr] | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.client_payload.triggerRepo }}#${{ github.event.client_payload.pr }}' | |
cancel-in-progress: true | |
jobs: | |
report-in-progress: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
env: | |
REPORTER_EVENT_TYPE: report-cloud-tests-pr-pending | |
steps: | |
- name: Output | |
env: | |
MESSAGE: ${{ toJSON(github.event.client_payload) }} | |
run: echo $MESSAGE | |
- name: Report Progress | |
if: ${{ env.TOKEN }} | |
run: | | |
STATUS="pending" | |
RUN_URL="https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
DESC="Running Tests" | |
CLIENT_PAYLOAD=$( jq -n \ | |
--arg prHeadSha "$PR_HEAD_SHA" \ | |
--arg state "$STATUS" \ | |
--arg runUrl "$RUN_URL" \ | |
--arg desc "$DESC" \ | |
'{prHeadSha: $prHeadSha, state: $state, runUrl: $runUrl, desc: $desc}' ) | |
echo "CLIENT_PAYLOAD: $CLIENT_PAYLOAD" | |
set -x | |
resp=$(curl -X POST -s "https://api.github.com/repos/${TRIGGER_REPOSITORY}/dispatches" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer ${TOKEN}" \ | |
-d "{\"event_type\": \"${REPORTER_EVENT_TYPE}\", \"client_payload\": ${CLIENT_PAYLOAD} }") | |
set +x | |
if [ -z "$resp" ] | |
then | |
sleep 2 | |
else | |
echo "Workflow failed to trigger" | |
echo "$resp" | |
exit 1 | |
fi | |
# kubernetes-jdk11: | |
# uses: ./.github/workflows/wildfly-cloud-tests-callable.yml | |
# with: | |
# runtimeImage: quay.io/wildfly/wildfly-runtime:latest-jdk11 | |
# type: Kubernetes | |
kubernetes-jdk17: | |
uses: ./.github/workflows/wildfly-cloud-tests-callable.yml | |
with: | |
runtimeImage: quay.io/wildfly/wildfly-runtime:latest-jdk17 | |
type: Kubernetes | |
kubernetes-jdk21: | |
uses: ./.github/workflows/wildfly-cloud-tests-callable.yml | |
with: | |
runtimeImage: quay.io/wildfly/wildfly-runtime:latest-jdk21 | |
type: Kubernetes | |
reporter-completed: | |
needs: [ kubernetes-jdk17, kubernetes-jdk21 ] | |
if: ${{ always() }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
env: | |
REPORTER_EVENT_TYPE: report-cloud-tests-pr-complete | |
steps: | |
- name: Output | |
env: | |
#MESSAGE: ${{ github.event.client_payload.message }} | |
MESSAGE: ${{ toJSON(github.event.client_payload) }} | |
run: echo $MESSAGE | |
- name: Check Jobs | |
run: | | |
echo "${{ toJSON(needs) }}" | |
if [[ ${{ needs.kubernetes-jdk17.outputs.status }} == "1" ]]; then | |
exit 1 | |
fi | |
if [[ ${{ needs.kubernetes-jdk21.outputs.status }} == "1" ]]; then | |
exit 1 | |
fi | |
- name: Remote Dispatch to report job complete | |
if: ${{ env.TOKEN }} && ${{ always() }} | |
run: | | |
STATUS=${{ job.status }} | |
if [ "${STATUS}" == "success" ]; then | |
TEXT="The job passed!" | |
else | |
# The statuses API doesn't have a 'cancelled' status, just error, failure, pending and success | |
# So treat everything that is not a success as a failure | |
STATUS="failure" | |
TEXT="The job failed, or was cancelled" | |
fi | |
echo $GITHUB_REPOSITORY | |
RUN_URL="https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
DESC="Running Tests" | |
CLIENT_PAYLOAD=$( jq -n \ | |
--arg prHeadSha "$PR_HEAD_SHA" \ | |
--arg state "$STATUS" \ | |
--arg runUrl "$RUN_URL" \ | |
--arg desc "$TEXT" \ | |
'{prHeadSha: $prHeadSha, state: $state, runUrl: $runUrl, desc: $desc}' ) | |
echo "CLIENT_PAYLOAD: $CLIENT_PAYLOAD" | |
resp=$(curl -X POST -s "https://api.github.com/repos/${TRIGGER_REPOSITORY}/dispatches" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer ${TOKEN}" \ | |
-d "{\"event_type\": \"${REPORTER_EVENT_TYPE}\", \"client_payload\": ${CLIENT_PAYLOAD} }") | |
if [ -z "$resp" ] | |
then | |
sleep 2 | |
else | |
echo "Workflow failed to trigger" | |
echo "$resp" | |
exit 1 | |
fi |