Skip to content

Commit 98745cd

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 98745cd

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed

Diff for: .github/workflows/build.yaml

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

0 commit comments

Comments
 (0)