Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ConfigFileTests
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Feb 1, 2024
2 parents bb7c0cd + 14c89a4 commit 625446e
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 89 deletions.
106 changes: 106 additions & 0 deletions .github/install-dependency-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/bash

set -e

##############################
# LINUX
##############################
GENERAL_PACKAGE_LIST_LINUX=(
python
gcc
make
cmake
tree
pkgconf
ninja
meson
)
IGUANA_PACKAGE_LIST_LINUX=(
fmt
)

##############################
# MACOS
##############################
GENERAL_PACKAGE_LIST_MACOS=(
tree
ninja
meson
)
IGUANA_PACKAGE_LIST_MACOS=(
fmt
)

#############################################

if [ $# -ne 2 ]; then
echo "USAGE: $0 [runner] [latest/minver]" >&2
exit 2
fi
runner=$1
verset=$2
summary_file=pkg_summary.md
> $summary_file

case $verset in
latest) echo "[+] Prefer latest version for iguana-specific dependencies" ;;
minver) echo "[+] Prefer minimum required version for iguana-specific dependencies" ;;
*)
echo "ERROR: unknown verset '$verset'" >&2
exit 1
;;
esac

#############################################

info_pacman() {
echo "| \`$1\` | $(pacman -Qi $1 | grep -Po '^Version\s*: \K.+') |" >> $summary_file
}

info_homebrew() {
echo "| \`$1\` | $(brew info $1 | head -n1) |" >> $summary_file
}

#############################################

case $runner in

ubuntu*)
echo "[+] On Linux runner"
echo "[+] UPDATING"
pacman -Syu --noconfirm
### install latest version of general packages
for pkg in ${GENERAL_PACKAGE_LIST_LINUX[@]}; do
echo "[+] INSTALLING PACKAGE $pkg"
pacman -S --noconfirm $pkg
info_pacman $pkg
done
### install either the latest or minver version of iguana-specific packages
for pkg in ${IGUANA_PACKAGE_LIST_LINUX[@]}; do
echo "[+] INSTALLING PACKAGE $pkg"
case $verset in
latest) pacman -S --noconfirm $pkg ;;
minver) pacman -U --noconfirm $(meson/minimum-version.sh $pkg ALA) ;;
esac
info_pacman $pkg
done
;;

macos*)
[ "$verset" = "minver" ] && echo "ERROR: 'minver' not implemented for macOS" >&2 && exit 1
echo "[+] On macOS runner"
export NO_COLOR=1
### install the latest version of all packages
for pkg in ${GENERAL_PACKAGE_LIST_MACOS[@]} ${IGUANA_PACKAGE_LIST_MACOS[@]}; do
echo "[+] INSTALLING PACKAGE $pkg"
brew install $pkg
info_homebrew $pkg
done
;;

*)
echo "ERROR: runner '$runner' is unknown to $0" >&2
exit 1
;;

esac
4 changes: 2 additions & 2 deletions .github/test-consumer-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ exe() {
# build and test
case $tool in
cmake)
exe cmake -S $source_dir -B $build_dir
exe cmake -S $source_dir -B $build_dir -G Ninja --install-prefix $install_dir
exe cmake --build $build_dir
exe cmake --install $build_dir --prefix $install_dir
exe cmake --install $build_dir
;;
make)
pushd $source_dir
Expand Down
128 changes: 46 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ on:
description: 'GitHub runner'
required: true
type: string
num_threads:
description: 'Number of threads or CPUs'
container:
description: 'Docker container'
required: false
type: string
default: 2
default: ''
verset:
description: 'Dependency version set'
required: false
type: string
default: 'latest'

defaults:
run:
shell: bash

env:
hipo_version: 4.0.1
fmt_version: 9.1.0 # for Linux runners, whereas macOS uses Homebrew version
num_events: 10

jobs:
Expand All @@ -30,62 +34,40 @@ jobs:
build_hipo:
name: Build HIPO
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.container }}
steps:
- name: checkout iguana for dependency installation script
uses: actions/checkout@v4
- name: install dependency packages
run: .github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
- name: checkout hipo
uses: actions/checkout@v4
with:
repository: gavalian/hipo
ref: ${{ env.hipo_version }}
- name: build
run: |
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=hipo
cmake --build build -j${{ inputs.num_threads }}
cmake -S . -B build -G Ninja --install-prefix $(pwd)/hipo
cmake --build build
cmake --install build
tar czvf hipo{.tar.gz,}
- run: brew install tree
if: ${{ inputs.runner == 'macos-latest' }}
- run: tree hipo
- uses: actions/upload-artifact@v4
with:
name: build_deps_hipo
retention-days: 1
path: hipo.tar.gz

build_fmt:
name: Build fmt
runs-on: ${{ inputs.runner }}
steps:
- name: checkout fmt
if: ${{ inputs.runner != 'macos-latest' }} # prefer Homebrew fmt installation on macOS (needed on every step, since we just want this job to succeed on macOS)
uses: actions/checkout@v4
with:
repository: fmtlib/fmt
ref: ${{ env.fmt_version }}
- name: build
if: ${{ inputs.runner != 'macos-latest' }}
run: |
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=fmt -DCMAKE_POSITION_INDEPENDENT_CODE=ON
cmake --build build -j${{ inputs.num_threads }}
cmake --install build
tar czvf fmt{.tar.gz,}
- run: tree fmt
if: ${{ inputs.runner != 'macos-latest' }}
- uses: actions/upload-artifact@v4
if: ${{ inputs.runner != 'macos-latest' }}
with:
name: build_deps_fmt
retention-days: 1
path: fmt.tar.gz

# build
#########################################################

build_iguana:
name: Build Iguana
needs:
- build_hipo
- build_fmt
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.container }}
strategy:
fail-fast: false
matrix:
Expand All @@ -100,44 +82,28 @@ jobs:
clean: false
fetch-tags: true
fetch-depth: 0
- name: setup meson
run: python -m pip install meson ninja
### dependencies
- name: get dependency build artifacts
- name: install dependency packages
run: .github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
- name: get local dependencies
uses: actions/download-artifact@v4
with:
pattern: build_deps_*
merge-multiple: true
- run: brew install fmt
if: ${{ inputs.runner == 'macos-latest' }}
- name: untar build
- name: untar local dependencies
run: ls *.tar.gz | xargs -I{} tar xzvf {}
- name: tree local dependencies
run: tree hipo
- name: summarize dependencies
run: |
echo '### Dependencies' >> $GITHUB_STEP_SUMMARY
echo '| Dependency | Version |' >> $GITHUB_STEP_SUMMARY
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
for dep in python meson ninja ; do
echo "| \`$dep\` | $($dep --version) |" >> $GITHUB_STEP_SUMMARY
done
if [ "${{ inputs.runner }}" = "macos-latest" ]; then
echo "| \`fmt\` | $(brew info fmt | head -n1) |" >> $GITHUB_STEP_SUMMARY
else
echo "| \`fmt\` | ${{ env.fmt_version }} |" >> $GITHUB_STEP_SUMMARY
fi
echo "| \`hipo\` | ${{ env.hipo_version }} |" >> $GITHUB_STEP_SUMMARY
### tree
- run: brew install tree
if: ${{ inputs.runner == 'macos-latest' }}
- run: tree
cat pkg_summary.md >> $GITHUB_STEP_SUMMARY
### build iguana
- name: resolve dependencies
run: |
if [ ${{ inputs.runner }} = "macos-latest" ]; then
meson/resolve-dependencies.py --ini native.ini --hipo ./hipo # fmt is a system installation on macOS runners
else
meson/resolve-dependencies.py --ini native.ini --hipo ./hipo --fmt ./fmt # fmt is locally built on Linux runners
fi
- name: resolve local dependencies
run: meson/resolve-dependencies.py --ini native.ini --hipo ./hipo
- name: meson setup
run: meson setup --native-file=native.ini build-iguana
- name: meson configure
Expand Down Expand Up @@ -214,6 +180,8 @@ jobs:
- download_validation_files
- build_iguana
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.container }}
strategy:
fail-fast: false
matrix:
Expand All @@ -222,25 +190,18 @@ jobs:
- { binding: cpp, extension: '' }
- { binding: python, extension: '.py' }
steps:
### setup
### dependencies and test data
- uses: actions/checkout@v4
with:
path: iguana_src # keep source code isolated
- name: install python binding runtime dependencies
if: ${{ matrix.binding == 'python' }}
run: |
python -m venv .venv
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
python -m pip install -r iguana_src/bind/python/requirements.txt
### dependencies and test data
- name: install dependency packages
run: .github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
working-directory: iguana_src
- name: get dependency build artifacts
uses: actions/download-artifact@v4
with:
pattern: build_deps_*
merge-multiple: true
- run: brew install fmt
if: ${{ inputs.runner == 'macos-latest' }}
- name: get iguana build artifacts
uses: actions/download-artifact@v4
with:
Expand All @@ -253,11 +214,16 @@ jobs:
run: |
ls *.tar.gz | xargs -I{} tar xzvf {}
rm -v *.tar.gz
### tree
- run: brew install tree
if: ${{ inputs.runner == 'macos-latest' }}
- name: tree artifacts
run: tree
### setup python virtaul environment (for python binding tests)
- name: install python binding runtime dependencies
if: ${{ matrix.binding == 'python' }}
run: |
python -m venv .venv
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
python -m pip install -r iguana_src/bind/python/requirements.txt
### set env vars - depends on runner and binding
- name: source environment for Linux and python
if: ${{ inputs.runner == 'ubuntu-latest' && matrix.binding == 'python' }}
Expand Down Expand Up @@ -290,24 +256,22 @@ jobs:
- download_validation_files
- build_iguana
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.container }}
strategy:
fail-fast: false
matrix:
tool: [ cmake, make, meson ]
steps:
### setup
- uses: actions/checkout@v4
- name: setup meson
if: ${{ matrix.tool == 'meson' }}
run: python -m pip install meson ninja
### dependencies and test data
- uses: actions/checkout@v4
- name: install dependency packages
run: .github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
- name: get dependency build artifacts
uses: actions/download-artifact@v4
with:
pattern: build_deps_*
merge-multiple: true
- run: brew install fmt
if: ${{ inputs.runner == 'macos-latest' }}
- name: get iguana build artifacts
uses: actions/download-artifact@v4
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ concurrency:
cancel-in-progress: true

jobs:
Linux:
linux:
name: Linux (latest)
uses: ./.github/workflows/ci.yml
with:
runner: ubuntu-latest
num_threads: 4
container: archlinux/archlinux:latest
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:

jobs:
macOS:
name: macOS (latest)
uses: ./.github/workflows/ci.yml
with:
runner: macos-latest
num_threads: 3
Loading

0 comments on commit 625446e

Please sign in to comment.