Skip to content

Commit ad38d27

Browse files
committed
(gha) Test install_build_artifacts task in gha
* adds a workflow to test the new install_build_artifacts task * extracts common elements to .github/actions
1 parent 27c55f1 commit ad38d27

File tree

7 files changed

+165
-58
lines changed

7 files changed

+165
-58
lines changed

.github/actions/bolt/action.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Install and Prepare Bolt
3+
description: "Helps with installing Bolt from the Puppet repository on Ubuntu distributions."
4+
5+
inputs:
6+
os-codename:
7+
description: The Ubuntu codename of the OS to install Bolt on.
8+
required: true
9+
type: string
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Install Bolt
15+
shell: bash
16+
env:
17+
OS_CODENAME: ${{ inputs.os-codename }}
18+
run: |-
19+
wget https://apt.puppet.com/puppet-tools-release-${OS_CODENAME}.deb
20+
sudo dpkg -i puppet-tools-release-${OS_CODENAME}.deb
21+
sudo apt update
22+
sudo apt install -y puppet-bolt
23+
- name: Install module dependencies
24+
shell: bash
25+
run: bolt module install
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: Prepare Container for Task
3+
description: "Checkouts module dependencies and ensures a wget is installed so that we can run the task scripts manually."
4+
5+
runs:
6+
using: "composite"
7+
steps:
8+
- uses: actions/checkout@v4
9+
with:
10+
repository: puppetlabs/puppetlabs-facts
11+
path: facts
12+
- name: Ensure wget is installed
13+
shell: bash
14+
env:
15+
PT__installdir: ${{ github.workspace }}
16+
run: |-
17+
source openvox_bootstrap/files/common.sh
18+
19+
# Ensure wget is installed.
20+
if exists 'apt'; then
21+
exec_and_capture apt update
22+
elif exists 'apt-get'; then
23+
exec_and_capture apt-get update
24+
elif exists 'dnf'; then
25+
exec_and_capture dnf clean all
26+
elif exists 'yum'; then
27+
exec_and_capture yum clean all
28+
elif exists 'zypper'; then
29+
exec_and_capture zypper refresh
30+
else
31+
echo "No package manager found."
32+
exit 1
33+
fi
34+
install_package wget
35+
36+
# Deal with missing package dependencies in the containers.
37+
# ...possibly this should be moved into the
38+
# install_build_artifact task scripts.
39+
set_platform
40+
if [[ "${platform}" == 'Rocky' ]]; then
41+
# The Rocky9 container, at least, is missing openvox-agent's
42+
# systemd dependency...
43+
exec_and_capture dnf install -y systemd
44+
if [[ "${major_version}" == '8' ]]; then
45+
# ...and the Rocky8 container is missing findutils.
46+
exec_and_capture dnf install -y findutils
47+
fi
48+
fi

.github/workflows/pr_testing.yaml

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ jobs:
3232
needs: shellcheck
3333
steps:
3434
- uses: actions/checkout@v4
35-
- name: Install Bolt
36-
run: |-
37-
wget https://apt.puppet.com/puppet-tools-release-${{ matrix.os-details.codename }}.deb
38-
sudo dpkg -i puppet-tools-release-${{ matrix.os-details.codename }}.deb
39-
sudo apt update
40-
sudo apt install -y puppet-bolt
41-
- name: Install module dependencies
42-
run: bolt module install
35+
- id: install-bolt
36+
uses: ./.github/actions/bolt
37+
with:
38+
os-codename: ${{ matrix.os-details.codename }}
4339
- name: Run openvox-agent install task
4440
run: bolt task run openvox_bootstrap::install --targets localhost --run-as root
4541
- name: Verify openvox-agent is installed
@@ -55,6 +51,8 @@ jobs:
5551
- debian:10
5652
- debian:11
5753
- debian:12
54+
- fedora:42
55+
- ubuntu:24.04
5856
# Need to pull in the repo GPG keys for sles
5957
# - registry.suse.com/suse/sle15:15.6
6058
needs: shellcheck
@@ -64,36 +62,8 @@ jobs:
6462
- uses: actions/checkout@v4
6563
with:
6664
path: openvox_bootstrap
67-
- uses: actions/checkout@v4
68-
with:
69-
repository: puppetlabs/puppetlabs-facts
70-
path: facts
71-
- name: debugging
72-
run: |
73-
pwd
74-
echo "Running on ${{ matrix.image }}"
75-
ls -l
76-
echo "${GITHUB_WORKSPACE}"
77-
ls -l "${GITHUB_WORKSPACE}/.."
78-
- name: Ensure wget is installed (apt)
79-
if: startsWith(matrix.image, 'debian')
80-
run: |
81-
if ! command -v wget &> /dev/null; then
82-
apt update
83-
apt install -y wget
84-
fi
85-
- name: Ensure wget is installed (dnf)
86-
if: startsWith(matrix.image, 'rocky')
87-
run: |
88-
if ! command -v wget &> /dev/null; then
89-
dnf install -y wget
90-
fi
91-
- name: Ensure wget is installed (zypper)
92-
if: contains(matrix.image, 'suse')
93-
run: |
94-
if ! command -v wget &> /dev/null; then
95-
zypper install -y wget
96-
fi
65+
- id: prep
66+
uses: ./openvox_bootstrap/.github/actions/container_task_prep
9767
- name: Run openvox-agent install task manually
9868
env:
9969
PT__installdir: ${{ github.workspace }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: 'PR Tests of the install_build_artifact task'
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test-install-build-artifact-task-on-ubuntu:
14+
strategy:
15+
matrix:
16+
os-details:
17+
- os: ubuntu-22.04
18+
codename: jammy
19+
# - os: ubuntu-24.04
20+
# codename: noble
21+
# Perforce hasn't yet released bolt on 24.04.
22+
runs-on: ${{ matrix.os-details.os }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
- id: install-bolt
26+
uses: ./.github/actions/bolt
27+
with:
28+
os-codename: ${{ matrix.os-details.codename }}
29+
- name: Run openvox-agent install task
30+
run: bolt task run openvox_bootstrap::install_build_artifact version=8.15.0 --targets localhost --run-as root
31+
- name: Verify openvox-agent is installed
32+
run: |-
33+
[[ "$(/opt/puppetlabs/bin/puppet --version)" = "8.15.0" ]]
34+
35+
test-install-build-artifact-task-on-other-os-via-containers:
36+
strategy:
37+
matrix:
38+
image:
39+
- rockylinux:8
40+
- rockylinux:9
41+
- debian:10
42+
- debian:11
43+
- debian:12
44+
- fedora:42
45+
- ubuntu:24.04
46+
# Need to pull in the repo GPG keys for sles
47+
# - registry.suse.com/suse/sle15:15.6
48+
runs-on: ubuntu-latest
49+
container: ${{ matrix.image }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
path: openvox_bootstrap
54+
- id: prep
55+
uses: ./openvox_bootstrap/.github/actions/container_task_prep
56+
- name: Run openvox-agent install task manually
57+
env:
58+
PT__installdir: ${{ github.workspace }}
59+
PT_version: "8.15.0"
60+
run: ./openvox_bootstrap/tasks/install_build_artifact_linux.sh
61+
- name: Verify openvox-agent is installed
62+
shell: bash
63+
run: |-
64+
[[ "$(/opt/puppetlabs/bin/puppet --version)" = "8.15.0" ]]

files/common.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,23 @@ install_package_file() {
165165
;;
166166
esac
167167
}
168+
169+
# TODO add support for the version parameter.
170+
install_package() {
171+
local _package="$1"
172+
173+
info "Installing ${_package}"
174+
if exists 'dnf'; then
175+
exec_and_capture dnf install -y "$_package"
176+
elif exists 'yum'; then
177+
exec_and_capture yum install -y "$_package"
178+
elif exists 'zypper'; then
179+
exec_and_capture zypper install -y "$_package"
180+
elif exists 'apt'; then
181+
exec_and_capture apt install -y "$_package"
182+
elif exists 'apt-get'; then
183+
exec_and_capture apt-get install -y "$_package"
184+
else
185+
fail "Unable to install ${_package}. Neither dnf, yum, zypper, apt nor apt-get are installed."
186+
fi
187+
}

tasks/install_build_artifact_linux.sh

100644100755
File mode changed.

tasks/install_linux.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,6 @@ set_collection_url() {
5858
assigned 'package_url'
5959
}
6060

61-
# TODO add support for the version parameter.
62-
install_package() {
63-
local _package="$1"
64-
65-
info "Installing ${_package}"
66-
if exists 'dnf'; then
67-
exec_and_capture dnf install -y "$_package"
68-
elif exists 'yum'; then
69-
exec_and_capture yum install -y "$_package"
70-
elif exists 'zypper'; then
71-
exec_and_capture zypper install -y "$_package"
72-
elif exists 'apt'; then
73-
exec_and_capture apt install -y "$_package"
74-
elif exists 'apt-get'; then
75-
exec_and_capture apt-get install -y "$_package"
76-
else
77-
fail "Unable to install ${_package}. Neither dnf, yum, zypper, apt nor apt-get are installed."
78-
fi
79-
}
80-
8161
# Installs the release package, and runs apt update if we are on a
8262
# Debian based platform.
8363
install_release_package() {

0 commit comments

Comments
 (0)