Skip to content

Commit 02683b3

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 02683b3

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

Diff for: .github/workflows/build.yaml

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

0 commit comments

Comments
 (0)