Speed up Ansible tests

Move Molecule Vagrant tests over to QEmu runners on Linux boxes
"Dog-food" the Vagrant VMs
Accelerate linting of Ansible code as well
This commit is contained in:
Greg Hellings
2022-06-08 13:56:47 -05:00
committed by GitHub
parent 0941dd9909
commit 8448e1f187
9 changed files with 39 additions and 53 deletions
+6 -4
View File
@@ -13,14 +13,15 @@ inputs:
runs: runs:
using: composite using: composite
steps: steps:
- shell: bash - name: Install Packer and deps in Linux
shell: bash
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: | run: |
set -exo pipefail set -exo pipefail
# Install virtualbox # Install virtualbox
sudo apt-get update sudo apt-get update
# Install QEmu, etc # Install QEmu, etc
sudo apt-get install -y unzip python3-{virtualenv,yaml} cloud-utils xorriso qemu-system-{x86,ppc} sudo apt-get install -y unzip python3-{virtualenv,yaml} cloud-utils xorriso qemu-system-{x86,ppc} vagrant
# Install packer.io # Install packer.io
curl -O https://releases.hashicorp.com/packer/${{ inputs.version }}/packer_${{ inputs.version }}_linux_amd64.zip curl -O https://releases.hashicorp.com/packer/${{ inputs.version }}/packer_${{ inputs.version }}_linux_amd64.zip
unzip -o packer_${{ inputs.version }}_linux_amd64.zip -d /usr/local/bin unzip -o packer_${{ inputs.version }}_linux_amd64.zip -d /usr/local/bin
@@ -29,9 +30,10 @@ runs:
curl -L -o pup.zip "https://github.com/ericchiang/pup/releases/download/${{ inputs.pup_version }}/pup_${{ inputs.pup_version }}_linux_amd64.zip" curl -L -o pup.zip "https://github.com/ericchiang/pup/releases/download/${{ inputs.pup_version }}/pup_${{ inputs.pup_version }}_linux_amd64.zip"
sudo unzip pup.zip -d /usr/local/bin sudo unzip pup.zip -d /usr/local/bin
sudo chmod +x /usr/local/bin/pup sudo chmod +x /usr/local/bin/pup
- shell: bash - name: Install Packer's deps in macOS
shell: bash
if: runner.os == 'macOS' if: runner.os == 'macOS'
run: | run: |
set -exo pipefail set -exo pipefail
brew install pup dvdrtools xorriso coreutils gsed brew install pup dvdrtools xorriso coreutils gsed virtualbox vagrant
# Packer is already installed # Packer is already installed
@@ -1,9 +0,0 @@
name: Install virtualbox on Mac
description: Installs virtualbox on Mac runners
runs:
using: composite
steps:
- shell: bash
run: |
set -exo pipefail
brew install virtualbox vagrant
+1 -1
View File
@@ -11,7 +11,7 @@ name: Build the boxes
jobs: jobs:
collect: collect:
name: Discover distros name: Discover distros
runs-on: ubuntu-latest runs-on: ubuntu-22.04
outputs: outputs:
distros: ${{ steps.distros.outputs.distros }} distros: ${{ steps.distros.outputs.distros }}
build: ${{ steps.time.outputs.time }} build: ${{ steps.time.outputs.time }}
+27 -10
View File
@@ -16,7 +16,7 @@ name: Test the components of it
jobs: jobs:
validate: validate:
name: Validate Packer templates are reasonable name: Validate Packer templates are reasonable
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
@@ -34,7 +34,7 @@ jobs:
collect: collect:
name: Collect all Ansible-related jobs name: Collect all Ansible-related jobs
runs-on: ubuntu-latest runs-on: ubuntu-22.04
outputs: outputs:
all: ${{ steps.zipped.outputs.scenarios }} all: ${{ steps.zipped.outputs.scenarios }}
steps: steps:
@@ -56,16 +56,18 @@ jobs:
import json import json
ubuntu = json.loads('${{ steps.collection.outputs.tox-envs }}') ubuntu = json.loads('${{ steps.collection.outputs.tox-envs }}')
macos = json.loads('${{ steps.vagrant.outputs.tox-envs }}') macos = json.loads('${{ steps.vagrant.outputs.tox-envs }}')
ub_zip = [{'os': 'ubuntu-latest', 'scenario': u} for u in ubuntu] ub_zip = [{'os': 'ubuntu-22.04', 'scenario': u} for u in ubuntu]
mac_zip = [{'os': 'macos-12', 'scenario': m} for m in macos] mac_zip = [{'os': 'ubuntu-22.04', 'scenario': m} for m in macos]
print("::set-output name=scenarios::" + json.dumps(ub_zip + mac_zip)) print("::set-output name=scenarios::" + json.dumps(ub_zip + mac_zip))
lint: lint:
name: Lint Ansible code name: Lint Ansible code
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- uses: ./.github/actions/setup uses: actions/checkout@v3
- name: Setup test environment
uses: ./.github/actions/setup
with: with:
ansible: true ansible: true
- name: Run lint - name: Run lint
@@ -83,7 +85,22 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/install_virtualbox - uses: ./.github/actions/install_packer
if: startsWith(matrix.scenarios.os, 'macos') - name: Install libvirt
shell: bash
run: |
set -exo pipefail
sudo apt-get install libvirt-daemon-system
sudo usermod -a -G libvirt $USER
sudo systemctl start libvirtd
sudo ls -la /var/run/libvirt/
- name: Run scenario - name: Run scenario
run: tox -e "${{ matrix.scenarios.scenario }}" run: |
set -ex
TOX="$(which tox)"
sudo -E su -m -c "groups && ${TOX} -e \"${{ matrix.scenarios.scenario }}\" -- --destroy=never" $USER
- name: Get possible output
if: ${{ failure() }}
run: |
set -x
cat /home/runner/.cache/molecule/init/ubuntu18/vagrant.err
@@ -1,8 +0,0 @@
driver:
name: vagrant
provider:
name: libvirt
platforms:
- name: test-ubuntu16-init
image: ubuntu:16.04
box: generic/ubuntu1604
@@ -1,11 +0,0 @@
- hosts: all
tasks:
- name: Read init file
ansible.builtin.slurp:
path: /etc/default/console-setup
register: __slurped
- name: Validate desired string is present
assert:
that: >-
'ACTIVE_CONSOLES="/dev/tty1"' in ( __slurped["content"] | b64decode )
@@ -4,5 +4,6 @@ driver:
name: libvirt name: libvirt
platforms: platforms:
- name: test-ubuntu18-init - name: test-ubuntu18-init
image: ubuntu:18.04 box: boxen/ubuntu-18.04-x86_64
box: generic/ubuntu1804 provider_options:
driver: qemu
@@ -1,8 +1,5 @@
driver: driver:
name: containers name: containers
provider:
name: libvirt
platforms: platforms:
- name: test-ubuntu18-init - name: test-ubuntu18-virtualbox
image: ubuntu:18.04 image: ubuntu:18.04
box: generic/ubuntu1804
@@ -1,8 +1,5 @@
driver: driver:
name: containers name: containers
provider:
name: libvirt
platforms: platforms:
- name: test-ubuntu20-init - name: test-ubuntu20-virtualbox
image: ubuntu:20.04 image: ubuntu:20.04
box: generic/ubuntu2004