Use multipass #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run rocks tests | ||
on: | ||
workflow_call: | ||
inputs: | ||
rock-metas: | ||
description: List of maps featuring the built {name, version, path, arch, image} | ||
type: string | ||
default: "[]" | ||
jobs: | ||
run-tests: | ||
if: ${{ inputs.rock-metas != '[]' }} | ||
name: Run tests | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Maximize build space | ||
uses: AdityaGarg8/[email protected] | ||
with: | ||
remove-android: 'true' | ||
remove-haskell: 'true' | ||
remove-codeql: 'true' | ||
remove-swapfile: 'true' | ||
- name: Checkout repository | ||
uses: actions/[email protected] | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.8' | ||
- name: Setup environment | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y jq | ||
pip install tox | ||
- name: Install multipass | ||
sudo snap install multipass | ||
# We need to authenticate into multipass, since we're not running as root. | ||
# https://github.com/canonical/multipass/issues/1437#issuecomment-1435357872 | ||
sudo multipass set local.passphrase=Passw0rd | ||
multipass auth Passw0rd | ||
- name: Set rock image environment variables | ||
run: | | ||
# NOTE(aznashwan): these env var names are maintained for backwards | ||
# compatibility, but new tests should ideally use the utility functions | ||
# from the shared testing harnesss repository to directly read the | ||
# values from the below-set BUILT_ROCKS_METADATA environment variable. | ||
# https://github.com/canonical/k8s-test-harness/blob/main/k8s_test_harness/util/env_util.py | ||
echo '${{ inputs.rock-metas }}' | jq -c '.[] | select(.arch == "amd64") ' | while read i; do | ||
name=$(echo "$i" | jq -r '.name' | tr '[:lower:]' '[:upper:]' | tr '-' '_') | ||
image=$(echo "$i" | jq -r '.image') | ||
echo "ROCK_$name=$image" >> $GITHUB_ENV | ||
done | ||
- name: Run integration tests | ||
env: | ||
BUILT_ROCKS_METADATA: ${{ inputs.rock-metas }} | ||
run: | | ||
export TEST_SNAP_CHANNEL="latest/edge" | ||
export TEST_SUBSTRATE=multipass | ||
export TEST_MULTIPASS_MEMORY=6G | ||
export TEST_MULTIPASS_DISK=40G | ||
tox --conf tests/tox.ini -e integration | ||
- name: Setup upterm session | ||
uses: lhotari/action-upterm@v1 | ||
if: ${{ failure() }} | ||
with: | ||
## If no one connects after 5 minutes, shut down server. | ||
wait-timeout-minutes: 5 |