From f8c608dbaf791ac35226e6ddca3a9c552933e000 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Thu, 1 Feb 2024 12:20:02 -0500 Subject: [PATCH] feat: allow for testing of minimum-versioned dependencies --- .github/install-dependency-packages.sh | 69 ++++++++++++++++++++------ .github/workflows/ci.yml | 13 +++-- meson.build | 13 ++++- meson/minimum-version.sh | 41 +++++++++++++++ 4 files changed, 116 insertions(+), 20 deletions(-) create mode 100755 meson/minimum-version.sh diff --git a/.github/install-dependency-packages.sh b/.github/install-dependency-packages.sh index dce217ce..dc2ad19e 100755 --- a/.github/install-dependency-packages.sh +++ b/.github/install-dependency-packages.sh @@ -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 ;; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5a85bef..7808c4c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,11 @@ on: required: false type: string default: '' + verset: + description: 'Dependency version set' + required: false + type: string + default: 'latest' defaults: run: @@ -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: @@ -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: @@ -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: @@ -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: diff --git a/meson.build b/meson.build index 30a84f28..1be03ca5 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/meson/minimum-version.sh b/meson/minimum-version.sh new file mode 100755 index 00000000..6361ab17 --- /dev/null +++ b/meson/minimum-version.sh @@ -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