Skip to content

Commit 4d2a622

Browse files
committed
copy GitHub Actions from CPUID project
Signed-off-by: Steven Noonan <[email protected]>
1 parent 2778373 commit 4d2a622

File tree

6 files changed

+150
-0
lines changed

6 files changed

+150
-0
lines changed

.github/install-fedora.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
#
3+
# This is an install script for Fedora-specific packages.
4+
#
5+
set -ex
6+
7+
# Base build packages
8+
PACKAGES=(
9+
git
10+
gcc
11+
compiler-rt
12+
libasan
13+
libubsan
14+
clang
15+
meson
16+
perl
17+
pkgconf-pkg-config
18+
which
19+
)
20+
21+
dnf install -y "${PACKAGES[@]}"

.github/install-post.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
#
3+
# This is a post-install script common to all Docker images.
4+
#
5+
set -x
6+
meson --version
7+
g++ --version
8+
clang++ --version
9+
lsb_release -a
10+
exit 0

.github/install-ubuntu.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
#
3+
# This is an install script for Ubuntu-specific packages.
4+
#
5+
set -ex
6+
7+
export DEBIAN_FRONTEND=noninteractive
8+
9+
apt-get update
10+
apt-get install -y locales
11+
locale-gen en_US.UTF-8
12+
13+
PACKAGES=(git build-essential pkg-config meson clang perl lsb-release)
14+
15+
apt-get install -y "${PACKAGES[@]}"

.github/install.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
. .github/install-${IMAGE//\//-}.sh

.github/script.sh

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
#
3+
# This is a distribution-agnostic build script. Do not use "apt-get", "dnf", or
4+
# similar in here. Add any package installation gunk into the appropriate
5+
# install script instead.
6+
#
7+
set -ex
8+
9+
rm -rf build-{a,ub,t}san build-meson
10+
11+
case $COMPILER in
12+
gcc)
13+
export CC=gcc
14+
export CXX=g++
15+
;;
16+
clang)
17+
export CC=clang
18+
export CXX=clang++
19+
esac
20+
21+
22+
MESON_ARGS=()
23+
BUILD_VARIANTS=(meson)
24+
25+
BUILD_SANITIZERS=1
26+
[[ $(uname -s) == MINGW* ]] && BUILD_SANITIZERS=0
27+
28+
if lsb_release -c | grep -q bionic$; then
29+
export ASAN_OPTIONS=detect_odr_violation=0
30+
fi
31+
32+
meson . build-meson -Dbuildtype=release -Ddebug=false -Db_lto=true
33+
34+
# Build some tests with sanitizers
35+
if [[ $BUILD_SANITIZERS -ne 0 ]]; then
36+
BUILD_VARIANTS+=(asan ubsan)
37+
meson . build-asan -Db_sanitize=address
38+
meson . build-ubsan -Db_sanitize=undefined
39+
if [[ ${CXX} == *clang* ]]; then
40+
BUILD_VARIANTS+=(tsan)
41+
meson . build-tsan -Db_sanitize=thread
42+
fi
43+
fi
44+
45+
# Test CMake build too
46+
BUILD_VARIANTS+=(cmake)
47+
cmake -G Ninja -S . -B build-cmake
48+
49+
# Build all targets of meson, ensuring everything can build.
50+
for BUILD_VARIANT in ${BUILD_VARIANTS[@]}; do
51+
ninja -C build-${BUILD_VARIANT}
52+
done
53+
54+
# Ensure plain makefile build works too
55+
make
56+
57+
# Run basic tests
58+
for BUILD_VARIANT in . ${BUILD_VARIANTS[@]}; do
59+
BUILD_DIR=build-$BUILD_VARIANT
60+
[[ "$BUILD_VARIANT" == "." ]] && BUILD_DIR=.
61+
pushd $BUILD_DIR
62+
./clockperf
63+
popd
64+
[[ "$BUILD_VARIANT" != "." ]] && rm -rf build-$BUILD_VARIANT
65+
done

.github/workflows/build.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
name: BuildAndTest
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
build: [ubuntu-latest, ubuntu-rolling, fedora-latest]
11+
compiler: [gcc, clang]
12+
include:
13+
- build: ubuntu-latest
14+
os: ubuntu-latest
15+
docker_image: ubuntu
16+
docker_tag: latest
17+
- build: ubuntu-rolling
18+
os: ubuntu-latest
19+
docker_image: ubuntu
20+
docker_tag: rolling
21+
- build: fedora-latest
22+
os: ubuntu-latest
23+
docker_image: fedora
24+
docker_tag: latest
25+
steps:
26+
- uses: actions/checkout@master
27+
- name: Launch container
28+
run: |
29+
docker run -d --rm --name github-docker-builder -e LC_ALL="C" -e LANG="C" -v ${{ github.workspace }}:/build -w /build ${{ matrix.docker_image }}:${{ matrix.docker_tag }} tail -f /dev/null
30+
docker ps
31+
- name: Install dependencies
32+
run: |
33+
docker exec -e COMPILER=${{ matrix.compiler }} -e IMAGE=${{ matrix.docker_image }} -e IMAGE_TAG=${{ matrix.docker_tag }} -t github-docker-builder bash .github/install.sh
34+
docker exec -e COMPILER=${{ matrix.compiler }} -e IMAGE=${{ matrix.docker_image }} -e IMAGE_TAG=${{ matrix.docker_tag }} -t github-docker-builder bash .github/install-post.sh
35+
- name: Build and run project
36+
run: |
37+
docker exec -e COMPILER=${{ matrix.compiler }} -e IMAGE=${{ matrix.docker_image }} -e IMAGE_TAG=${{ matrix.docker_tag }} -t github-docker-builder bash .github/script.sh

0 commit comments

Comments
 (0)