Skip to content

test extended tests #24

test extended tests

test extended tests #24

name: Integration Tests
on:
- pull_request
- push
jobs:
e2e_tests:
runs-on: ubuntu-latest
steps:
- name: Get the branch name
id: get_branch
run: echo "branch=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})" >> $GITHUB_OUTPUT
- name: Get the originating repository
id: get_repo
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "repo=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_OUTPUT
else
echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT
fi
- name: Repository Dispatch
env:
TOKEN: ${{ secrets.PAT_INTEGRATION_TESTS }}
run: |
curl -X POST https://api.github.com/repos/UlisesGascon/express-examples/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H "Authorization: token $TOKEN" \
--data '{"event_type": "integration-tests", "client_payload": {"branch": "${{ steps.get_branch.outputs.branch }}", "repo": "${{ steps.get_repo.outputs.repo }}"}}'
# Wait for the workflow to start
sleep 60
# Get the latest workflow run
response=$(curl -H "Authorization: token $TOKEN" https://api.github.com/repos/UlisesGascon/express-examples/actions/runs)
workflow_url=$(echo "$response" | jq -r '.workflow_runs[0].url')
status=""
start_time=$(date +%s)
timeout=$((10 * 60)) # timeout after 10 minutes
while [[ "$status" != "completed" && $(( $(date +%s) - start_time )) -lt $timeout ]]; do
echo "checking..."
sleep 10
response=$(curl -H "Authorization: token $TOKEN" $workflow_url)
status=$(echo "$response" | jq -r .status)
echo "current status: $status"
done
if [[ $(( $(date +%s) - start_time )) -ge $timeout ]]; then
echo "Workflow did not complete within the expected time"
fi
# Get the conclusion of the workflow run
conclusion=$(echo "$response" | jq -r .conclusion)
if [[ "$status" == "completed" && "$conclusion" != "success" ]]; then
echo "Workflow completed but failed. Conclusion: $conclusion"
exit 1
fi
if [[ "$status" == "completed" && "$conclusion" == "success" ]]; then
echo "Workflow has been completed successfully"
exit 0
fi