-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (63 loc) · 2.33 KB
/
Copy pathintegration-test.yml
File metadata and controls
71 lines (63 loc) · 2.33 KB
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
65
66
67
68
69
70
71
name: Integration Test
on:
pull_request:
branches: [ "main" ]
jobs:
integration-test:
runs-on: ubuntu-latest
steps:
- name: Trigger and wait for integration test
env:
GH_TOKEN: ${{ secrets.FMSG_DOCKER_PAT }}
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
FMSGD_REF="$PR_BRANCH"
matching_ref() {
if gh api "repos/markmnl/$1/git/ref/heads/$PR_BRANCH" >/dev/null 2>&1; then
printf '%s\n' "$PR_BRANCH"
else
echo main
fi
}
DOCKER_REF=$(matching_ref fmsg-docker)
WEBAPI_REF=$(matching_ref fmsg-webapi)
ID_REF=$(matching_ref fmsgid)
CLI_REF=$(matching_ref fmsg-cli)
DISPATCH_STARTED=$(date -u +%Y-%m-%dT%H:%M:%SZ)
# Coordinated schema/API changes use their companion branches.
gh workflow run integration-test.yml \
--repo markmnl/fmsg-docker \
--ref "$DOCKER_REF" \
-f fmsgd_ref="$FMSGD_REF" \
-f fmsg_webapi_ref="$WEBAPI_REF" \
-f fmsgid_ref="$ID_REF" \
-f fmsg_cli_ref="$CLI_REF"
echo "Triggered integration test for fmsgd_ref=$FMSGD_REF, polling for run..."
# Poll until we find the run matching our fmsgd_ref
RUN_ID=""
for i in $(seq 1 30); do
sleep 10
RUN_ID=$(gh run list \
--repo markmnl/fmsg-docker \
--workflow integration-test.yml \
--event workflow_dispatch \
--branch "$DOCKER_REF" \
--created ">=$DISPATCH_STARTED" \
--limit 10 \
--json databaseId,displayTitle \
| jq -r --arg ref "$FMSGD_REF" '.[] | select(.displayTitle | contains($ref)) | .databaseId' \
| head -1)
if [ -n "$RUN_ID" ]; then
break
fi
echo "Attempt $i: run not found yet..."
done
if [ -z "$RUN_ID" ]; then
echo "::error::Timed out waiting for integration test run to appear"
exit 1
fi
echo "Found run $RUN_ID, waiting for completion..."
# Wait for completion and exit with its status
gh run watch "$RUN_ID" \
--repo markmnl/fmsg-docker \
--exit-status