Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test extended tests #4

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 48 additions & 7 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- push

jobs:
dispatch:
e2e_tests:
runs-on: ubuntu-latest
steps:
- name: Get the branch name
Expand All @@ -22,9 +22,50 @@ jobs:
fi

- name: Repository Dispatch
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
with:
token: "${{ secrets.PAT_INTEGRATION_TESTS}}"
repository: expressjs/examples
event-type: integration-tests
client-payload: '{"branch": "${{ steps.get_branch.outputs.branch }}", "repo": "${{ steps.get_repo.outputs.repo }}"}'
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)

# Get the URL of the workflow run
html_url=$(echo "$response" | jq -r .html_url)
echo "Check the workflow run for details: $html_url"

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
Loading