Skip to content

Commit

Permalink
Draft implementation of the new action
Browse files Browse the repository at this point in the history
  • Loading branch information
Hook25 committed Oct 8, 2024
1 parent 440c0f2 commit 6f93dcd
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 53 deletions.
83 changes: 83 additions & 0 deletions .github/actions/checkbox_snap/action.yaml
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
101 changes: 48 additions & 53 deletions .github/workflows/checkbox-promote-beta-to-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,69 @@ jobs:
fail-fast: false
matrix:
include:
- queue: 201712-26047
data_source: "distro: xenial"
checkbox_runtime: checkbox16
checkbox_track: uc16
#- queue: 201712-26047
# provision_data: "distro: xenial"
# checkbox_runtime: checkbox16
# checkbox_track: uc16

- queue: 201712-26047
data_source: "distro: focal"
checkbox_runtime: checkbox20
checkbox_track: uc20
#- queue: 201712-26047
# provision_data: "distro: focal"
# checkbox_runtime: checkbox20
# checkbox_track: uc20

- queue: 201712-26047
data_source: "distro: bionic"
#- queue: 201712-26047
# provision_data: "distro: bionic"

- queue: 202203-30061
data_source: "distro: jammy"
provision_data: "distro: jammy"
checkbox_runtime: checkbox22
checkbox_track: uc22

- queue: 202203-30061
data_source: "distro: jammy"
#- queue: 202203-30061
# provision_data: "distro: jammy"

- queue: 202012-28526
data_source: "distro: noble"
checkbox_runtime: checkbox24
checkbox_track: uc24
#- queue: 202012-28526
# provision_data: "distro: noble"
# checkbox_runtime: checkbox24
# checkbox_track: uc24

- queue: 202012-28526
data_source: "distro: noble"
#- queue: 202012-28526
# provision_data: "distro: noble"

- queue: 202201-29865
data_source: "distro: bionic"
checkbox_runtime: checkbox18
checkbox_track: uc18
#- queue: 202201-29865
# provision_data: "distro: bionic"
# checkbox_runtime: checkbox18
# checkbox_track: uc18

- queue: 202201-29865
data_source: "distro: focal"
#- queue: 202201-29865
# provision_data: "distro: focal"

- queue: rpi4b
data_source: "url: http://cdimage.ubuntu.com/ubuntu-core/22/dangerous-stable/current/ubuntu-core-22-arm64+raspi.img.xz"
checkbox_runtime: checkbox22
checkbox_track: uc22
# - queue: rpi4b
# provision_data: "url: http://cdimage.ubuntu.com/ubuntu-core/22/dangerous-stable/current/ubuntu-core-22-arm64+raspi.img.xz"
# checkbox_runtime: checkbox22
# checkbox_track: uc22

- queue: rpi4b
data_source: "url: http://cdimage.ubuntu.com/ubuntu-core/22/dangerous-stable/current/ubuntu-core-22-armhf+raspi.img.xz"
checkbox_runtime: checkbox22
checkbox_track: uc22
# - queue: rpi4b
# provision_data: "url: http://cdimage.ubuntu.com/ubuntu-core/22/dangerous-stable/current/ubuntu-core-22-armhf+raspi.img.xz"
# checkbox_runtime: checkbox22
# checkbox_track: uc22
steps:
- name: Checkout checkbox monorepo
uses: actions/checkout@v4

- name: Create job file (by instantiating template)
id: create-job
run: |
JOB_PATH=${{ github.workspace }}/job.yaml
# instantiate job template with input values
INPUT_QUEUE="${{ matrix.queue }}" \
INPUT_DATA_SOURCE="${{ matrix.data_source }}" \
INPUT_CHECKBOX_RUNTIME="${{ matrix.checkbox_runtime }}" \
INPUT_CHECKBOX_TRACK="${{ matrix.checkbox_track }}" \
INPUT_RESOURCES_PATH="${{ github.workspace }}/.github/workflows/checkbox-promote-beta-to-candidate/resources" \
envsubst '$INPUT_QUEUE $INPUT_DATA_SOURCE $INPUT_CHECKBOX_RUNTIME $INPUT_CHECKBOX_TRACK $INPUT_RESOURCES_PATH' \
< $GITHUB_WORKSPACE/.github/workflows/checkbox-promote-beta-to-candidate/job.template \
> $JOB_PATH
# return path for instantiated job file
echo "job=$JOB_PATH" >> $GITHUB_OUTPUT
- name: Submit job
uses: canonical/testflinger/.github/actions/submit@main
- name: Run the spec
uses: canonical/checkbox/.github/actions/checkbox_source_deb@main
with:
poll: true
job-path: ${{ steps.create-job.outputs.job }}
provision_data: ${{ matrix.spec.provision_data }}
queue: ${{ matrix.spec.queue }}
test_plan: ${{ matrix.spec.test_plan }}
match: ${{ matrix.spec.match }}
zapper_channel: ${{ matrix.spec.zapper_channel }}
launcher_override: |
[environment]
WPA_BG_PSK = ${{ secrets.INPUT_PASSWORD_SECRET }}
WPA_N_PSK = ${{ secrets.INPUT_PASSWORD_SECRET }}
WPA_AC_PSK = ${{ secrets.INPUT_PASSWORD_SECRET }}
WPA_AX_PSK = ${{ secrets.INPUT_PASSWORD_SECRET }}
WPA3_AX_PSK = ${{ secrets.INPUT_PASSWORD_SECRET }}
checkbox_revision: ${{ steps.get_sha.outputs.sha }}
62 changes: 62 additions & 0 deletions tools/lab_dispatch/generic_snap.yaml
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

0 comments on commit 6f93dcd

Please sign in to comment.