Skip to content

workflows: macos

workflows: macos #74

Workflow file for this run

name: C/C++ CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build-ubuntu-24_04:
runs-on: ubuntu-24.04
steps:
- name: Add apt.llvm.org
run: |
echo 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble main' | sudo tee /etc/apt/sources.list.d/apt.llvm.org.list
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
- name: Upgrade packages
run: |
sudo apt-get update
sudo apt-get upgrade -y
- name: Install libcanth dependencies
run: |
sudo apt-get install libcjson-dev
- name: Upgrade Clang
run: |
sudo apt-get install clang{,-{format,tidy,tools}} lib{c++{,abi},clang,omp}-dev lld llvm{,-dev,-runtime}
- name: Add Ubuntu 22.04 and 20.04 package repos
run: |
printf 'deb http://archive.ubuntu.com/ubuntu/ %s main restricted universe multiverse\n' jammy{,-{updates,security,backports}} | sudo tee /etc/apt/sources.list.d/jammy.list
printf 'deb http://archive.ubuntu.com/ubuntu/ %s main restricted universe multiverse\n' focal{,-{updates,security,backports}} | sudo tee /etc/apt/sources.list.d/focal.list
sudo apt-get update
- name: Install Clang 6 through 15 and GCC 7 through 11
run: |
sudo apt-get install clang-{6.0,7,8,9,10,11,12,13,14,15} llvm-{{6.0,7,8,9,10}-dev,{11,12,13}-linker-tools} g{cc,++}-{7,8,9,10,11}
- uses: actions/checkout@v4
- name: Get available compilers, run warnings summary builds
run: |
set +e
uname -a
{ compgen -c clang; compgen -c gcc; } | grep -E '^(clang|gcc)(-[1-9][0-9]*(\.[0-9]+)*)?$' | sort -V -u -r > compilers
grep -Fxe clang -e gcc compilers > default-compilers
cat default-compilers | xargs -I§ bash -c 'realpath "$(command -v §)" 2>/dev/null' | paste - default-compilers | grep -Ev '^[[:blank:]]*$' > default-compilers2
grep -Fvxf default-compilers compilers > versioned-compilers
cat versioned-compilers | xargs -I§ bash -c 'realpath "$(command -v §)" 2>/dev/null' | paste - versioned-compilers | grep -Ev '^[[:blank:]]*$' > versioned-compilers2
sed 's/-[1-9][0-9\.]*$//' versioned-compilers2 | grep -Fxvf- default-compilers2 > compilers2
cat versioned-compilers2 >> compilers2
cut -f2 compilers2 > compilers
rm -f compilers2 default-compilers2 versioned-compilers2
cat compilers
scripts/warnings-summary.sh $(< compilers)
- name: GCC debug builds
run: |
set +e
for _cc in $(grep '^gcc' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#gcc/g++}"
_dir="build/dbg_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" debug=1 CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done
- name: Clang debug builds
run: |
set +e
for _cc in $(grep '^clang' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#clang/clang++}"
_dir="build/dbg_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" debug=1 CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done
- name: GCC release builds
run: |
set +e
for _cc in $(grep '^gcc' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#gcc/g++}"
_dir="build/rel_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done
- name: Clang release builds
run: |
set +e
for _cc in $(grep '^clang' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#clang/clang++}"
_dir="build/rel_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done
- name: Report
run: |
set +e
ng=$(shopt -p nullglob)
shopt -s nullglob
a=($(printf '%s\n' build/*/failed | grep -Ev '^[[:blank:]]*$' | sort -V -r))
$ng
if (( ${#a[@]} )); then
a=("${a[@]%/failed}")
printf '%s\n' "Failures: ${#a[@]}" "${a[@]/#build\//- }"
exit 1
fi
echo 'All builds succeeded, running tests...'
declare -i n=0
for x in $(printf '%s\n' build/*/test | grep -Ev '^[[:blank:]]*$' | sort -V -r); do
y=$("$x" 2>&1)
(( n += $? != 0 ))
x="${x#build/}"
printf -vx -- '%-13s|' "${x%/test}"
echo "$y" | sed "s,^,$x ,"
done
if (( n )); then
echo "Failures: $n"
exit 1
fi
build-macos-14:
runs-on: macos-14
steps:
- name: Install dependencies
run: |
brew update
brew upgrade
brew install bash cjson
- uses: actions/checkout@v4
- name: Get available compilers, run warnings summary builds
shell: bash
run: |
set +e
uname -a
{ compgen -c clang; compgen -c gcc; } | grep -E '^(clang|gcc)(-[1-9][0-9]*(\.[0-9]+)*)?$' | sort -V -u -r > compilers
grep -Fxe clang -e gcc compilers > default-compilers
cat default-compilers | xargs -I§ bash -c 'realpath "$(command -v §)" 2>/dev/null' | paste - default-compilers | grep -Ev '^[[:blank:]]*$' > default-compilers2
grep -Fvxf default-compilers compilers > versioned-compilers
cat versioned-compilers | xargs -I§ bash -c 'realpath "$(command -v §)" 2>/dev/null' | paste - versioned-compilers | grep -Ev '^[[:blank:]]*$' > versioned-compilers2
sed 's/-[1-9][0-9\.]*$//' versioned-compilers2 | grep -Fxvf- default-compilers2 > compilers2
cat versioned-compilers2 >> compilers2
cut -f2 compilers2 > compilers
rm -f compilers2 default-compilers2 versioned-compilers2
cat compilers
scripts/warnings-summary.sh $(< compilers)
- name: GCC debug builds
shell: bash
run: |
set +e
for _cc in $(grep '^gcc' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#gcc/g++}"
_dir="build/dbg_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" debug=1 CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done
- name: Clang debug builds
shell: bash
run: |
set +e
for _cc in $(grep '^clang' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#clang/clang++}"
_dir="build/dbg_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" debug=1 CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done
- name: GCC release builds
shell: bash
run: |
set +e
for _cc in $(grep '^gcc' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#gcc/g++}"
_dir="build/rel_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done
- name: Clang release builds
shell: bash
run: |
set +e
for _cc in $(grep '^clang' compilers); do
[[ -z "$_cxx" ]] || printf '\n\n========================================\n'
_cxx="${_cc/#clang/clang++}"
_dir="build/rel_$_cc"
mkdir -p "$_dir"
make -j$(nproc) -C src O="../$_dir" CC="$_cc" CXX="$_cxx"
(( $? == 0 )) || touch "$_dir/failed"
done