Skip to content

Commit

Permalink
Small improvements for CI with Vagrant (#188)
Browse files Browse the repository at this point in the history
Signed-off-by: Benoit Donneaux <[email protected]>
  • Loading branch information
btlogy authored Sep 17, 2024
1 parent 58d2d9f commit 70feab3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/_ansible_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ on:
required: true
type: string
deployment_target:
# The target should match a single host from the Ansible inventory
# Considering a dedicated host could make the testing more flexible
description: 'Inventory host or group to limit the deployment'
required: true
type: string
Expand All @@ -36,13 +38,7 @@ jobs:
ansible_e2e:
name: Ansible end-to-end testing
runs-on: ${{ inputs.gh_runner_version }}
env:
# Those variables will (also) be consumed in the Vagrantfile
DEPLOYMENT_SSH_KEY: ${{ secrets.deployment_ssh_key }}
DEPLOYMENT_USER: ${{ inputs.deployment_user }}
DEPLOYMENT_TARGET: ${{ inputs.deployment_target }}
# The target above should match a single host from the Ansible inventory
# It could be any host, but better be something dedicated for testing
timeout-minutes: 20
steps:
- name: Checkout
id: checkout
Expand Down Expand Up @@ -90,13 +86,19 @@ jobs:
vagrant --version
vagrant plugin list
hostnamectl
# Prepare env. variables required in the Vagrantfile
cat <<EOF | tee /dev/stderr >> $GITHUB_ENV
DEPLOYMENT_REPO=$(echo ${{ github.repository }} | cut -d/ -f2)
DEPLOYMENT_USER=${{ inputs.deployment_user }}
DEPLOYMENT_SSH_KEY<<END_OF_KEY
${{ secrets.deployment_ssh_key }}
END_OF_KEY
DEPLOYMENT_TARGET=${{ inputs.deployment_target }}
EOF
- name: Start Vagrant boxe(s)
id: vagrant_start
run: |
# Prepare an env. variable required for the Vagrantfile
export DEPLOYMENT_REPO="$(echo ${{ github.repository }} | cut -d/ -f2)"
echo "DEPLOYMENT_REPO=${DEPLOYMENT_REPO}" >> $GITHUB_ENV
# Start the Vagrant guest(s)
vagrant up --provider=libvirt --no-tty
# Save the SSH config for later
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vi: set ft=ruby :

host_name = ENV.has_key?('DEPLOYMENT_TARGET') ? ENV['DEPLOYMENT_TARGET'] : 'base-local'
repo_name = ENV.has_key?('DEPLOYMENT_REPO') ? ENV['DEPLOYMENT_REPO'] : abort("Repo is undefinned!")
repo_name = ENV.has_key?('DEPLOYMENT_REPO') ? ENV['DEPLOYMENT_REPO'] : abort("Repo is undefined!")
ssh_key = ENV.has_key?('DEPLOYMENT_SSH_KEY') ? ENV['DEPLOYMENT_SSH_KEY'] : abort("SSH key is undefined!")

# Get a dedicated LibVirt pool name or use default one
Expand Down

0 comments on commit 70feab3

Please sign in to comment.