Skip to content

Commit

Permalink
build(chameleon): decrease minimum ruby version and test it (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Aug 5, 2024
1 parent 818f55b commit 9dbab20
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 69 deletions.
50 changes: 0 additions & 50 deletions .github/download-ROOT-source.rb

This file was deleted.

27 changes: 27 additions & 0 deletions .github/download-ROOT-source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# download the ROOT source code

set -euo pipefail

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

tag=$1
curl_cmd='curl --silent -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28"'

echo "Download ROOT tag '$tag' from:"
case $tag in
latest)
url=$($curl_cmd https://api.github.com/repos/root-project/ROOT/releases/latest | jq -r '.tarball_url')
;;
*)
url=$($curl_cmd https://api.github.com/repos/root-project/ROOT/tags | jq -r '.[] | select (.name=="'$tag'") | .tarball_url')
;;
esac

echo " $url"
[ -z "$url" ] && echo "ERROR: GitHub API call returned empty string, perhaps tag '$tag' does not exist?" && exit 1
echo "downloading ..."
wget -nv --no-check-certificate --output-document root.tar.gz $url
1 change: 0 additions & 1 deletion .github/install-dependency-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set -e
##############################
GENERAL_PACKAGE_LIST_LINUX=(
python
ruby
gcc
gcc-fortran
clang
Expand Down
69 changes: 68 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
- name: download ROOT source code
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
iguana_src/.github/download-ROOT-source.rb ${{ steps.key.outputs.root_version }}
iguana_src/.github/download-ROOT-source.sh ${{ steps.key.outputs.root_version }}
tar xf $(ls -t *.gz | head -n1)
ls -t
mv -v $(ls -td root-* | head -n1) root_src
Expand Down Expand Up @@ -199,6 +199,51 @@ jobs:
key: ${{ steps.key.outputs.key }}---${{ matrix.root_dep }}
path: hipo.tar.zst

build_ruby_minver:
name: Build Minver Ruby
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.container }}
outputs:
key: ${{ steps.key.outputs.key }}
steps:
- name: checkout iguana
if: ${{ inputs.verset == 'minver' }}
uses: actions/checkout@v4
with:
path: iguana_src
- name: key
if: ${{ inputs.verset == 'minver' }}
id: key
run: |
ver=$(iguana_src/meson/minimum-version.sh ruby)
echo ver=$ver >> $GITHUB_OUTPUT
echo key=ruby---${{ inputs.id }}---${ver}---$(date +%Y-week%U) >> $GITHUB_OUTPUT
- uses: actions/cache/restore@v4
if: ${{ inputs.verset == 'minver' }}
id: cache
with:
key: ${{ steps.key.outputs.key }}
path: ruby.tar.zst
lookup-only: true
- name: build ruby
if: ${{ steps.cache.outputs.cache-hit != 'true' && inputs.verset == 'minver' }}
run: |
iguana_src/.github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
export RBENV_ROOT=$(pwd)/.rbenv
git clone https://github.com/rbenv/rbenv.git $RBENV_ROOT
eval "$($RBENV_ROOT/bin/rbenv init - bash)"
git clone https://github.com/rbenv/ruby-build.git $(rbenv root)/plugins/ruby-build
rbenv install ${{ steps.key.outputs.ver }}
rbenv global ${{ steps.key.outputs.ver }}
tar cavf ruby.tar.zst .rbenv
- uses: actions/cache/save@v4
if: ${{ steps.cache.outputs.cache-hit != 'true' && inputs.verset == 'minver' }}
id: cache_save
with:
key: ${{ steps.key.outputs.key }}
path: ruby.tar.zst

# build and test Iguana
#########################################################

Expand All @@ -208,6 +253,7 @@ jobs:
- download_test_data
- build_hipo
- build_root
- build_ruby_minver
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.container }}
Expand Down Expand Up @@ -235,6 +281,26 @@ jobs:
###### system
- name: install dependency packages
run: iguana_src/.github/install-dependency-packages.sh ${{ inputs.runner }} ${{ inputs.verset }}
###### ruby
- name: install ruby from linux package manager
if: ${{ inputs.id != 'macOS' && inputs.verset != 'minver' }}
run: pacman -S --noconfirm ruby
- name: install ruby from cached minver build
if: ${{ inputs.id != 'macOS' && inputs.verset == 'minver' }}
uses: actions/cache/restore@v4
with:
key: ${{ needs.build_ruby_minver.outputs.key }}
path: ruby.tar.zst
- name: source ruby from cached minver build
if: ${{ inputs.id != 'macOS' && inputs.verset == 'minver' }}
run: |
tar xf ruby.tar.zst
export RBENV_ROOT=$(pwd)/.rbenv
echo RBENV_ROOT=$RBENV_ROOT >> $GITHUB_ENV
eval "$($RBENV_ROOT/bin/rbenv init - bash)"
echo "ruby --version:"
ruby --version
echo PATH=$PATH >> $GITHUB_ENV
###### python bindings
- name: install python bindings dependencies
if: ${{ matrix.id == 'python' }}
Expand Down Expand Up @@ -289,6 +355,7 @@ jobs:
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
echo "| \`hipo\` | ${{ env.hipo_ref }} |" >> $GITHUB_STEP_SUMMARY
echo "| \`root\` | $(root --version 2>&1 | head -n1) |" >> $GITHUB_STEP_SUMMARY
echo "| \`ruby\` | $(ruby --version) |" >> $GITHUB_STEP_SUMMARY
cat pkg_summary.md >> $GITHUB_STEP_SUMMARY
### build
- name: meson setup
Expand Down
6 changes: 6 additions & 0 deletions doc/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ cmake --build build-hipo
cmake --install build-hipo
```

### 🟩 Optional: `ruby`: programming language
<https://www.ruby-lang.org/en/>
- Likely available in your package manager, likely as `ruby`
- This is only needed if you intend to use Iguana with languages other than C++
- Bindings to other programming languages are generated by [`chameleon`](/src/chameleon), a local Ruby program

### 🟩 Optional: `ROOT`: Data analysis framework
<https://root.cern.ch/>
- ROOT is an **optional** dependency: some algorithms and test code depends on ROOT, but if you do not
Expand Down
20 changes: 15 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,40 @@ project_description = 'Implementation Guardian of Analysis Algorithms'

# initialize binding languanges
add_languages('fortran', native: false, required: get_option('bind_fortran'))
use_chameleon = get_option('bind_fortran')

# meson modules
pkg = import('pkgconfig')
fs = import('fs')

# resolve dependencies
prog_minver = find_program('meson' / 'minimum-version.sh')
# 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(),
version: '>=' + run_command(prog_minver, 'fmt', check: true).stdout().strip(),
)
yamlcpp_dep = dependency(
'yaml-cpp',
method: 'pkg-config',
version: run_command('meson' / 'minimum-version.sh', 'yaml-cpp', check: true).stdout().strip(),
version: '>=' + run_command(prog_minver, 'yaml-cpp', check: true).stdout().strip(),
)
hipo_dep = dependency(
'hipo4',
method: 'pkg-config',
version: '>=4.1.0'
)
hipo_dep = dependency('hipo4', method: 'pkg-config', version: '>=4.1.0')
ROOT_dep = dependency(
'ROOT',
required: get_option('z_require_root'),
method: 'cmake',
version: run_command('meson' / 'minimum-version.sh', 'ROOT', check: true).stdout().strip(),
version: '>=' + run_command(prog_minver, 'ROOT', check: true).stdout().strip(),
)
prog_ruby = find_program(
'ruby',
version: '>=' + run_command(prog_minver, 'ruby', check: true).stdout().strip(),
required: use_chameleon,
)

# list of dependencies
Expand Down Expand Up @@ -169,7 +180,6 @@ add_project_arguments(
)

# start chameleon
use_chameleon = get_option('bind_fortran')
if use_chameleon
subdir('src/chameleon')
endif
Expand Down
23 changes: 14 additions & 9 deletions meson/minimum-version.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash

if [ $# -eq 0 ]; then
echo """USAGE: $0 [package] [command(default=meson)]
echo """USAGE: $0 [package] [command(default=ver)]
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()\`
command: ver return the minimum version number
ALA return a URL for the Arch Linux Archive (ALA), for CI
https://archive.archlinux.org/
Expand All @@ -16,7 +16,7 @@ if [ $# -eq 0 ]; then
exit 2
fi
dep=$1
[ $# -ge 2 ] && cmd=$2 || cmd=meson
[ $# -ge 2 ] && cmd=$2 || cmd=ver

not_used() {
[ "$cmd" = "$1" ] && echo "ERROR: command '$cmd' is not used for '$dep'" >&2 && exit 1
Expand All @@ -26,20 +26,25 @@ not_used() {

case $dep in
fmt)
result_meson='>=9.1.0'
result_ver='9.1.0'
result_ala='https://archive.archlinux.org/packages/f/fmt/fmt-9.1.0-4-x86_64.pkg.tar.zst'
not_used 'tag'
;;
yaml-cpp)
result_meson='>=0.7.0'
result_ver='0.7.0'
result_ala='https://archive.archlinux.org/packages/y/yaml-cpp/yaml-cpp-0.7.0-2-x86_64.pkg.tar.zst'
not_used 'tag'
;;
root|ROOT)
result_meson='>=6.28.12'
result_ver='6.28.12'
result_tag='v6-28-12'
not_used 'ALA'
;;
ruby)
result_ver='2.7.2'
not_used 'ALA'
not_used 'tag'
;;
*)
echo "ERROR: dependency '$dep' is unknown" >&2
exit 1
Expand All @@ -49,9 +54,9 @@ esac
#############################################

case $cmd in
meson) echo $result_meson ;;
ALA) echo $result_ala ;;
tag) echo $result_tag ;;
ver) echo $result_ver ;;
ALA) echo $result_ala ;;
tag) echo $result_tag ;;
*)
echo "ERROR: command '$cmd' is unknown" >&2
exit 1
Expand Down
3 changes: 1 addition & 2 deletions src/chameleon/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ chameleon_sources = files(
'src' / 'bind_c.rb',
)

ruby = find_program('ruby', version: '>=3.0.0', required: use_chameleon)
chameleon_gen = find_program(chameleon_sources[0], required: use_chameleon)
prog_chameleon = find_program(chameleon_sources[0], required: use_chameleon)
2 changes: 1 addition & 1 deletion src/iguana/algorithms/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ foreach algo : algo_dict
input: [ algo_dir / 'Action.yaml', chameleon_sources ],
output: [ target_name + '_bind.cc' ],
command: [
chameleon_gen,
prog_chameleon,
'--input', '@INPUT0@',
'--output', '@OUTDIR@',
'--prefix', target_name,
Expand Down

0 comments on commit 9dbab20

Please sign in to comment.