diff --git a/.github/workflows/ci-e2e.yml b/.github/workflows/ci-e2e.yml new file mode 100644 index 0000000..b42663d --- /dev/null +++ b/.github/workflows/ci-e2e.yml @@ -0,0 +1,60 @@ +name: E2E Test + +on: + pull_request: + +permissions: {} + +jobs: + e2e-test: + name: E2E Integration Test + runs-on: ubuntu-latest + + steps: + - name: Send message to consumer to publish + id: send-message + run: | + echo "SHA: ${{ github.sha }}" + curl -s -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.PAT }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/immutable-actions/test-publish-internal-ts-action/dispatches \ + -d '{"event_type":"e2e-test","client_payload":{"unit":false,"integration":true,"sha":"${{ github.sha }}"}}' + - name: Wait for successful publish + id: wait-for-successful-publish + run: | + START_TIME=$SECONDS + TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + while (( SECONDS - START_TIME < 60 )); do + echo "Polling for workflow created after $TIMESTAMP" + RESULT=$(curl -s -L -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.PAT }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/immutable-actions/test-publish-internal-ts-action/actions/runs?created=>$TIMESTAMP" \ + | jq '.workflow_runs[] | select(.name=="Publish Actions Package" and (.display_title | contains("${{ github.sha }}"))) | .status, .conclusion') + + # split the RESULT into an array + RESULT=($RESULT) + STATUS=$(echo ${RESULT[0]} | sed -e 's/^"//' -e 's/"$//') + CONCLUSION=$(echo ${RESULT[1]} | sed -e 's/^"//' -e 's/"$//') + if [ -z "$STATUS" ]; then + echo "No workflow found yet" + else + echo "Workflow status: $STATUS" + echo "Workflow conclusion: $CONCLUSION" + if [ "$STATUS" = "completed" ]; then + if [ "$CONCLUSION" = "success" ]; then + echo "workflow succeeded" + exit 0 + elif [ "$CONCLUSION" = "failure" ]; then + echo "workflow failed" + exit 1 + fi + fi + fi + + sleep 1 + done + exit 2