Skip to content

Commit

Permalink
.github/workflows: Introduce catalog tests
Browse files Browse the repository at this point in the history
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #20
  • Loading branch information
craciunoiuc authored and razvand committed Dec 20, 2024
1 parent e728010 commit 61baeeb
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: integration

on:
push:
branches: [staging]
paths-ignore: ['*.md']

jobs:
catalog-tests:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/staging' && github.repository_owner == 'unikraft' }}
runs-on: ubuntu-latest
steps:
- name: Check idle
run: |
set -e;
today=$(date -u +"%Y-%m-%d");
# Check if there are any ongoing tests (only one repository dispatch exists so we can just check for the status)
# We need to check separately for each status because the API does not support multiple statuses
idle_queued=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status queued 2> /dev/null)
idle_in_progress=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status in_progress 2> /dev/null)
idle_requested=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status requested 2> /dev/null)
idle_waiting=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 200 --created "$today" --status waiting 2> /dev/null)
if [ -n "$idle_queued" ] || [ -n "$idle_in_progress" ] || [ -n "$idle_requested" ] || [ -n "$idle_waiting" ]; then
sudo apt-get update;
sudo apt-get install -y jq;
echo "There are idle tests, try again later:";
echo "Queued:";
jq "$idle_queued";
echo "In Progress:";
jq "$idle_in_progress";
echo "Requested:";
jq "$idle_requested";
echo "Waiting:";
jq "$idle_waiting";
exit 1;
fi
env:
GITHUB_TOKEN: ${{ secrets.GH_CATALOG_PAT }}

- name: Get the start time
id: start_time
run: echo "start=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"

- name: Repository Dispatch
uses: octokit/request-action@v2.x
with:
route: POST /repos/{owner}/{repo}/dispatches
owner: unikraft
repo: catalog
event_type: compiler-rt_merge
client_payload: '{"id": "${{ github.run_id }}"}'
env:
GITHUB_TOKEN: ${{ secrets.GH_CATALOG_PAT }}

- name: Fetch catalog results
run: |
set -e;
sudo apt-get update;
sudo apt-get install -y jq;
today=$(date -u +"%Y-%m-%d");
stop=$(date -u +"%Y-%m-%dT%H:%M:%SZ");
start="${{ steps.start_time.outputs.start }}";
for _ in {1..60}; do
# If there are more than 100 tests, the list will be truncated
# TODO(craciunoiuc): Implement pagination or filter only for not concluded tests
joutput=$(gh run list --repo unikraft/catalog --event repository_dispatch --limit 100 --created "$today" --json displayTitle,conclusion,createdAt);
# Check all the tests if they are successful
# If there is a failure, the workflow will fail-fast
# Filter out tests that were created after $start and before stop and pick only the ones that have the displayTitle==compiler-rt_merge
fail_output=$(echo "$joutput" | jq -r -c -M --arg start "$start" --arg stop "$stop" '.[] | select(.createdAt <= $stop) | select(.createdAt >= $start) | select(.displayTitle == "compiler-rt_merge") | select(.conclusion == "failure")');
if [ -n "$fail_output" ]; then
echo "There are failed tests:";
jq "$fail_output";
exit 1;
fi
# If there are tests that are on-going still, we will wait for them to finish
# Filter out tests that were created after $start and before stop and pick only the ones that have the displayTitle==compiler-rt_merge
ongoing_output=$(echo "$joutput" | jq -r -c -M --arg start "$start" --arg stop "$stop" '.[] | select(.createdAt <= $stop) | select(.createdAt >= $start) | select(.displayTitle == "compiler-rt_merge") | select(.conclusion == "")')
if [ -z "$ongoing_output" ]; then
echo "All tests have finished successfully";
exit 0;
fi
sleep 30;
done
echo "Timeout waiting for tests to finish";
exit 1;
env:
GITHUB_TOKEN: ${{ secrets.GH_CATALOG_PAT }}


merge-stable:
needs: [catalog-tests]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/staging' && github.repository_owner == 'unikraft' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: staging

- name: Merge stable
run: |
set -e;
git pull origin stable;
git checkout --track origin/stable;
git rebase staging;
git push origin stable;
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.\#_*
!.gitignore
.*
!.github/

# gnu global files
GPATH
Expand Down

0 comments on commit 61baeeb

Please sign in to comment.