Split out packet creation from test runner
This commit is contained in:
parent
6afcaa1776
commit
984d1d74c0
49
.ci/spec/create-packet.sh
Normal file
49
.ci/spec/create-packet.sh
Normal file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# packet and job configuration
|
||||
export SLACK_USERNAME="Vagrant"
|
||||
export SLACK_ICON="https://media.giphy.com/media/yIQ5glQeheYE0/200.gif"
|
||||
export SLACK_TITLE="Vagrant-Spec Test Runner"
|
||||
export PACKET_EXEC_DEVICE_NAME="${PACKET_EXEC_DEVICE_NAME:-spec-ci-boxes}"
|
||||
export PACKET_EXEC_DEVICE_SIZE="${PACKET_EXEC_DEVICE_SIZE:-baremetal_0,baremetal_1,baremetal_1e}"
|
||||
export PACKET_EXEC_PREFER_FACILITIES="${PACKET_EXEC_PREFER_FACILITIES:-iad1,iad2,ewr1,dfw1,dfw2,sea1,sjc1,lax1}"
|
||||
export PACKET_EXEC_OPERATING_SYSTEM="${PACKET_EXEC_OPERATING_SYSTEM:-ubuntu_18_04}"
|
||||
export PACKET_EXEC_PRE_BUILTINS="${PACKET_EXEC_PRE_BUILTINS:-InstallVagrant,InstallVirtualBox,InstallVmware,InstallHashiCorpTool,InstallVagrantVmware}"
|
||||
export PACKET_EXEC_QUIET="1"
|
||||
export PKT_VAGRANT_CLOUD_TOKEN="${VAGRANT_CLOUD_TOKEN}"
|
||||
export VAGRANT_PKG_VERSION="2.2.7" # need to figure out how to make this latest instead
|
||||
###
|
||||
|
||||
|
||||
csource="${BASH_SOURCE[0]}"
|
||||
while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done
|
||||
root="$( cd -P "$( dirname "$csource" )/../" && pwd )"
|
||||
|
||||
. "${root}/.ci/common.sh"
|
||||
|
||||
pushd "${root}" > "${output}"
|
||||
|
||||
# Define a custom cleanup function to destroy any orphan guests
|
||||
# on the packet device
|
||||
function cleanup() {
|
||||
(>&2 echo "Cleaning up packet device")
|
||||
unset PACKET_EXEC_PERSIST
|
||||
pkt_wrap_stream "cd vagrant;VAGRANT_CWD=test/vagrant-spec/ VAGRANT_VAGRANTFILE=Vagrantfile.spec vagrant destroy -f" \
|
||||
"Vagrant command failed"
|
||||
}
|
||||
|
||||
# Ensure we have a packet device to connect
|
||||
echo "Creating packet device if needed..."
|
||||
|
||||
packet-exec info
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
wrap_stream packet-exec create \
|
||||
"Failed to create packet device"
|
||||
fi
|
||||
|
||||
# job_id is provided by common.sh
|
||||
export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}"
|
||||
export PACKET_EXEC_PERSIST="1"
|
||||
|
||||
echo "Finished creating spec test packet instance"
|
||||
@ -23,6 +23,8 @@ root="$( cd -P "$( dirname "$csource" )/../" && pwd )"
|
||||
|
||||
pushd "${root}" > "${output}"
|
||||
|
||||
# Assumes packet is already set up
|
||||
|
||||
# Define a custom cleanup function to destroy any orphan guests
|
||||
# on the packet device
|
||||
function cleanup() {
|
||||
@ -32,16 +34,6 @@ function cleanup() {
|
||||
"Vagrant command failed"
|
||||
}
|
||||
|
||||
# Ensure we have a packet device to connect
|
||||
echo "Creating packet device if needed..."
|
||||
|
||||
packet-exec info
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
wrap_stream packet-exec create \
|
||||
"Failed to create packet device"
|
||||
fi
|
||||
|
||||
# job_id is provided by common.sh
|
||||
export PACKET_EXEC_REMOTE_DIRECTORY="${job_id}"
|
||||
export PACKET_EXEC_PERSIST="1"
|
||||
@ -51,7 +43,7 @@ export PKT_VAGRANT_HOST_BOXES="${VAGRANT_HOST_BOXES}"
|
||||
export PKT_VAGRANT_GUEST_BOXES="${VAGRANT_GUEST_BOXES}"
|
||||
###
|
||||
|
||||
echo "Setting up remote packet device for current job... "
|
||||
echo "Syncing up remote packet device for current job... "
|
||||
# NOTE: We only need to call packet-exec with the -upload option once
|
||||
# since we are persisting the job directory. This command
|
||||
# is used simply to seed the work directory.
|
||||
|
||||
10
.github/workflows/spectesting.yml
vendored
10
.github/workflows/spectesting.yml
vendored
@ -6,8 +6,16 @@ on:
|
||||
- 'CHANGELOG.md'
|
||||
- 'website/**'
|
||||
|
||||
# split packet setup and test runner into two jobs
|
||||
jobs:
|
||||
setup-packet:
|
||||
if: github.repository == 'hashicorp/vagrant'
|
||||
runs-on: self-hosted
|
||||
name: Build Packet Instance
|
||||
steps:
|
||||
- name: Create packet instance
|
||||
run: .ci/spec/create-packet.sh
|
||||
working-directory: ${{github.workspace}}
|
||||
|
||||
spec-tests:
|
||||
if: github.repository == 'hashicorp/vagrant'
|
||||
runs-on: self-hosted
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user