trigger-cloud-tests-run #2998
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 | |
env: | |
STATUS_BRANCH: run-status | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [trigger-cloud-tests-run] | |
jobs: | |
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 | |
reporter: | |
needs: [ kubernetes-jdk11, kubernetes-jdk17 ] | |
if: ${{ always() }} | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
# - name: Output | |
# env: | |
# #MESSAGE: ${{ github.event.client_payload.message }} | |
# MESSAGE: ${{ toJSON(github.event.client_payload) }} | |
# run: echo $MESSAGE | |
# - name: Checkout run-status branch | |
# uses: actions/checkout@v4 | |
# with: | |
# repository: wildfly/wildfly | |
# path: status | |
# | |
- name: Checkout run-status branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.STATUS_BRANCH }} | |
path: status | |
- name: Check Jobs | |
run: | | |
echo "${{ toJSON(needs) }}" | |
if [[ ${{ needs.kubernetes-jdk11.outputs.status }} == "1" ]]; then | |
exit 1 | |
fi | |
if [[ ${{ needs.kubernetes-jdk17.outputs.status }} == "1" ]]; then | |
exit 1 | |
fi | |
- name: Report PR failure | |
if: ${{ github.event.client_payload && failure() }} | |
run: | | |
echo "It failed" | |
STATUS="failed" | |
echo "STATUS=${STATUS}" >> $GITHUB_ENV | |
- name: Report PR success | |
if: ${{ github.event.client_payload && success() }} | |
run: | | |
echo "It passed" | |
STATUS="passed" | |
echo "STATUS=${STATUS}" >> $GITHUB_ENV | |
- name: Checkout PR status branch | |
if: ${{ always() }} | |
uses: actions/checkout@v4 | |
with: | |
path: status | |
ref: ${{ env.STATUS_BRANCH }} | |
- name: Add run status commit | |
if: ${{ always() }} | |
env: | |
TRIGGER_REPO: ${{ github.event.client_payload.triggerRepo }} | |
STATUS_FILE: ${{ github.event.client_payload.statusFile }} | |
working-directory: status | |
run: | | |
echo "Reporting back. Status: $STATUS" | |
RUN_URL="https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
# Don't add a full stop after this sentence as it mangles the URL when output in the calling job | |
TEXT="The remote job $STATUS. Further details can be found at $RUN_URL" | |
COMMIT_TEXT=$( jq -n \ | |
--arg s "$STATUS" \ | |
--arg m "$TEXT" \ | |
--arg orid "$GITHUB_RUN_ID" \ | |
'{status: $s, message: $m, originalId: $orid}' ) | |
echo "${COMMIT_TEXT}" > "${STATUS_FILE}" | |
# git status | |
git config --local user.name "CI Action" | |
git config --local user.email "[email protected]" | |
git add -A | |
# git status | |
git commit -m "Committing status for ${TRIGGER_REPO} ${FILENAME} ${{github.event.client_payload.ref}}" | |
# git status | |
git log | |
i=0 | |
echo "Committed. Attempting to push" | |
git push origin ${STATUS_BRANCH} | |
RESULT=$? | |
echo "result ${RESULT}" | |
while [[ "${RESULT}" != '0' ]] | |
do | |
# Generate random sleep time between 15 and 45 seconds | |
wait=$[ $RANDOM % 45 + 15 ] | |
echo "Sleeping $wait seconds" | |
sleep $wait | |
i=$((i+1)) | |
if [[ "$i" == '10' ]]; then | |
echo "Too many failures trying to push. Giving up." | |
fi | |
echo "Push failed. Trying to fetch, rebase and push again..." | |
git fetch origin ${STATUS_BRANCH} | |
git rebase origin/${STATUS_BRANCH} | |
git push origin ${STATUS_BRANCH} | |
RESULT=$? | |
done |