On 2024-08-02 00:06, Stefano Stabellini wrote:
The ECLAIR jobs part of the Gitlab CI pipeline fail reliably when the
pipeline is started from a merge request. This is the error:
Unexpected event pull_request
The error is a consequence of action.settings setting
event=pull_request
for merge_request_event. Given that we don't need any special behavior
from ECLAIR for merge requests, just run the regular scan, change
action.settings to set event=push for merge_request_event (same as for
pipeline triggered by git push).
According to my analysis, the error stems from the fact that
automation/scripts/eclair unconditionally calls action_push.sh, which is
not designed to handle merge requests (that would be
action_pull_request.sh). One approach, that needs to be tested, could be
to execute that second script based on the value of
${CI_PIPELINE_SOURCE}.
The main difference the approach taken in this patch is that the
analysis results will be relative to the nearest merge point with the
staging tree. If that's not something that is desired, then this
approach looks good to me.
Signed-off-by: Stefano Stabellini <stefano.stabell...@amd.com>
---
Example of a failure:
https://gitlab.com/xen-project/hardware/xen/-/jobs/7486162928
Example of a success with this patch applies:
https://gitlab.com/xen-project/people/sstabellini/xen/-/pipelines/1397672866
diff --git a/automation/eclair_analysis/ECLAIR/action.settings
b/automation/eclair_analysis/ECLAIR/action.settings
index 1577368b61..1bfb22b1c1 100644
--- a/automation/eclair_analysis/ECLAIR/action.settings
+++ b/automation/eclair_analysis/ECLAIR/action.settings
@@ -64,14 +64,11 @@ gitlab)
case "${CI_PIPELINE_SOURCE}" in
merge_request_event)
- event=pull_request
- pullRequestId="${CI_MERGE_REQUEST_IID}"
- pullRequestHeadRef="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
- pullRequestHeadRepo="${CI_MERGE_REQUEST_SOURCE_PROJECT_PATH}"
- pullRequestBaseRef="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
- pullRequestUser="${GITLAB_USER_LOGIN}"
+ event=push
+ ref_kind=branch
+ ref="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
headCommitId="${CI_COMMIT_SHA}"
- baseCommitId="${CI_MERGE_REQUEST_DIFF_BASE_SHA}"
+ pushUser="${GITLAB_USER_NAME}"
;;
push | pipeline | web | schedule)
event=push
--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)