Skip to content

Commit

Permalink
Test AM Vagrant box before publishing it
Browse files Browse the repository at this point in the history
This splits the AM vagrant box workflow in two jobs, one for building
the Ubuntu 20.04 base image and one for building and publishing the AM
vagrant box.

It also adds steps to provision a VM using Vagrant and VirtualBox and
tests if AM responds to API endpoint calls before publishing the
image.
  • Loading branch information
replaceafill authored Jan 21, 2025
1 parent 1f8e75e commit 28e01ef
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 13 deletions.
76 changes: 69 additions & 7 deletions .github/workflows/vagrant-box-archivematica.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@ on:
description: Description
required: true
jobs:
vagrant-box-archivematica:
name: Build and upload
build-base-image:
name: Build base image
runs-on: ubuntu-24.04
env:
PACKER_CACHE_DIR: ${{ github.workspace }}/.packer_cache
steps:
- name: Check out code
uses: actions/checkout@v4
- name: "Install packer"
- name: "Install packer and VirtualBox"
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install packer
- name: "Install VirtualBox"
run: |
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update && sudo apt install virtualbox-7.1
sudo apt update && sudo apt install packer virtualbox-7.1
- name: Set the user environment as VirtualBox expects it
run: |
echo "USER=$USER" >> $GITHUB_ENV
Expand All @@ -40,10 +37,75 @@ jobs:
run: |
cd ${{ github.workspace }}/packer/templates/vagrant-base-ubuntu-20.04-amd64
packer build -on-error=abort template.json
- name: Upload base image
uses: actions/upload-artifact@v4
with:
name: base-image
path: "${{ github.workspace }}/packer/builds/virtualbox/vagrant-base-ubuntu-20.04-amd64"
vagrant-box-archivematica:
name: Build and upload box image
runs-on: ubuntu-24.04
needs: ["build-base-image"]
env:
PACKER_CACHE_DIR: ${{ github.workspace }}/.packer_cache
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Restore base image
uses: actions/download-artifact@v4
with:
name: base-image
path: "${{ github.workspace }}/packer/builds/virtualbox/vagrant-base-ubuntu-20.04-amd64"
- name: "Install packer, vagrant and VirtualBox"
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update && sudo apt install packer vagrant virtualbox-7.1
- name: Set the user environment as VirtualBox expects it
run: |
echo "USER=$USER" >> $GITHUB_ENV
echo "LOGNAME=$USER" >> $GITHUB_ENV
- name: Update vbox networks
run: |
sudo mkdir -p /etc/vbox/
echo "* 10.10.10.20/24" | sudo tee -a /etc/vbox/networks.conf
- name: Install packer plugins
run: |
packer plugins install github.com/hashicorp/virtualbox
packer plugins install github.com/hashicorp/ansible
packer plugins install github.com/hashicorp/vagrant
- name: Build
run: |
cd ${{ github.workspace }}/packer/templates/vagrant-box-archivematica
packer build -on-error=abort template.json
mv ${{ github.workspace }}/packer/builds/virtualbox/vagrant-am.box \
${{ github.workspace }}/archivematica-vagrant-${{ github.event.inputs.version }}.box
- name: Provision a test VM with the new image
run: |
vagrant init --minimal --no-tty archivematica-vagrant-${{ github.event.inputs.version }} file://${{ github.workspace }}/archivematica-vagrant-${{ github.event.inputs.version }}.box
cat Vagrantfile
vagrant up --debug-timestamp --provider virtualbox
- name: Test AM is running in the test VM
run: |
sleep 180
test $( \
curl \
--silent \
--header 'Authorization: ApiKey admin:this_is_the_am_api_key' \
--header 'Content-Type: application/json' \
'http://10.10.10.20/api/processing-configuration/' \
| jq -r '.processing_configurations == ["automated", "default"]' \
) == true
test $( \
curl \
--silent \
--header 'Authorization: ApiKey admin:this_is_the_ss_api_key' \
--header 'Content-Type: application/json' \
'http://10.10.10.20:8000/api/v2/pipeline/' \
| jq -r '.meta.total_count == 1' \
) == true
- name: Upload
run: |
cd ${{ github.workspace }}/tools/vagrant-box-uploader
Expand Down
6 changes: 0 additions & 6 deletions packer/scripts/ubuntu/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ dpkg --list \
| grep linux-source \
| xargs apt-get -y purge;

# Delete development packages
dpkg --list \
| awk '{ print $2 }' \
| grep -- '-dev$' \
| xargs apt-get -y purge;

# delete docs packages
dpkg --list \
| awk '{ print $2 }' \
Expand Down

0 comments on commit 28e01ef

Please sign in to comment.