From 98b6c5327089d3faa0b95b01994faae558f54dd8 Mon Sep 17 00:00:00 2001 From: Sawjan Gurung Date: Thu, 8 Jan 2026 14:12:40 +0545 Subject: [PATCH] ci: fix unwanted workflow skip in the cron pipelines (#2117) * ci: run workflow if not found in the list Signed-off-by: Saw-jan * ci: suffix event in cache key to separate cron and push pipelines Signed-off-by: Saw-jan * ci: prefix test workflow with test Signed-off-by: Saw-jan * ci: create empty cache dir for unit tests Signed-off-by: Saw-jan --------- Signed-off-by: Saw-jan --- .woodpecker.star | 3 ++- tests/config/woodpecker/evaluate_pipeline.js | 15 ++++++++++++++- tests/config/woodpecker/upload_pipeline_info.sh | 8 +++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.woodpecker.star b/.woodpecker.star index 9ba4215381..2030aaa41c 100644 --- a/.woodpecker.star +++ b/.woodpecker.star @@ -858,6 +858,7 @@ def testOpencloud(ctx): prefixStepCommands(pipeline, [ ". ./.woodpecker.env", + "mkdir -p cache", '[ "$SKIP_WORKFLOW" = "true" ] && exit 0', ]) return [pipeline] @@ -1743,7 +1744,7 @@ def multiServiceE2ePipeline(ctx): uploadTracingResult(ctx) pipeline = { - "name": "e2e-tests-multi-service%s" % ("-watchfs" if watch_fs_enabled else ""), + "name": "test-e2e-multi-service%s" % ("-watchfs" if watch_fs_enabled else ""), "steps": steps, "depends_on": getPipelineNames(buildOpencloudBinaryForTesting(ctx) + buildWebCache(ctx)), "when": e2e_trigger, diff --git a/tests/config/woodpecker/evaluate_pipeline.js b/tests/config/woodpecker/evaluate_pipeline.js index b5e325a908..87f0446597 100644 --- a/tests/config/woodpecker/evaluate_pipeline.js +++ b/tests/config/woodpecker/evaluate_pipeline.js @@ -3,11 +3,20 @@ const fs = require("fs"); const CI_REPO_NAME = process.env.CI_REPO_NAME; const CI_COMMIT_SHA = process.env.CI_COMMIT_SHA; const CI_WORKFLOW_NAME = process.env.CI_WORKFLOW_NAME; +const CI_PIPELINE_EVENT = process.env.CI_PIPELINE_EVENT; const opencloudBuildWorkflow = "build-opencloud-for-testing"; const webCacheWorkflows = ["cache-web", "cache-web-pnpm", "cache-browsers"]; -const INFO_URL = `https://s3.ci.opencloud.eu/public/${CI_REPO_NAME}/pipelines/${CI_COMMIT_SHA}/pipeline_info.json`; +const INFO_URL = `https://s3.ci.opencloud.eu/public/${CI_REPO_NAME}/pipelines/${CI_COMMIT_SHA}-${CI_PIPELINE_EVENT}/pipeline_info.json`; + +function getWorkflowNames(workflows) { + const allWorkflows = []; + for (const workflow of workflows) { + allWorkflows.push(workflow.name); + } + return allWorkflows; +} function getFailedWorkflows(workflows) { const failedWorkflows = []; @@ -59,6 +68,7 @@ async function main() { process.exit(0); } + const allWorkflows = getWorkflowNames(info.workflows); const failedWorkflows = getFailedWorkflows(info.workflows); // NOTE: implement for test pipelines only for now @@ -78,6 +88,9 @@ async function main() { // process.exit(0); // } + if (!allWorkflows.includes(CI_WORKFLOW_NAME)) { + process.exit(0); + } if (!failedWorkflows.includes(CI_WORKFLOW_NAME)) { console.log("[INFO] Workflow passed in previous pipeline. Skip..."); fs.appendFileSync(".woodpecker.env", "SKIP_WORKFLOW=true\n"); diff --git a/tests/config/woodpecker/upload_pipeline_info.sh b/tests/config/woodpecker/upload_pipeline_info.sh index 6662338cc3..4455066c4d 100644 --- a/tests/config/woodpecker/upload_pipeline_info.sh +++ b/tests/config/woodpecker/upload_pipeline_info.sh @@ -2,10 +2,12 @@ set -e +CACHE_KEY="$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA-$CI_PIPELINE_EVENT" + mc alias set s3 $MC_HOST $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY # check previous pipeline -URL="https://s3.ci.opencloud.eu/$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA/prev_pipeline" +URL="https://s3.ci.opencloud.eu/$CACHE_KEY/prev_pipeline" status=$(curl -s -o prev_pipeline "$URL" -w '%{http_code}') if [ "$status" == "200" ]; @@ -19,9 +21,9 @@ then exit 1 fi # update previous pipeline info - mc cp -a pipeline_info.json "s3/$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA/" + mc cp -a pipeline_info.json "s3/$CACHE_KEY/" fi # upload current pipeline number for the next pipeline echo "PREV_PIPELINE_NUMBER=$CI_PIPELINE_NUMBER" > prev_pipeline -mc cp -a prev_pipeline "s3/$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA/" +mc cp -a prev_pipeline "s3/$CACHE_KEY/"