Skip to content

.github/workflows: Add tests for core libs and apps #5

.github/workflows: Add tests for core libs and apps

.github/workflows: Add tests for core libs and apps #5

Workflow file for this run

name: test-all

Check failure on line 1 in .github/workflows/test-all.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/test-all.yml

Invalid workflow file

(Line: 67, Col: 9): Unexpected value 'run'
on:
schedule:
- cron: '0 1 * * *' # 1 AM UTC daily
repository_dispatch:
types: [unikraft_pr]
workflow_dispatch: # Manual trigger
jobs:
test-all:
runs-on: ubuntu-latest
steps:
- name: Parse Repository Info
if: github.event_name == 'repository_dispatch'
id: parse_repo
run: |
REPO_PAYLOAD="${{ github.event.client_payload.pr_repo }}"
echo "owner=$(echo $REPO_PAYLOAD | cut -d'/' -f1)" >> $GITHUB_OUTPUT
echo "repo=$(echo $REPO_PAYLOAD | cut -d'/' -f2)" >> $GITHUB_OUTPUT
- name: Generate GitHub App Token
if: github.event_name == 'repository_dispatch'
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ steps.parse_repo.outputs.owner }}
repositories: ${{ steps.parse_repo.outputs.repo }}
- name: Create Initial Check Run
if: github.event_name == 'repository_dispatch'
uses: octokit/[email protected]
id: create_check
with:
route: POST /repos/{owner}/{repo}/check-runs
owner: ${{ steps.parse_repo.outputs.owner }}
repo: ${{ steps.parse_repo.outputs.repo }}
name: "Catalog Core Tests"
head_sha: ${{ github.event.client_payload.pr_sha }}
status: 'in_progress'
started_at: ${{ github.event.client_payload.start_time }}
output: |
{
"title": "Tests are running...",
"summary": "The Unikraft Catalog Core tests have been triggered. [View Progress](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
}
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
- name: Checkout test branch
uses: actions/checkout@v4
with:
ref: test
- name: Pull .github scripts from main
uses: actions/checkout@v4
with:
ref: main
sparse-checkout: |
.github/scripts
sparse-checkout-cone-mode: false
- name: Setup Docker
uses: docker/setup-buildx-action@v3
run: bash .github/scripts/setup/docker-setup.sh
- name: Install base dependencies
run: bash .github/scripts/base-dependencies.sh
- name: Setup QEMU networking
run: |
./.github/workflows/scripts/setup-qemu.sh
- name: Install Firecracker
run: |
./.github/workflows/scripts/setup-firecracker.sh
- name: Checkout Unikraft PR Branch
if: github.event_name == 'repository_dispatch'
run: |
./.github/workflows/scripts/setup-firecracker.sh /repos/unikraft ${{ github.event.client_payload.pr_repo }} ${{ github.event.client_payload.pr_number }}
- name: Run tests
id: run-tests
run: |
# sudo -E ./test.overall.sh 2>&1 | tee -a output.log
cd c-fs
CC=clang
sudo -E ./scripts/test/all.sh 2>&1 | tee -a ../output.log
RESULT=$(grep -q 'FAILED' output.log && echo 'failure' || echo 'success')
echo "result=$RESULT" >> $GITHUB_OUTPUT
echo "result_upper=$(echo $RESULT | tr 'a-z' 'A-Z')" >> $GITHUB_OUTPUT
- name: Get the completion time
id: completion_time
run: echo "completion_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"
- name: Update Final Check Run
if: always() && github.event_name == 'repository_dispatch'
uses: octokit/[email protected]
with:
route: PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}
owner: ${{ steps.parse_repo.outputs.owner }}
repo: ${{ steps.parse_repo.outputs.repo }}
check_run_id: ${{ fromJson(steps.create_check.outputs.data).id }}
status: 'completed'
# conclusion: ${{ steps.run-tests.outputs.result }}
conclusion: ${{ steps.run-tests.outputs.result || job.status }}
started_at: ${{ github.event.client_payload.start_time }}
completed_at: ${{ steps.completion_time.outputs.completion_time }}
output: |
{
"title": "Test run complete: ${{ steps.run-tests.outputs.result_upper || (job.status == 'cancelled' && 'CANCELED' || 'FAILED') }}",
"summary": "The Catalog Core tests have finished. [View Full Logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
}
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
- name: Generate test report
if: always()
run: |
echo "## Unikraft Catalog Core Test Results" >> $GITHUB_STEP_SUMMARY
echo "### $(date -u)" >> $GITHUB_STEP_SUMMARY
# Application test results
grep -E '\[.*\]|PASSED|FAILED' output.log | awk '
BEGIN {
print "| Test Suite | Test Name | Status |"
print "|------------|-----------|--------|"
}
/\[.*\]/ {
app=$0
gsub(/\[|\]/, "", app)
next
}
/PASSED|FAILED/ {
split($0, parts, /\.\.\. /)
test_name = $1
status = ($NF == "PASSED") ? "✅ PASSED" : "❌ FAILED"
printf "| %s | %s | %s |\n", app, test_name, status
}' >> $GITHUB_STEP_SUMMARY
echo "### System Configuration" >> $GITHUB_STEP_SUMMARY
echo "- QEMU Version: $(qemu-system-x86_64 --version | head -n1)" >> $GITHUB_STEP_SUMMARY
echo "- Firecracker Version: $(firecracker-$(uname -m) --version 2>&1 | head -n1)" >> $GITHUB_STEP_SUMMARY
echo "- Docker Version: $(docker --version)" >> $GITHUB_STEP_SUMMARY
- name: Archive test artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: catalog-core-test-logs-${{ github.run_id }}
path: |
output.log
*/scripts/test/log/*
retention-days: 7