Skip to content

Commit 7c13783

Browse files
committed
Add initial GitHub Actions support for lutok
This proposed GitHub Actions workflow file runs tests on MacOS and Ubuntu Linux, similar to what is being proposed in freebsd/atf#93 . Signed-off-by: Enji Cooper <[email protected]>
1 parent e891d2e commit 7c13783

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed

.github/workflows/build.yaml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
---
2+
# GitHub action to compile and test lutok on supported platforms.
3+
#
4+
# Steps executed:
5+
# * Handle prerequisites
6+
# * Install binary packages
7+
# * Build packages from source (if needed).
8+
# * Build
9+
# * Install
10+
# * Run tests
11+
#
12+
# On MacOS we build with:
13+
# * latest clang from brew (system provided clang lacks sanitizers).
14+
# * ld from system
15+
#
16+
# Notes re: building with 5.3...
17+
# - In order to build/test with 5.3 on MacOS, we would need to build lutok
18+
# and kyua from scratch (installing via the formula unfortunately picks
19+
# up the binary package).
20+
# - I'm not sure why Ubuntu doesn't distribute the liblua5.3-dev package on
21+
# 24.04.
22+
name: build
23+
on:
24+
pull_request:
25+
branches:
26+
- master
27+
push:
28+
workflow_dispatch:
29+
30+
permissions:
31+
contents: read
32+
33+
jobs:
34+
build:
35+
name: Build ${{ matrix.build-os }} ${{ matrix.compiler }} ${{ matrix.enable-atf }} ${{ matrix.lua }}
36+
runs-on: "${{ matrix.build-os }}"
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
build-os:
41+
- ubuntu-24.04
42+
- macos-latest
43+
enable-atf: [--disable-atf, --enable-atf]
44+
include:
45+
- build-os: macos-latest
46+
compiler: clang-19
47+
# pkgconf comes standard on the MacOS runner.
48+
pkgs:
49+
- llvm@19
50+
- atf
51+
- autoconf
52+
- automake
53+
- libtool
54+
55+
llvm-bindir: /opt/homebrew/opt/llvm/bin
56+
- build-os: ubuntu-24.04
57+
compiler: clang-18
58+
pkgs:
59+
- clang-18
60+
- atf-sh
61+
- libatf-c++-2
62+
- libatf-c-1
63+
- libatf-dev
64+
- autoconf
65+
- automake
66+
- libtool
67+
- kyua
68+
- pkgconf
69+
- liblua5.4-dev
70+
- lua5.4
71+
llvm-bindir: /usr/lib/llvm-18/bin
72+
steps:
73+
- name: Install packages (macOS)
74+
if: runner.os == 'macOS'
75+
run: |
76+
brew update --quiet || true
77+
brew install ${{ join(matrix.pkgs, ' ') }}
78+
# kyua was kicked out of Homebrew due to lack of activity.
79+
# Remove the disabled line and build the latest binary package
80+
# from source.
81+
# Note that it cannot be rebuilt as compiler defaults have changed
82+
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/k/kyua.rb | sed 's/[[:space:]]*disable!.*$//' > kyua.rb
83+
brew install --ignore-dependencies --formula ./kyua.rb
84+
- name: Install packages (Ubuntu)
85+
if: runner.os == 'Linux'
86+
run: |
87+
sudo apt update --quiet
88+
sudo apt --quiet -y --no-install-suggests \
89+
--no-install-recommends install \
90+
${{ join(matrix.pkgs, ' ') }}
91+
- name: Checking out source
92+
uses: actions/checkout@v4
93+
with:
94+
path: src
95+
- name: Setup Environment
96+
run: |
97+
echo "AR=${{ matrix.llvm-bindir }}/llvm-ar" >> "${GITHUB_ENV}"
98+
echo "CC=${{ matrix.llvm-bindir }}/clang" >> "${GITHUB_ENV}"
99+
echo "CPP=${{ matrix.llvm-bindir }}/clang-cpp" >> "${GITHUB_ENV}"
100+
echo "CXX=${{ matrix.llvm-bindir }}/clang++" >> "${GITHUB_ENV}"
101+
echo "NM=${{ matrix.llvm-bindir }}/llvm-nm" >> "${GITHUB_ENV}"
102+
echo "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" >> "${GITHUB_ENV}"
103+
echo "RANLIB=${{ matrix.llvm-bindir }}/llvm-ranlib" >> "${GITHUB_ENV}"
104+
echo "OBJDUMP=${{ matrix.llvm-bindir }}/llvm-objdump" >> "${GITHUB_ENV}"
105+
echo "STRIP=${{ matrix.llvm-bindir }}/llvm-strip" >> "${GITHUB_ENV}"
106+
echo "ATF_SRCDIR=${GITHUB_WORKSPACE}/src" >> "${GITHUB_ENV}"
107+
echo "ATF_OBJDIR=${GITHUB_WORKSPACE}/obj" >> "${GITHUB_ENV}"
108+
echo "ATF_DESTDIR=${GITHUB_WORKSPACE}/installed" >> "${GITHUB_ENV}"
109+
echo "NPROC=`getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1`" >> "${GITHUB_ENV}"
110+
- name: Sanity checks
111+
run: |
112+
which -a kyua
113+
- name: Build ATF
114+
run: |
115+
CFG_OPTS="--disable-dependency-tracking ${{ matrix.enable-atf }}"
116+
CFG_OPTS="${CFG_OPTS} --prefix=${ATF_DESTDIR}"
117+
echo "Building atf with ${CFG_OPTS}..."
118+
echo "uname -a: $(uname -a)"
119+
echo "uname -m: $(uname -m)"
120+
echo "uname -p: $(uname -p)"
121+
echo "Build environment:"
122+
cat "${GITHUB_ENV}"
123+
kyua about | head -1
124+
cd "${ATF_SRCDIR}"
125+
autoreconf -isv -I/usr/local/share/aclocal
126+
mkdir -p "${ATF_OBJDIR}"
127+
cd "${ATF_OBJDIR}"
128+
"${ATF_SRCDIR}/configure" ${CFG_OPTS}
129+
make -j${NPROC} | tee make-all.log
130+
- name: Install ATF
131+
run: |
132+
cd "${ATF_OBJDIR}"
133+
make install
134+
- name: Test Lutok (
135+
if: matrix.enable-atf == '--enable-atf'
136+
run: |
137+
cd "${ATF_OBJDIR}"
138+
make installcheck
139+
check_exit=$?
140+
if [ $check_exit -eq 0 ]; then
141+
echo "# ✅ All mandatory checks passed" >> $GITHUB_STEP_SUMMARY
142+
else
143+
echo "# ❌ Some checks failed" >> $GITHUB_STEP_SUMMARY
144+
echo "::error file=.github/workflows/build.yaml,line=173,endLine=173,title=Checks failed!::checks failed"
145+
fi
146+
cd "${ATF_DESTDIR}/tests/lutok"
147+
kyua report-html --output ${ATF_OBJDIR}/html # produces html subdirectory
148+
# Include the plaintext and JUnit reports.
149+
kyua report --verbose --results-filter=xfail,broken,failed > ${ATF_OBJDIR}/html/test-reportfailed.txt
150+
kyua report-junit --output ${ATF_OBJDIR}/html/test-reportfailed.xml
151+
# Include the kyua log.
152+
cp -a ~/.kyua/logs ${ATF_OBJDIR}/html/
153+
exit $check_exit

0 commit comments

Comments
 (0)