Skip to content

Commit 70a2721

Browse files
craciunoiucrazvand
authored andcommitted
.github/workflows: Introduce catalog tests
Signed-off-by: Cezar Craciunoiu <[email protected]> Approved-by: Razvan Deaconescu <[email protected]> Reviewed-by: Razvan Deaconescu <[email protected]> GitHub-Closes: #54
1 parent 0d1e874 commit 70a2721

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

.github/workflows/integration.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: integration
2+
3+
on:
4+
push:
5+
branches: [staging]
6+
paths-ignore: ['*.md']
7+
8+
jobs:
9+
catalog-tests:
10+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/staging' && github.repository_owner == 'unikraft' }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check idle
14+
run: |
15+
set -e;
16+
17+
today=$(date -u +"%Y-%m-%d");
18+
19+
# Check if there are any ongoing tests (only one repository dispatch exists so we can just check for the status)
20+
# We need to check separately for each status because the API does not support multiple statuses
21+
idle_queued=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status queued 2> /dev/null)
22+
idle_in_progress=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status in_progress 2> /dev/null)
23+
idle_requested=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status requested 2> /dev/null)
24+
idle_waiting=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status waiting 2> /dev/null)
25+
if [ -n "$idle_queued" ] || [ -n "$idle_in_progress" ] || [ -n "$idle_requested" ] || [ -n "$idle_waiting" ]; then
26+
sudo apt-get update;
27+
sudo apt-get install -y jq;
28+
echo "There are idle tests, try again later:";
29+
echo "Queued:";
30+
jq "$idle_queued";
31+
echo "In Progress:";
32+
jq "$idle_in_progress";
33+
echo "Requested:";
34+
jq "$idle_requested";
35+
echo "Waiting:";
36+
jq "$idle_waiting";
37+
exit 1;
38+
fi
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GH_CATALOG_PAT }}
41+
42+
- name: Get the start time
43+
id: start_time
44+
run: echo "start=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"
45+
46+
- name: Repository Dispatch
47+
uses: octokit/[email protected]
48+
with:
49+
route: POST /repos/{owner}/{repo}/dispatches
50+
owner: unikraft
51+
repo: catalog
52+
event_type: lwip_merge
53+
client_payload: '{"id": "${{ github.run_id }}"}'
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GH_CATALOG_PAT }}
56+
57+
- name: Fetch catalog results
58+
run: |
59+
set -e;
60+
61+
sudo apt-get update;
62+
sudo apt-get install -y jq;
63+
64+
today=$(date -u +"%Y-%m-%d");
65+
stop=$(date -u +"%Y-%m-%dT%H:%M:%SZ");
66+
start="${{ steps.start_time.outputs.start }}";
67+
68+
for _ in {1..60}; do
69+
# If there are more than 100 tests, the list will be truncated
70+
# TODO(craciunoiuc): Implement pagination or filter only for not concluded tests
71+
joutput=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 100 --created "$today" --json displayTitle,conclusion,createdAt);
72+
73+
# Check all the tests if they are successful
74+
# If there is a failure, the workflow will fail-fast
75+
# Filter out tests that were created after $start and before stop and pick only the ones that have the displayTitle==lwip_merge
76+
fail_output=$(echo "$joutput" | jq -r -c -M --arg start "$start" --arg stop "$stop" '.[] | select(.createdAt <= $stop) | select(.createdAt >= $start) | select(.displayTitle == "lwip_merge") | select(.conclusion == "failure")');
77+
if [ -n "$fail_output" ]; then
78+
echo "There are failed tests:";
79+
jq "$fail_output";
80+
exit 1;
81+
fi
82+
83+
# If there are tests that are on-going still, we will wait for them to finish
84+
# Filter out tests that were created after $start and before stop and pick only the ones that have the displayTitle==lwip_merge
85+
ongoing_output=$(echo "$joutput" | jq -r -c -M --arg start "$start" --arg stop "$stop" '.[] | select(.createdAt <= $stop) | select(.createdAt >= $start) | select(.displayTitle == "lwip_merge") | select(.conclusion == "")')
86+
if [ -z "$ongoing_output" ]; then
87+
echo "All tests have finished successfully";
88+
exit 0;
89+
fi
90+
91+
sleep 30;
92+
done
93+
echo "Timeout waiting for tests to finish";
94+
exit 1;
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GH_CATALOG_PAT }}
97+
98+
99+
merge-stable:
100+
needs: [catalog-tests]
101+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/staging' && github.repository_owner == 'unikraft' }}
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
with:
106+
fetch-depth: 0
107+
ref: staging
108+
109+
- name: Merge stable
110+
run: |
111+
set -e;
112+
113+
git pull origin stable;
114+
git checkout --track origin/stable;
115+
git rebase staging;
116+
git push origin stable;

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
.\#_*
1616
!.gitignore
1717
.*
18+
!.github/
1819

1920
# gnu global files
2021
GPATH

0 commit comments

Comments
 (0)