Skip to content

Commit fad134e

Browse files
committed
.github/workflows: refactor the actions
Signed-off-by: Rares-Stefan Goidescu <[email protected]>
1 parent 189c5c4 commit fad134e

File tree

10 files changed

+316
-198
lines changed

10 files changed

+316
-198
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
sudo apt -y update
6+
sudo apt install -y --no-install-recommends \
7+
build-essential \
8+
sudo \
9+
gcc-aarch64-linux-gnu \
10+
g++-aarch64-linux-gnu \
11+
libncurses-dev \
12+
libyaml-dev \
13+
flex \
14+
bison \
15+
git \
16+
wget \
17+
curl \
18+
uuid-runtime \
19+
qemu-kvm \
20+
qemu-system-x86 \
21+
qemu-system-arm \
22+
sgabios \
23+
libarchive-tools \
24+
clang \
25+
xen-utils \
26+
redis-tools
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Enable Docker BuildKit
6+
echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
release_url="https://github.com/firecracker-microvm/firecracker/releases"
4+
latest=v1.7.0
5+
curl -L ${release_url}/download/${latest}/firecracker-${latest}-$(uname -m).tgz | tar -xz
6+
sudo cp release-${latest}-$(uname -m)/firecracker-${latest}-$(uname -m) /usr/local/bin/firecracker-${latest}-$(uname -m)
7+
sudo ln -sfn /usr/local/bin/firecracker-${latest}-$(uname -m) /usr/local/bin/firecracker-$(uname -m)
8+
sudo usermod -a -G kvm $USER
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
test -d /etc/qemu || sudo mkdir -p /etc/qemu
4+
echo "allow all" | sudo tee /etc/qemu/bridge.conf

.github/scripts/tests/run-tests.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Unified test runner. Args: $1=mode ("all" or "musl"), $2=compiler (optional, e.g., "clang").
4+
# Runs setup, finds apps based on dependency, executes tests, captures output, sets results.
5+
6+
set -e
7+
8+
MODE="${1:-all}"
9+
COMPILER="$2"
10+
11+
./setup.sh
12+
13+
if [ -n "$COMPILER" ]; then
14+
export CC="$COMPILER"
15+
fi
16+
17+
if [ "$MODE" = "musl" ]; then
18+
FILTER='\$(LIBS_BASE)/musl'
19+
elif [ "$MODE" = "all" ]; then
20+
FILTER=''
21+
else
22+
echo "Invalid mode: $MODE"
23+
exit 1
24+
fi
25+
26+
apps=$(find . -maxdepth 1 -type d ! -name '.' | while read -r dir; do
27+
if [ -f "$dir/Makefile" ] && ([ -z "$FILTER" ] || grep -q "$FILTER" "$dir/Makefile"); then
28+
echo "$(basename "$dir")"
29+
fi
30+
done)
31+
32+
echo "Testing the following apps (mode: $MODE):"
33+
echo "$apps"
34+
35+
touch output.log
36+
37+
for app in $apps; do
38+
echo "[$app]"
39+
echo ""
40+
cd "$app"
41+
sudo -E ./scripts/test/all.sh 2>&1 | tee -a ../output.log
42+
cd ..
43+
echo ""
44+
done
45+
46+
if grep -q 'FAILED' output.log; then
47+
RESULT='failure'
48+
else
49+
RESULT='success'
50+
fi
51+
52+
echo "result=$RESULT" >> "$GITHUB_OUTPUT"
53+
echo "result_upper=$(echo "$RESULT" | tr 'a-z' 'A-Z')" >> "$GITHUB_OUTPUT"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Generates the markdown test report and appends it to GITHUB_STEP_SUMMARY.
4+
# Assumes output.log exists in the current directory.
5+
#
6+
7+
echo "## Unikraft Catalog Core Test Results" >> "$GITHUB_STEP_SUMMARY"
8+
echo "### $(date -u)" >> "$GITHUB_STEP_SUMMARY"
9+
10+
# Application test results
11+
grep -E '\[.*\]|PASSED|FAILED' output.log | awk '
12+
BEGIN {
13+
print "| Test Suite | Test Name | Status |"
14+
print "|------------|-----------|--------|"
15+
}
16+
/\[.*\]/ {
17+
app=$0
18+
gsub(/\[|\]/, "", app)
19+
next
20+
}
21+
/PASSED|FAILED/ {
22+
split($0, parts, /\.\.\. /)
23+
test_name = $1
24+
status = ($NF == "PASSED") ? "✅ PASSED" : "❌ FAILED"
25+
printf "| %s | %s | %s |\n", app, test_name, status
26+
}' >> "$GITHUB_STEP_SUMMARY"
27+
28+
echo "### System Configuration" >> "$GITHUB_STEP_SUMMARY"
29+
echo "- QEMU Version: $(qemu-system-x86_64 --version | head -n1)" >> "$GITHUB_STEP_SUMMARY"
30+
echo "- Firecracker Version: $(firecracker-$(uname -m) --version 2>&1 | head -n1)" >> "$GITHUB_STEP_SUMMARY"
31+
echo "- Docker Version: $(docker --version)" >> "$GITHUB_STEP_SUMMARY"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Parses the repository payload from the input argument and sets GitHub step outputs.
4+
# Usage: bash parse-repo.sh "<owner>/<repo>"
5+
#
6+
7+
REPO_PAYLOAD="$1"
8+
owner=$(echo "$REPO_PAYLOAD" | cut -d'/' -f1)
9+
repo=$(echo "$REPO_PAYLOAD" | cut -d'/' -f2)
10+
11+
echo "owner=$owner" >> "$GITHUB_OUTPUT"
12+
echo "repo=$repo" >> "$GITHUB_OUTPUT"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
./setup.sh
4+
cd $1
5+
git fetch -fu "https://github.com/$2" "refs/pull/$3/head:pr-branch"
6+
git checkout pr-branch
7+
cd -

0 commit comments

Comments
 (0)