Skip to content

Use type instead of name in thermal sensor tests (Bugfix) #6886

Use type instead of name in thermal sensor tests (Bugfix)

Use type instead of name in thermal sensor tests (Bugfix) #6886

name: PR Validation
permissions:
contents: read
on:
pull_request:
types:
- opened
- synchronize
- edited
jobs:
validate_title:
runs-on: ubuntu-latest
steps:
- name: Checking the presence of the Traceability Marker in the PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
if echo "$PR_TITLE" | grep -iqP " \((infra|bugfix|new|breaking)\)$"; then
echo "PR title contains the traceability marker"
exit 0
else
echo "Traceability marker missing"
echo "Update your title with one of the following postfix"
echo "(Infra,Bugfix,New,Breaking)"
echo
echo "e.g. $PR_TITLE (BugFix)"
exit 1
fi
sru_gate:
runs-on: ubuntu-latest
steps:
- name: Checkout Checkbox monorepo
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
fetch-depth: 0
persist-credentials: false
- name: Install dependencies, Checkbox and providers
run: |
sudo apt update
sudo apt install -y -qq python3 python3-venv jq
python3 -m venv venv
. venv/bin/activate
python3 -m pip install checkbox-ng/
python3 -m pip install checkbox-support/
python3 providers/resource/manage.py develop
python3 providers/base/manage.py develop
python3 providers/certification-client/manage.py develop
python3 providers/tpm2/manage.py develop
python3 providers/sru/manage.py develop
- name: Export main sru list
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.html_url }}
run: |
export DESCRIPTION=$(gh pr view $PR --json 'body' --jq '.body')
# we are on current branch/commit
. venv/bin/activate
checkbox-cli expand -f json com.canonical.certification::sru-server >> sru_server_testplan_this_branch.json
checkbox-cli expand -f json com.canonical.certification::sru >> sru_testplan_this_branch.json
git checkout origin/main
checkbox-cli expand -f json com.canonical.certification::sru-server >> sru_server_testplan_main.json
checkbox-cli expand -f json com.canonical.certification::sru >> sru_testplan_main.json
# https://stackoverflow.com/a/57795761
# compare two jsons without comparing the order arrays but just
# the content of objects
echo
echo
echo "Difference of com.canonical.certification::sru-server (diff this_branch main)"
# The following line sorts the array of jobs/templates obtained from the pre/post checkout.
# This is done because we want compare the list/content of jobs but not necessarily the order
# that for most jobs is not deterministic either way. The array keys are sorted as well
# as what counts is the content of each key (id, environ, command) and not the order
# the exporter prints them out.
# Taken partially from: https://github.com/jqlang/jq/issues/893
diff \
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_server_testplan_this_branch.json") \
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_server_testplan_main.json") | tee sru_server_diff.txt
if [ -s sru_server_diff.txt ]; then
# if the sru_server_diff file is not empty, there is at least one diff (patch) done to it
# require the PR description to contain the bold text highlighting it
if [[ "$DESCRIPTION" == *"## WARNING: This modifies com.canonical.certification::sru-server"* ]]; then
echo "Warning is correcty posted in the description for sru-server"
else
echo "Missing warning for sru modification in the description"
echo "Include the following in your description:"
echo " ## WARNING: This modifies com.canonical.certification::sru-server"
exit 1
fi
else
echo "No diff found"
fi
echo "Difference of com.canonical.certification::sru (diff this_branch main)"
# the following line sorts the array of jobs/templates obtained from the pre/post checkout
# this is done because we want compare the list/content of jobs but not necessarely the order
# that for most jobs is not deterministic either way. The array keys are sorted as well
# as what counts is the content of each key (id, environ, command) and not the order
# the exporter prints them out
# Taken partially from: https://github.com/jqlang/jq/issues/893
diff \
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_testplan_this_branch.json") \
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_testplan_main.json") | tee sru_diff.txt
if [ -s sru_diff.txt ]; then
# if the sru_server_diff file is not empty, there is at least one diff (patch) done to it
# require the PR description to contain the bold text highlighting it
if [[ "$DESCRIPTION" == *"## WARNING: This modifies com.canonical.certification::sru"* ]]; then
echo "Warning is correcty posted in the description for sru"
else
echo "Missing warning for sru modification in the description"
echo "Include the following in your description:"
echo " ## WARNING: This modifies com.canonical.certification::sru"
exit 1
fi
else
echo "No diff found"
fi
check_missing_manifests:
runs-on: ubuntu-latest
steps:
- name: Checkout Checkbox monorepo
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
fetch-depth: 0
persist-credentials: false
- name: Install dependencies, Checkbox and providers
run: |
sudo apt update
sudo apt install -y -qq python3 python3-venv jq
python3 -m venv venv
. venv/bin/activate
python3 -m pip install checkbox-ng/
python3 -m pip install checkbox-support/
python3 providers/resource/manage.py develop
python3 providers/base/manage.py develop
python3 providers/certification-client/manage.py develop
python3 providers/tpm2/manage.py develop
python3 providers/sru/manage.py develop
- name: Export manifest entries
run: |
# we are on current branch/commit
. venv/bin/activate
# Export list of manifest entries as a JSON array
checkbox-cli list 'manifest entry' --format=json > manifest_pr.json
git checkout origin/main
checkbox-cli list 'manifest entry' --format=json > manifest_main.json
# back to PR branch
git checkout -
- name: Trigger workflow in DUT config repo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DUT_CONFIG_TOKEN: ${{ secrets.DUT_CONFIG_PAT }}
run: |
OUTPUT=$(python3 tools/compare_manifests.py manifest_main.json manifest_pr.json)
COMMIT=$(git rev-parse HEAD)
if [[ "$OUTPUT" ]]; then
echo "Differences: $OUTPUT"
echo "New hidden manifest entries found. Checking DUT configuration in the lab..."
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${DUT_CONFIG_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/canonical/ce-oem-dut-checkbox-configuration/dispatches \
-d "{\"event_type\":\"check-missing-manifests\",\"client_payload\":{\"manifest-entries\":\"$OUTPUT\", \"commit\": \"$COMMIT\"}}"
else
echo "No new hidden manifest entries found. No need to check DUT configuration in the lab."
fi