Skip to content

Commit

Permalink
[CHECKBOX-1447] Github workflow for promoting beta to candidate (Infr…
Browse files Browse the repository at this point in the history
…a) (#1284)

* [CHECKBOX-1447] feat: Add workflow for promoting beta to candidate

* [CHECKBOX-1447] fix: include branch when using composite action

* [CHECKBOX-1447] update promotion workflow

* [CHECKBOX-1447] fix: correct conditional for Checkbox version

* [CHECKBOX-1447] Download installer from main tools branch

* chore: update Checkbox promotion workflow to latest scriptlets

* fix: exit from `test_cmds` with Checkbox's exit status

* feat: Use job template instead of inline job definition

* fix: rename template to avoid it being treated as a workflow

* fix: use quotes when using matrix values for environment variables

* fix: appropriate name and branch

* chore: path no longer necessary for calling `fetch_manifest`

* feat: retrieve auxillary launcher fragments from Checkbox repo

* Expand matrix of promo job (infra) (#1388)

* Expand canary matrix for candidate promotion
* Temporarily remove `--no-wait` from snap install
* Fix debian install step
* Use/maintain a single scriptlet branch

---------

Co-authored-by: George Boukeas <george.boukeas@canonical.com>

* fix: remove erroneous matrix entry

* fix: use `wait_for_snap_change_id` when installing Checkbox from snap

* fix: wait for global (instead of specific) snap changes

* chore: remove `push` trigger for promotion workflow

---------

Co-authored-by: Massimiliano <massimiliano.girardi@canonical.com>
  • Loading branch information
boukeas and Hook25 authored Oct 7, 2024
1 parent 017d7ff commit 440c0f2
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/checkbox-promote-beta-to-candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Promote Checkbox beta to candidate
on:
workflow_dispatch:

jobs:
checkbox-promotion-beta-to-candidate-test:
runs-on: [self-hosted, testflinger]
strategy:
fail-fast: false
matrix:
include:
- queue: 201712-26047
data_source: "distro: xenial"
checkbox_runtime: checkbox16
checkbox_track: uc16

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

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

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

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

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

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

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

- queue: 202201-29865
data_source: "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
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
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
with:
poll: true
job-path: ${{ steps.create-job.outputs.job }}
79 changes: 79 additions & 0 deletions .github/workflows/checkbox-promote-beta-to-candidate/job.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
job_queue: $INPUT_QUEUE
global_timeout: 3600
output_timeout: 1800
provision_data:
$INPUT_DATA_SOURCE
test_data:
attachments:
- local: "$INPUT_RESOURCES_PATH/manifest.conf"
agent: "resources/manifest.conf"
- local: "$INPUT_RESOURCES_PATH/testplan.conf"
agent: "resources/testplan.conf"
test_cmds: |
#!/usr/bin/env bash

set -x

# input arguments
CHECKBOX_RUNTIME=$INPUT_CHECKBOX_RUNTIME
CHECKBOX_TRACK=$INPUT_CHECKBOX_TRACK

# flag to indicate how Checkbox is installed on the device (snap or deb)
[ -n "$CHECKBOX_RUNTIME" ] && [ -n "$CHECKBOX_TRACK" ] && SNAP_FLAG="true" || SNAP_FLAG="false"

# constants
CHANNEL=beta
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/CERTTF-337-scriptlets-sru/install_tools.sh
source install_tools.sh $TOOLS_PATH --branch CERTTF-337-scriptlets-sru

# ensure device is available before continuing
wait_for_ssh

# install checkbox runtime on device (snap or deb)
if [[ "$SNAP_FLAG" == "true" ]]; then
echo "Installing checkbox runtime on device (from snap)"
CHANGE_ID=$(_run sudo snap install $CHECKBOX_RUNTIME --no-wait --channel=latest/$CHANNEL)
wait_for_snap_changes
CHANGE_ID=$(_run sudo snap install checkbox --devmode --channel=$CHECKBOX_TRACK/$CHANNEL)
wait_for_snap_changes
# list all the installed snaps to facilitate debugging
_run snap list
CHECKBOX_CLI_CMD="checkbox.checkbox-cli"
else
echo "Installing checkbox runtime on device (from deb package)"
_run sudo add-apt-repository -y ppa:checkbox-dev/$CHANNEL
_run install_packages checkbox-ng python3-checkbox-ng checkbox-provider-base checkbox-provider-resource checkbox-provider-sru fswebcam obexftp wmctrl iperf mesa-utils vim pastebinit fwts xorg-dev gir1.2-clutter-1.0
# list installed checkbox-related packages to facilitate debugging
_run "apt list --installed | grep checkbox"
CHECKBOX_CLI_CMD="checkbox-cli"
fi

check_for_checkbox_service --debug || exit 1

# sync Checkbox version between agent and device
CHECKBOX_VERSION=$(_run $CHECKBOX_CLI_CMD --version)
[ -z "$CHECKBOX_VERSION" ] && echo "Error: Unable to retrieve Checkbox version from device" && exit 1
echo "Installing checkbox $CHECKBOX_VERSION on agent container from source"
install_checkbox_agent_source $CHECKBOX_VERSION $TOOLS_PATH

# retrieve manifest
RESOURCES_PATH=attachments/test/resources
MANIFEST_FILE=manifest.conf
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
# create checkbox launcher
stacker --output checkbox.conf $RESOURCES_PATH/testplan.conf $MANIFEST_FILE

# run the canary test plan
PYTHONUNBUFFERED=1 checkbox-cli control $DEVICE_IP checkbox.conf
EXITCODE=$?

# placeholder for gathering possible artifacts

exit $EXITCODE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[manifest]
com.canonical.certification::has_bt_smart = false
com.canonical.certification::has_camera = true
com.canonical.certification::has_card_reader = true
com.canonical.certification::has_ethernet_adapter = true
com.canonical.certification::has_thunderbolt = false
com.canonical.certification::has_thunderbolt3 = false
com.canonical.certification::has_touchscreen = false
com.canonical.certification::has_tpm2_chip = false
com.canonical.certification::has_usb_storage = true
com.canonical.certification::has_usb_type_c = false
com.canonical.certification::has_wlan_adapter = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[launcher]
launcher_version = 1
stock_reports = certification

[test plan]
unit = com.canonical.certification::canary
forced = yes

[test selection]
forced = true

[ui]
type = silent

0 comments on commit 440c0f2

Please sign in to comment.