diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2023-05-31 09:36:27 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2023-05-31 14:42:09 +0000 |
commit | 49e82466debcefe742c6939cea924adbd9e7c07d (patch) | |
tree | a7856de51cc1e063ed3f3f91d1b6d78d75e68f9b /pw-report.sh | |
parent | a533b9a1c0d918996bfc77d95e1673134f4b42cf (diff) |
pw-{trigger,apply,report,helpers}.sh: New scripts for pre-commit testing
Scripts that use below functions:
- pw-trigger.sh -- looks for new patch series to test in patchworks
and creates trigger-* files for jenkins.
- pw-apply.sh -- fetches and applies a series to a local git clone.
- pw-report.sh -- sends "check" feedback back to patchworks.
On the patchworks side we use bundles as a simple database to store state
of individual patches. For each $ci_bot (aka ci_project/ci_config) we
have 6 bundles: queued, triggered, {apply,test}-{pass,fail}.
- "triggered" bundle is the only one that really affect precommit
workflow, all other bundles are information-only. Triggered bundle
lists patches for which testing has been started, and pw-trigger.sh
will generate trigger-* files for jenkins only for tests, which are
NOT present in this bundle.
- "queued" bundle lists patches for which trigger-* files have been
generated, but testing for which have not been started.
- "apply-pass"/"apply-fail" -- lists patches, which have been successfully
applied or failed to apply.
- "test-pass"/"test-fail" -- lists patches, which successfully passed
pre-commit testing or failed pre-commit testing.
The general workflow is:
1. At the end of successful post-commit testing, after baseline was
updated, pw-trigger.sh generates trigger-* files for jenkins. This
populates jenkins queue with jobs for testing patches posted since
the last successful post-commit build.
2. Jenkins starts a build for a given patch series, and applies to
the local git checkout -- this is done with pw-apply.sh. As soon
as pw-apply.sh has a patch ID, it adds it to "triggered" bundle.
3. If patch applied successfully, pw-apply.sh generates a state file
(artifacts/jenkins/<project>), which has information necessary for
pw-report.sh to send subsequent "check" feedback to patchworks.
3. The build proceeds as a normal post-commit build.
4. Once the build finishes pw-report.sh is called to send the final
"check" -- whether patch passed or failed testing.
Change-Id: Ic49f1b06c2246dcb098091223f73542962cc1902
Diffstat (limited to 'pw-report.sh')
-rwxr-xr-x | pw-report.sh | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/pw-report.sh b/pw-report.sh new file mode 100755 index 00000000..f51adc46 --- /dev/null +++ b/pw-report.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +set -euf -o pipefail +x + +scripts=$(dirname $0) +# shellcheck source=jenkins-helpers.sh +. $scripts/jenkins-helpers.sh +# shellcheck source=pw-helpers.sh +. $scripts/pw-helpers.sh + +convert_args_to_variables "$@" + +obligatory_variables check result pw_dir pw_token +declare check result pw_dir pw_token + +verbose="${verbose-true}" + +if ! [ -d "$pw_dir" ]; then + exit 0 +fi + +bundle_types=({appl,test}-{fail,pass}) +# ... and "triggered" and "queued" -- all bundle types are <= 9 characters long. + +while IFS= read -r -d '' pw_file; do + ( + # shellcheck disable=SC1090 + source "$pw_file" + obligatory_variables project patch_id ci_bot pw_check_cmd build_url + declare project patch_id ci_bot pw_check_cmd build_url + + # BE CAREFUL WITH $pw_token + set +x + # shellcheck disable=SC2064 + trap "pw_deinit $project" EXIT + pw_init "$project" "$pw_token" + + if $verbose; then + set -x + fi + + case "$ci_bot:$result" in + tcwg_*_check--*:fail) + # FIXME: Don't post failed test results while in development. + pw_check_cmd=(echo DRYRUN: "${pw_check_cmd[@]}") + ;; + esac + + case "$check-$result" in + triggered-*) + # Remove $patch_id from *-pass and *-fail bundles. + for i in "${bundle_types[@]}"; do + pw_ci_bot_bundle_remove "$project" "$i" "$ci_bot" \ + "$patch_id" + done + "${pw_check_cmd[@]}" --state pending \ + --description "Test started" \ + --url "${build_url}console" + ;; + apply-fail|apply-pass|test-fail|test-pass) + if [ "$check" = "apply" ]; then + # Make apply-pass and apply-fail fit into 9 characters. + check="appl" + fi + pw_ci_bot_bundle_check_and_add \ + "$project" "$check-$result" "$ci_bot" "$patch_id" true + + case "$check-$result" in + appl-fail) + desc="Patch failed to apply" + url="${build_url}artifact/artifacts/jenkins/pw-apply.log" + state="fail" + ;; + appl-pass) + desc="Patch applied" + url="${build_url}console" + state="pending" + ;; + test-fail) + desc="Testing failed" + url="${build_url}artifact/artifacts/artifacts.precommit/" + state="fail" + ;; + test-pass) + desc="Testing passed" + url="$build_url" + state="success" + ;; + esac + "${pw_check_cmd[@]}" --state "$state" \ + --description "$desc" --url "$url" + ;; + test-ignore) + # Testing failed due to sporadic failure. Allow retrigger testing + # of this patch in the next round. + pw_ci_bot_bundle_remove "$project" "triggered" "$ci_bot" \ + "$patch_id" + desc="Build did not complete; will be retriggered" + "${pw_check_cmd[@]}" --state warning \ + --description "$desc" --url "$build_url" + ;; + esac + ) +done < <(find "$pw_dir" -type f -print0) |