Skip to content

Commit 05e7fe2

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 05e7fe2

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

Diff for: .github/workflows/build.yaml

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

0 commit comments

Comments
 (0)