forked from expressjs/express
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (53 loc) · 2.25 KB
/
integration-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
if [[ "$status" != "completed" ]]; then
echo "Workflow failed. Current status: $status"
exit 1
fi
if [[ "$status" == "completed" ]]; then
echo "Workflow has been completed"
exit 0
fi