Skip to content

Commit

Permalink
feat: allow for testing of minimum-versioned dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Feb 1, 2024
1 parent a9dff90 commit f8c608d
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 20 deletions.
69 changes: 55 additions & 14 deletions .github/install-dependency-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,99 @@

set -e

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

PACKAGE_LIST_MACOS=(
### general dependencies
##############################
# MACOS
##############################
GENERAL_PACKAGE_LIST_MACOS=(
tree
### iguana dependencies
ninja
meson
)
IGUANA_PACKAGE_LIST_MACOS=(
fmt
)

if [ $# -ne 1 ]; then
echo "USAGE: $0 [runner]" >&2
#############################################

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
for pkg in ${PACKAGE_LIST_ARCH_LINUX[@]}; do
### install latest version of general packages
for pkg in ${GENERAL_PACKAGE_LIST_LINUX[@]}; do
echo "[+] INSTALLING PACKAGE $pkg"
pacman -S --noconfirm $pkg
echo "| \`$pkg\` | $(pacman -Qi $pkg | grep -Po '^Version\s*: \K.+') |" >> $summary_file
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
echo "[+] TEST"
pacman -U --noconfirm https://archive.archlinux.org/packages/f/fmt/fmt-9.1.0-4-x86_64.pkg.tar.zst
;;

macos*)
[ "$verset" = "minver" ] && echo "ERROR: 'minver' not implemented for macOS" >&2 && exit 1
echo "[+] On macOS runner"
export NO_COLOR=1
for pkg in ${PACKAGE_LIST_MACOS[@]}; do
### 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
echo "| \`$pkg\` | $(brew info $pkg | head -n1) |" >> $summary_file
info_homebrew $pkg
done
;;

Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
required: false
type: string
default: ''
verset:
description: 'Dependency version set'
required: false
type: string
default: 'latest'

defaults:
run:
Expand All @@ -35,7 +40,7 @@ jobs:
- name: checkout iguana for dependency installation script
uses: actions/checkout@v4
- name: install dependency packages
run: .github/install-dependency-packages.sh ${{ inputs.runner }}
run: .github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
- name: checkout hipo
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -79,7 +84,7 @@ jobs:
fetch-depth: 0
### dependencies
- name: install dependency packages
run: .github/install-dependency-packages.sh ${{ inputs.runner }}
run: .github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
- name: get local dependencies
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -191,7 +196,7 @@ jobs:
with:
path: iguana_src # keep source code isolated
- name: install dependency packages
run: iguana_src/.github/install-dependency-packages.sh ${{ inputs.runner }}
run: iguana_src/.github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
- name: get dependency build artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -255,7 +260,7 @@ jobs:
### dependencies and test data
- uses: actions/checkout@v4
- name: install dependency packages
run: .github/install-dependency-packages.sh ${{ inputs.runner }}
run: .github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
- name: get dependency build artifacts
uses: actions/download-artifact@v4
with:
Expand Down
13 changes: 11 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ project(
project_description = 'Implementation Guardian of Analysis Algorithms'

# resolve dependencies
fmt_dep = dependency('fmt', version: '>=9.1.0', method: 'pkg-config')
hipo_dep = dependency('hipo4', version: '>=4.0.1', method: 'pkg-config')
# NOTE: those that are typically installed by package managers should use `meson/minimum-version.sh`
fmt_dep = dependency(
'fmt',
method: 'pkg-config',
version: run_command('meson' / 'minimum-version.sh', 'fmt', check: true).stdout().strip()
)
hipo_dep = dependency(
'hipo4',
method: 'pkg-config',
version: '>=4.0.1',
)

# list of dependencies
# FIXME: for users which use LD_LIBRARY_PATH, we should try to keep this list
Expand Down
41 changes: 41 additions & 0 deletions meson/minimum-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

if [ $# -eq 0 ]; then
echo """USAGE: $0 [package] [command(default=meson)]
package: the package name; since this varies between package manager
repositories, we prefer to use the name from that used by the CI
command: meson return a string for meson function \`dependency()\`
ALA return a URL for the Arch Linux Archive (ALA), for CI
https://archive.archlinux.org/
"""
exit 2
fi
dep=$1
[ $# -ge 2 ] && cmd=$2 || cmd=meson

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

case $dep in
fmt)
result_meson='>=9.1.0'
result_ala='https://archive.archlinux.org/packages/f/fmt/fmt-9.1.0-4-x86_64.pkg.tar.zst'
;;
*)
echo "ERROR: dependency '$dep' is unknown" >&2
exit 1
;;
esac

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

case $cmd in
meson) echo $result_meson ;;
ALA) echo $result_ala ;;
*)
echo "ERROR: command '$cmd' is unknown" >&2
exit 1
;;
esac

0 comments on commit f8c608d

Please sign in to comment.