feat(ci): optimize Molecule VM creation

- reuse validated runner-owned Vagrant linked-clone masters\n- create the default guests in bounded two-machine batches\n- capture create timing and runner utilization diagnostics
This commit is contained in:
Timothy Stewart
2026-08-01 01:15:25 -05:00
committed by Techno Tim
parent 57f234c8da
commit 10bde4eff0
14 changed files with 563 additions and 3 deletions
+2 -1
View File
@@ -45,7 +45,7 @@ jobs:
lookup-only: true
path: |
.vagrant-home/boxes
key: vagrant-boxes-${{ runner.os }}-${{ runner.arch }}-virtualbox-7.2-vagrant-2.4-${{ hashFiles('.github/vagrant-boxes.lock') }} # yamllint disable-line rule:line-length
key: vagrant-boxes-${{ runner.name }}-${{ runner.os }}-${{ runner.arch }}-virtualbox-7.2-vagrant-2.4-${{ hashFiles('.github/vagrant-boxes.lock') }} # yamllint disable-line rule:line-length
- name: Download Vagrant boxes for all scenarios
# An exact hit skips both cache restoration and upstream downloads.
@@ -53,4 +53,5 @@ jobs:
if: steps.cache-vagrant.outputs.cache-hit != 'true'
run: |
./.github/download-boxes.sh
./.github/scripts/prepare-vagrant-box-masters.sh
vagrant box list
+21 -2
View File
@@ -57,9 +57,12 @@ jobs:
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # 6.1.0
with:
path: .vagrant-home/boxes
key: vagrant-boxes-${{ runner.os }}-${{ runner.arch }}-virtualbox-7.2-vagrant-2.4-${{ hashFiles('.github/vagrant-boxes.lock') }} # yamllint disable-line rule:line-length
key: vagrant-boxes-${{ runner.name }}-${{ runner.os }}-${{ runner.arch }}-virtualbox-7.2-vagrant-2.4-${{ hashFiles('.github/vagrant-boxes.lock') }} # yamllint disable-line rule:line-length
fail-on-cache-miss: true
- name: Prepare runner-owned Vagrant box masters
run: ./.github/scripts/prepare-vagrant-box-masters.sh
- name: Install dependencies
run: |
echo "::group::Upgrade pip"
@@ -71,7 +74,20 @@ jobs:
echo "::endgroup::"
- name: Test with molecule
run: molecule test --scenario-name ${{ matrix.scenario }}
run: |
set -Eeuo pipefail
resource_dir="${RUNNER_TEMP}/logs/resources/${{ matrix.scenario }}"
timing_file="${RUNNER_TEMP}/logs/timing/${{ matrix.scenario }}.txt"
mkdir -p -- "${timing_file%/*}"
./.github/scripts/monitor-runner-resources.sh "$resource_dir" 10 &
monitor_pid=$!
stop_monitor() {
kill -TERM "$monitor_pid" 2>/dev/null || true
wait "$monitor_pid" 2>/dev/null || true
}
trap stop_monitor EXIT
/usr/bin/time -v -o "$timing_file" \
molecule test --scenario-name ${{ matrix.scenario }}
timeout-minutes: 90
env:
ANSIBLE_K3S_LOG_DIR: ${{ runner.temp }}/logs/k3s-ansible/${{ matrix.scenario }}
@@ -79,10 +95,13 @@ jobs:
ANSIBLE_TIMEOUT: 120
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
K3S_CI_CREATE_TIMING_LOG: ${{ runner.temp }}/logs/timing/${{ matrix.scenario }}-create.log
- name: Collect runner diagnostics
if: always()
run: ./.github/scripts/collect-runner-diagnostics.sh "${RUNNER_TEMP}/logs/runner"
env:
K3S_CI_SCENARIO_NAME: ${{ matrix.scenario }}
- name: Clean repository-owned resources after testing
if: always()