Skip to content

Commit 3588465

Browse files
authored
Merge pull request #24 from voxpupuli/handle-noarch-artifacts
Handle noarch artifacts
2 parents 7ac8ae5 + ba61717 commit 3588465

File tree

6 files changed

+383
-108
lines changed

6 files changed

+383
-108
lines changed

.github/actions/container_task_prep/action.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ runs:
2424
# ...possibly this should be moved into the
2525
# install_build_artifact task scripts.
2626
set_platform_globals
27-
if [[ "${platform}" == 'Rocky' ]]; then
28-
# The Rocky9 container, at least, is missing openvox-agent's
29-
# systemd dependency...
27+
if [[ "${platform}" == 'Rocky' ]] || [[ "${platform}" == 'Fedora' ]]; then
28+
# The Rocky9 and Fedora containers, at least, are missing
29+
# openvox-agent's systemd dependency...
3030
exec_and_capture dnf install -y systemd
3131
if [[ "${os_major_version}" == '8' ]]; then
3232
# ...and the Rocky8 container is missing findutils.

.github/workflows/pr_testing_install_build_artifact.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,74 @@ jobs:
7272
PT__installdir: ${{ github.workspace }}
7373
PT_version: "8.15.0"
7474
run: ./openvox_bootstrap/tasks/install_build_artifact_linux.sh
75+
76+
test-install-build-artifact-task-noarch:
77+
strategy:
78+
matrix:
79+
package:
80+
- name: openvox-server
81+
version: 8.8.0
82+
- name: openvoxdb
83+
version: 8.9.0
84+
- name: openvoxdb-termini
85+
version: 8.9.0
86+
details:
87+
- image: almalinux:9
88+
prereqs:
89+
- java-17-openjdk-headless
90+
- net-tools
91+
- procps-ng
92+
- which
93+
- image: debian:12
94+
prereqs:
95+
- openjdk-17-jre-headless
96+
- net-tools
97+
- procps
98+
- image: ubuntu:24.04
99+
prereqs:
100+
- openjdk-17-jre-headless
101+
- net-tools
102+
- procps
103+
runs-on: ubuntu-latest
104+
container: ${{ matrix.details.image }}
105+
steps:
106+
- uses: actions/checkout@v4
107+
with:
108+
path: openvox_bootstrap
109+
- id: prep
110+
uses: ./openvox_bootstrap/.github/actions/container_task_prep
111+
- name: Run openvox-agent install task manually
112+
env:
113+
PT__installdir: ${{ github.workspace }}
114+
PT_version: "8.19.1"
115+
run: ./openvox_bootstrap/tasks/install_build_artifact_linux.sh
116+
- name: Install prerequisites
117+
shell: bash
118+
env:
119+
PREREQ_PACKAGES: ${{ join(matrix.details.prereqs, ',') }}
120+
run: |-
121+
set +e
122+
/opt/puppetlabs/bin/puppet apply --detailed-exitcodes <<EOS
123+
package { [${PREREQ_PACKAGES}]:
124+
ensure => installed
125+
}
126+
EOS
127+
exitcode=$?
128+
set -e
129+
# Expect package changes and no failures.
130+
[[ "${exitcode}" -eq 2 ]]
131+
- name: Test noarch package installation
132+
env:
133+
PT__installdir: ${{ github.workspace }}
134+
PT_package: ${{ matrix.package.name }}
135+
PT_version: ${{ matrix.package.version }}
136+
run: ./openvox_bootstrap/tasks/install_build_artifact_linux.sh
137+
- name: Verify openvox-server is installed
138+
shell: bash
139+
env:
140+
PACKAGE: ${{ matrix.package.name }}
141+
VERSION: ${{ matrix.package.version }}
142+
run: |-
143+
/opt/puppetlabs/bin/puppet resource package "${PACKAGE}" > openvox-package.status
144+
cat openvox-package.status
145+
grep "ensure.*=>.*'${VERSION}" openvox-package.status

.github/workflows/pr_testing_with_nested_vms.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ jobs:
5858
"cpu_mode": "host-model"
5959
}
6060
]
61+
- name: Capture dereferenced inventory for use with openvox_bootstrap
62+
working-directory: kvm_automation_tooling
63+
run: |-
64+
bolt inventory --inventory terraform/instances/inventory.test.yaml show --format json --detail | \
65+
jq '.inventory | with_entries(select(.key == "targets")) | del(.targets[0].groups)' | \
66+
yq -P > ../inventory.yaml
6167
- name: Run openvox_bootstrap::install task on nested vm
6268
run: |-
63-
bolt task run openvox_bootstrap::install --inventory kvm_automation_tooling/terraform/instances/inventory.test.yaml --targets test-agent-1
69+
bolt task run openvox_bootstrap::install --inventory inventory.yaml --targets test-agent-1
6470
- name: Verify openvox-agent is installed
6571
run: |-
66-
bolt task run openvox_bootstrap::check version=8 test=gt --inventory kvm_automation_tooling/terraform/instances/inventory.test.yaml --targets test-agent-1
72+
bolt task run openvox_bootstrap::check version=8 test=gt --inventory inventory.yaml --targets test-agent-1

files/common.sh

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,136 @@ refresh_package_cache() {
377377
exit 1
378378
fi
379379
}
380+
381+
# Test whether the given package name matches a list of
382+
# openvox packages that are noarch.
383+
noarch_package() {
384+
local _package="$1"
385+
386+
# List of noarch packages.
387+
local noarch_packages=(
388+
'openvox-server'
389+
'openvoxdb'
390+
'openvoxdb-termini'
391+
)
392+
393+
for pkg in "${noarch_packages[@]}"; do
394+
if [[ "${_package}" == "${pkg}" ]]; then
395+
return 0
396+
fi
397+
done
398+
399+
return 1
400+
}
401+
402+
# Lookup the cpu architecture and set it as cpu_arch.
403+
# Translates x86_64 to amd64 and aarch64 to arm64 for debian/ubuntu.
404+
set_cpu_architecture() {
405+
local _family="$1"
406+
407+
local _arch
408+
_arch=$(uname -m)
409+
case "${_family}" in
410+
debian|ubuntu)
411+
case "${_arch}" in
412+
x86_64)
413+
cpu_arch="amd64"
414+
;;
415+
aarch64)
416+
cpu_arch="arm64"
417+
;;
418+
*)
419+
cpu_arch="${_arch}"
420+
;;
421+
esac
422+
;;
423+
*)
424+
cpu_arch="${_arch}"
425+
;;
426+
esac
427+
export cpu_arch # quiets shellcheck SC2034
428+
assigned 'cpu_arch'
429+
}
430+
431+
# Lookup the architecture for the given package and set it as
432+
# package_arch.
433+
#
434+
# This will either be noarch/all depending on the platform and
435+
# whether the package name matches an openvox noarch_package(),
436+
# or it will be the cpu_arch.
437+
set_package_architecture() {
438+
local _package="$1"
439+
local _os_family="${2:-${os_family}}"
440+
441+
if noarch_package "${_package}"; then
442+
case "${_os_family}" in
443+
debian|ubuntu)
444+
package_arch='all'
445+
;;
446+
*)
447+
package_arch='noarch'
448+
;;
449+
esac
450+
else
451+
set_cpu_architecture "${_os_family}"
452+
package_arch="${cpu_arch}"
453+
fi
454+
export package_arch # quiets shellcheck SC2034
455+
assigned 'package_arch'
456+
}
457+
458+
# Based on platform, package and version set:
459+
# package_name - the name of the build artifact package
460+
# package_url - the url to download the build artifact package
461+
#
462+
# Currently this is based on the structure of the package repository
463+
# at https://artifacts.voxpupuli.org, which is a page
464+
# that provides a summary of links to artifacts contained in an S3
465+
# bucket hosted by Oregon State University Open Source Lab.
466+
#
467+
# Example rpm:
468+
# https://artifacts.voxpupuli.org/openvox-agent/8.15.0/openvox-agent-8.15.0-1.el8.x86_64.rpm
469+
# Example deb:
470+
# https://artifacts.voxpupuli.org/openvox-agent/8.15.0/openvox-agent_8.15.0-1%2Bdebian12_amd64.deb
471+
set_artifacts_package_url() {
472+
local _artifacts_source="$1"
473+
local _package="$2"
474+
local _version="$3"
475+
476+
set_package_type "${os_family}"
477+
set_package_architecture "${_package}" "${os_family}"
478+
479+
case "${package_type}" in
480+
rpm)
481+
# Account for a fedora naming quirk in the build artifacts.
482+
if [[ "${os_family}" == "fedora" ]]; then
483+
_os_family="fc"
484+
else
485+
_os_family="${os_family}"
486+
fi
487+
package_name="${_package}-${_version}-1.${_os_family}${os_major_version}.${package_arch}.${package_type}"
488+
;;
489+
deb)
490+
package_name="${_package}_${_version}-1%2B${os_family}${os_full_version}_${package_arch}.${package_type}"
491+
;;
492+
*)
493+
fail "Unhandled package type: '${package_type}'"
494+
;;
495+
esac
496+
497+
case "${_package}" in
498+
openvoxdb-termini)
499+
local _package_dir='openvoxdb'
500+
;;
501+
*)
502+
local _package_dir="${_package}"
503+
;;
504+
esac
505+
506+
package_url="${_artifacts_source}/${_package_dir}/${_version}/${package_name}"
507+
508+
export package_name # quiets shellcheck SC2034
509+
assigned 'package_name'
510+
export package_url # quiets shellcheck SC2034
511+
assigned 'package_url'
512+
}

0 commit comments

Comments
 (0)