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:
@@ -13,14 +13,15 @@ inputs:
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- shell: bash
|
||||
- name: Install Packer and deps in Linux
|
||||
shell: bash
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
set -exo pipefail
|
||||
# Install virtualbox
|
||||
sudo apt-get update
|
||||
# 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
|
||||
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
|
||||
@@ -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"
|
||||
sudo unzip pup.zip -d /usr/local/bin
|
||||
sudo chmod +x /usr/local/bin/pup
|
||||
- shell: bash
|
||||
- name: Install Packer's deps in macOS
|
||||
shell: bash
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
set -exo pipefail
|
||||
brew install pup dvdrtools xorriso coreutils gsed
|
||||
brew install pup dvdrtools xorriso coreutils gsed virtualbox vagrant
|
||||
# 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
|
||||
@@ -11,7 +11,7 @@ name: Build the boxes
|
||||
jobs:
|
||||
collect:
|
||||
name: Discover distros
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
distros: ${{ steps.distros.outputs.distros }}
|
||||
build: ${{ steps.time.outputs.time }}
|
||||
|
||||
+27
-10
@@ -16,7 +16,7 @@ name: Test the components of it
|
||||
jobs:
|
||||
validate:
|
||||
name: Validate Packer templates are reasonable
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/setup
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
|
||||
collect:
|
||||
name: Collect all Ansible-related jobs
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
outputs:
|
||||
all: ${{ steps.zipped.outputs.scenarios }}
|
||||
steps:
|
||||
@@ -56,16 +56,18 @@ jobs:
|
||||
import json
|
||||
ubuntu = json.loads('${{ steps.collection.outputs.tox-envs }}')
|
||||
macos = json.loads('${{ steps.vagrant.outputs.tox-envs }}')
|
||||
ub_zip = [{'os': 'ubuntu-latest', 'scenario': u} for u in ubuntu]
|
||||
mac_zip = [{'os': 'macos-12', 'scenario': m} for m in macos]
|
||||
ub_zip = [{'os': 'ubuntu-22.04', 'scenario': u} for u in ubuntu]
|
||||
mac_zip = [{'os': 'ubuntu-22.04', 'scenario': m} for m in macos]
|
||||
print("::set-output name=scenarios::" + json.dumps(ub_zip + mac_zip))
|
||||
|
||||
lint:
|
||||
name: Lint Ansible code
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/setup
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup test environment
|
||||
uses: ./.github/actions/setup
|
||||
with:
|
||||
ansible: true
|
||||
- name: Run lint
|
||||
@@ -83,7 +85,22 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/setup
|
||||
- uses: ./.github/actions/install_virtualbox
|
||||
if: startsWith(matrix.scenarios.os, 'macos')
|
||||
- uses: ./.github/actions/install_packer
|
||||
- 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
|
||||
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
|
||||
platforms:
|
||||
- name: test-ubuntu18-init
|
||||
image: ubuntu:18.04
|
||||
box: generic/ubuntu1804
|
||||
box: boxen/ubuntu-18.04-x86_64
|
||||
provider_options:
|
||||
driver: qemu
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
driver:
|
||||
name: containers
|
||||
provider:
|
||||
name: libvirt
|
||||
platforms:
|
||||
- name: test-ubuntu18-init
|
||||
- name: test-ubuntu18-virtualbox
|
||||
image: ubuntu:18.04
|
||||
box: generic/ubuntu1804
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
driver:
|
||||
name: containers
|
||||
provider:
|
||||
name: libvirt
|
||||
platforms:
|
||||
- name: test-ubuntu20-init
|
||||
- name: test-ubuntu20-virtualbox
|
||||
image: ubuntu:20.04
|
||||
box: generic/ubuntu2004
|
||||
|
||||
Reference in New Issue
Block a user