Skip to content

Commit

Permalink
ci: parameters for build matrix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
anwayde committed Jun 26, 2024
1 parent b71945c commit de518f5
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 33 deletions.
55 changes: 42 additions & 13 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,60 @@
name: Builds
on:
workflow_call:
inputs:
targets:
type: string
description: Build targets
default: all,fdctl
machines:
type: string
description: Build architectures
default: linux_gcc_x86_64,linux_clang_x86_64
gcc:
type: string
description: GCC compiler versions
default: gcc-8.5.0,gcc-12.4.0
clang:
type: string
description: Clang compiler versions
default: clang-17.0.6
workflow_dispatch:
merge_group:
inputs:
targets:
type: string
description: Build targets (comma-separated)
default: all,fdctl
machines:
type: string
description: Build architectures (comma-separated)
default: linux_gcc_x86_64,linux_clang_x86_64
gcc:
type: string
description: GCC compiler versions (comma-separated)
default: gcc-8.5.0,gcc-12.4.0
clang:
type: string
description: Clang compiler versions (comma-separated)
default: clang-17.0.6
concurrency:
group: builds_${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: X64
env:
machines: linux_gcc_x86_64
gcc: gcc-8.5.0
targets: all
runs-on: 512G
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: ./.github/actions/deps

- uses: dtolnay/[email protected]

- uses: ./.github/actions/deps

- name: Start build
run: |
contrib/build.sh \
--no-deps --no-clang \
--targets $targets \
--gcc-versions $gcc \
--machines $machines
contrib/build.sh --no-deps --no-rust \
--targets ${{ inputs.targets }} \
--machines ${{ inputs.machines }} \
--gcc-versions ${{ inputs.gcc || 'none --no-gcc' }} \
--clang-versions ${{ inputs.clang || 'none --no-clang' }}
62 changes: 42 additions & 20 deletions contrib/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ while [[ $# -gt 0 ]]; do
"--no-deps")
NO_DEPS=1
;;
"--no-rust")
NO_RUST=1
;;
"--targets")
IFS=',' read -r -a TARGETS <<< "$1"
shift 1
Expand Down Expand Up @@ -57,36 +60,42 @@ FD_REPO_DIR=$(realpath $(dirname $(realpath "$0"))/..)
TEST_TARGETS=( unit-test fuzz-test integration-test )
BUILD_TARGETS=( all )
EXTRA_TARGETS=( asm ppp seccomp-policies )

BINARY_TARGETS=( fdctl fddev )
NONBINARY_TARGETS=( ${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]} )

declare -A CUSTOM_TARGETS=()

CUSTOM_TARGETS+=( ["linux_gcc_minimal"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_gcc_noarch64"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_gcc_noarch128"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_gcc_minimal"]="${NONBINARY_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_gcc_noarch64"]="${NONBINARY_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_gcc_noarch128"]="${NONBINARY_TARGETS[@]}" )

CUSTOM_TARGETS+=( ["macos_clang_m1"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_clang_minimal"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_clang_noarch64"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_clang_noarch128"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["freebsd_clang_noarch128"]="${BUILD_TARGETS[@]} ${EXTRA_TARGETS[@]} ${TEST_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["macos_clang_m1"]="${NONBINARY_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_clang_minimal"]="${NONBINARY_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_clang_noarch64"]="${NONBINARY_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["linux_clang_noarch128"]="${NONBINARY_TARGETS[@]}" )
CUSTOM_TARGETS+=( ["freebsd_clang_noarch128"]="${NONBINARY_TARGETS[@]}" )

FAIL=0

if [[ ${#GCC[@]} -eq 0 ]]; then
if [[ $NO_GCC -ne 1 ]]; then
if [[ $NO_GCC -ne 1 ]]; then
if [[ ${#GCC[@]} -eq 0 ]]; then
for gcc in $(ls /opt/gcc); do
GCC+=( $gcc )
done
fi
else
GCC=()
fi

if [[ ${#CLANG[@]} -eq 0 ]]; then
if [[ $NO_CLANG -ne 1 ]]; then
if [[ $NO_CLANG -ne 1 ]]; then
if [[ ${#CLANG[@]} -eq 0 ]]; then
for clang in $(ls /opt/clang); do
CLANG+=( $clang )
done
fi
else
CLANG=()
fi

if [[ ${#MACHINES[@]} -eq 0 ]]; then
Expand All @@ -105,8 +114,7 @@ echo

echo "Setting up build environment..."
cd $FD_REPO_DIR
if [[ $NO_DEPS -ne 1 ]]; then
FD_AUTO_INSTALL_PACKAGES=1 ./deps.sh fetch check install > /dev/null 2>&1
if [[ $NO_RUST -ne 1 ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y > /dev/null 2>&1
fi
make -j distclean > /dev/null 2>&1
Expand All @@ -117,6 +125,15 @@ if [[ $NO_GCC -ne 1 ]]; then
START=$(date +%s)
echo "Starting gcc builds..."
for compiler in "${GCC[@]}"; do
if [[ ! -f /opt/gcc/$compiler/activate ]]; then
echo "Environment activate script not found at /opt/gcc/$compiler... exiting."
exit 2
fi
source /opt/gcc/$compiler/activate
if [[ $NO_DEPS -ne 1 ]]; then
./deps.sh nuke
FD_AUTO_INSTALL_PACKAGES=1 ./deps.sh +dev fetch check install > /dev/null 2>&1
fi
for machine in "${MACHINES[@]}"; do
MACHINE="${machine%.mk}"
if [[ "$MACHINE" != *"clang"* ]]; then
Expand All @@ -130,13 +147,11 @@ if [[ $NO_GCC -ne 1 ]]; then
TARGETS+=( "${BINARY_TARGETS[@]}" )
fi
fi
test -f /opt/gcc/$compiler/activate || (echo "$compiler not found... exiting." && exit 2)
source /opt/gcc/$compiler/activate
echo "Starting builds for $MACHINE with $compiler..."
FAILED=()
start=$(date +%s)
for target in "${TARGETS[@]}"; do
MACHINE=${MACHINE} CC=gcc make -j $target > /dev/null 2>&1
MACHINE=${MACHINE} CC=gcc make -j $target
if [[ $? -ne 0 ]]; then
FAILED+=( $target )
FAIL=1
Expand Down Expand Up @@ -164,6 +179,15 @@ if [[ $NO_CLANG -ne 1 ]]; then
START=$(date +%s)
echo "Starting clang builds..."
for compiler in "${CLANG[@]}"; do
if [[ ! -f /opt/clang/$compiler/activate ]]; then
echo "Environment activate script not found at /opt/clang/$compiler... exiting."
exit 2
fi
source /opt/clang/$compiler/activate
if [[ $NO_DEPS -ne 1 ]]; then
./deps.sh nuke
FD_AUTO_INSTALL_PACKAGES=1 ./deps.sh +dev fetch check install > /dev/null 2>&1
fi
for machine in "${MACHINES[@]}"; do
MACHINE="${machine%.mk}"
if [[ "$MACHINE" != *"gcc"* ]]; then
Expand All @@ -177,13 +201,11 @@ if [[ $NO_CLANG -ne 1 ]]; then
TARGETS+=( "${BINARY_TARGETS[@]}" )
fi
fi
test -f /opt/gcc/$compiler/activate || (echo "$compiler not found... exiting." && exit 2)
source /opt/clang/$compiler/activate
echo "Starting builds for $MACHINE with $compiler..."
FAILED=()
start=$(date +%s)
for target in "${TARGETS[@]}"; do
MACHINE=${MACHINE} CC=clang make -j $target > /dev/null 2>&1
MACHINE=${MACHINE} CC=clang make -j $target
if [[ $? -ne 0 ]]; then
FAILED+=( $target )
FAIL=1
Expand Down

0 comments on commit de518f5

Please sign in to comment.