-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft implementation of the new action
- Loading branch information
Showing
3 changed files
with
193 additions
and
53 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Submit a Checkbox Test plan (or subset of it) to the lab | ||
inputs: | ||
provision_data: | ||
description: "Target image and provisioning data (ex. `url:` or `distro:`)" | ||
required: false | ||
default: null | ||
queue: | ||
description: "Queue that will run the testing (ex. 202012-28526)" | ||
required: true | ||
test_plan: | ||
description: "Test plan to run (ex. com.canonical.certification::sru)" | ||
required: true | ||
match: | ||
description: "Subset of jobs to run (ex. .*wireless.*)" | ||
required: false | ||
default: ".*" | ||
launcher_override: | ||
description: "Launcher with additional values that will take priority over the defaults" | ||
default: "" | ||
required: false | ||
checkbox_revision: | ||
description: "Revision of checkbox that has to be provisioned (ex. commit_hash, branch name, can be `beta`)" | ||
required: true | ||
zapper_channel: | ||
description: "Zapper channel to be used, will be ignored if no Zapper (ex. edge, beta, stable)" | ||
required: false | ||
default: "beta" | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
sudo apt install -y -qq gettext | ||
- name: Build test resource | ||
shell: bash | ||
env: | ||
INPUT_DATA_SOURCE: ${{ inputs.data_source }} | ||
INPUT_QUEUE: ${{ inputs.queue }} | ||
INPUT_MATCH: ${{ inputs.match || '.*' }} | ||
INPUT_TEST_PLAN: ${{ inputs.test_plan }} | ||
INPUT_LAUNCHER_OVERRIDE: ${{ inputs.launcher_override }} | ||
INPUT_CHECKBOX_REVISION: ${{ inputs.checkbox_revision }} | ||
INPUT_ZAPPER_CHANNEL: ${{ inputs.zapper_channel || 'beta' }} | ||
working-directory: ${{ github.action_path }}/../../../tools/lab_dispatch | ||
run: | | ||
echo "::group::Building the testflinger job" | ||
if [ -n "$INPUT_DATA_SOURCE" ]; then | ||
INPUT_DATA_SOURCE="provision_data: $INPUT_DATA_SOURCE" | ||
fi | ||
envsubst '$INPUT_CHECKBOX_REVISION $INPUT_DATA_SOURCE $INPUT_QUEUE $INPUT_ZAPPER_CHANNEL' < generic_snap.yaml | tee job.yaml | ||
echo "::endgroup::" | ||
echo "::group::Building the Checkbox launcher" | ||
# this goes from .template. (missing secret, testplan, match etc. to .partial.) | ||
# this is partial as some values are filled in on the agent (like wireless access points names) | ||
envsubst '$INPUT_TEST_PLAN $INPUT_MATCH' < resources/checkbox.no-manifest.template.conf | tee resources/checkbox.no-manifest.partial.conf | ||
echo "::endgroup::" | ||
echo "::group::Dumping launcher overrides" | ||
echo "$INPUT_LAUNCHER_OVERRIDE" | tee launcher_override.conf | ||
echo "::endgroup::" | ||
- name: Workaroud cwd | ||
shell: bash | ||
run: | | ||
# this allows us to dispatch the action and the attachments with relative | ||
# paths even when called form outside the Checkbox repo | ||
action_path=$(realpath ${{ github.action_path }}/../../../tools/) | ||
workdir_path=$(realpath tools/) | ||
if [ ! -e "$workdir_path" ]; then | ||
cp -rT "$action_path" "$workdir_path" | ||
fi | ||
if [ "$action_path" = "$workdir_path" ]; then | ||
echo "Skipping copy as the action is already running in workdir" | ||
else | ||
cp -rT "$action_path" "$workdir_path" | ||
fi | ||
- name: Submit and monitor job | ||
uses: canonical/testflinger/.github/actions/submit@main | ||
with: | ||
poll: true | ||
job-path: tools/lab_dispatch/job.yaml |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
job_queue: $INPUT_QUEUE | ||
global_timeout: 3600 | ||
output_timeout: 1800 | ||
$INPUT_PROVISION_DATA | ||
test_data: | ||
attachments: | ||
- local: "tools/lab_dispatch/resources/manifest.conf" | ||
agent: "manifest.conf" | ||
- local: "tools/lab_dispatch/resources/checkbox.no-manifest.partial.conf" | ||
agent: "checkbox.no-manifest.partial.conf" | ||
test_cmds: | | ||
#!/usr/bin/env bash | ||
set -x | ||
set -e | ||
# input arguments | ||
RISK=$INPUT_RISK | ||
RUNTIME_NAME=$INPUT_CHECKBOX_RUNTIME_NAME | ||
FRONTEND_NAME=$CHECKBOX_FRONTEND_NAME | ||
FRONTEND_TRACK=$INPUT_CHECKBOX_FRONTEND_TRACK | ||
export TOOLS_PATH=tools | ||
# retrieve all scripts/tools necessary from a repo | ||
curl -Ls -o install_tools.sh https://raw.githubusercontent.com/canonical/hwcert-jenkins-tools/install_checkbox_scriplet/install_tools.sh | ||
source install_tools.sh $TOOLS_PATH --branch install_checkbox_scriplet | ||
# ensure device is available before continuing | ||
wait_for_ssh --allow-degraded | ||
_run install_packages git python3 python3-pip dpkg-dev | ||
refresh_zapper_if_needed --channel "$INPUT_ZAPPER_CHANNEL" | ||
wait_for_ssh --allow-degraded | ||
install_checkbox_snaps beta | ||
# retrieve manifest | ||
RESOURCES_PATH=attachments/test/resources | ||
MANIFEST_FILE=manifest.conf | ||
set +e | ||
fetch_manifest --manifest_file manifest.conf $CID $HEXR_DEVICE_SECURE_ID | ||
if [ $? -ne 0 ]; then | ||
echo "Using default manifest" | ||
MANIFEST_FILE=$RESOURCES_PATH/manifest.conf | ||
fi | ||
set -e | ||
### create checkbox launcher | ||
# first dump the location specific infos in the launcher | ||
which envsubst || install_packages gettext | ||
envsubst < $RESOURCES_PATH/checkbox.no-manifest.partial.conf > checkbox.no-manifest.conf | ||
# then insert the manifest entries via the stacker | ||
stacker --output checkbox.conf checkbox.no-manifest.conf $MANIFEST_FILE | ||
PYTHONUNBUFFERED=1 checkbox-cli control $DEVICE_IP checkbox.conf | ||
EXITCODE=$? | ||
# placeholder for gathering possible artifacts | ||
exit $EXITCODE |