Skip to content

Commit b2c0e8d

Browse files
authored
ci: fix unwanted workflow skip in the cron pipelines (#2117)
* ci: run workflow if not found in the list Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * ci: suffix event in cache key to separate cron and push pipelines Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * ci: prefix test workflow with test Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * ci: create empty cache dir for unit tests Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> --------- Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com>
1 parent 186bbc8 commit b2c0e8d

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

.woodpecker.star

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ def testOpencloud(ctx):
859859

860860
prefixStepCommands(pipeline, [
861861
". ./.woodpecker.env",
862+
"mkdir -p cache",
862863
'[ "$SKIP_WORKFLOW" = "true" ] && exit 0',
863864
])
864865
return [pipeline]
@@ -1744,7 +1745,7 @@ def multiServiceE2ePipeline(ctx):
17441745
uploadTracingResult(ctx)
17451746

17461747
pipeline = {
1747-
"name": "e2e-tests-multi-service%s" % ("-watchfs" if watch_fs_enabled else ""),
1748+
"name": "test-e2e-multi-service%s" % ("-watchfs" if watch_fs_enabled else ""),
17481749
"steps": steps,
17491750
"depends_on": getPipelineNames(buildOpencloudBinaryForTesting(ctx) + buildWebCache(ctx)),
17501751
"when": e2e_trigger,

tests/config/woodpecker/evaluate_pipeline.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ const fs = require("fs");
33
const CI_REPO_NAME = process.env.CI_REPO_NAME;
44
const CI_COMMIT_SHA = process.env.CI_COMMIT_SHA;
55
const CI_WORKFLOW_NAME = process.env.CI_WORKFLOW_NAME;
6+
const CI_PIPELINE_EVENT = process.env.CI_PIPELINE_EVENT;
67

78
const opencloudBuildWorkflow = "build-opencloud-for-testing";
89
const webCacheWorkflows = ["cache-web", "cache-web-pnpm", "cache-browsers"];
910

10-
const INFO_URL = `https://s3.ci.opencloud.eu/public/${CI_REPO_NAME}/pipelines/${CI_COMMIT_SHA}/pipeline_info.json`;
11+
const INFO_URL = `https://s3.ci.opencloud.eu/public/${CI_REPO_NAME}/pipelines/${CI_COMMIT_SHA}-${CI_PIPELINE_EVENT}/pipeline_info.json`;
12+
13+
function getWorkflowNames(workflows) {
14+
const allWorkflows = [];
15+
for (const workflow of workflows) {
16+
allWorkflows.push(workflow.name);
17+
}
18+
return allWorkflows;
19+
}
1120

1221
function getFailedWorkflows(workflows) {
1322
const failedWorkflows = [];
@@ -59,6 +68,7 @@ async function main() {
5968
process.exit(0);
6069
}
6170

71+
const allWorkflows = getWorkflowNames(info.workflows);
6272
const failedWorkflows = getFailedWorkflows(info.workflows);
6373

6474
// NOTE: implement for test pipelines only for now
@@ -78,6 +88,9 @@ async function main() {
7888
// process.exit(0);
7989
// }
8090

91+
if (!allWorkflows.includes(CI_WORKFLOW_NAME)) {
92+
process.exit(0);
93+
}
8194
if (!failedWorkflows.includes(CI_WORKFLOW_NAME)) {
8295
console.log("[INFO] Workflow passed in previous pipeline. Skip...");
8396
fs.appendFileSync(".woodpecker.env", "SKIP_WORKFLOW=true\n");

tests/config/woodpecker/upload_pipeline_info.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
set -e
44

5+
CACHE_KEY="$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA-$CI_PIPELINE_EVENT"
6+
57
mc alias set s3 $MC_HOST $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY
68

79
# check previous pipeline
8-
URL="https://s3.ci.opencloud.eu/$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA/prev_pipeline"
10+
URL="https://s3.ci.opencloud.eu/$CACHE_KEY/prev_pipeline"
911
status=$(curl -s -o prev_pipeline "$URL" -w '%{http_code}')
1012

1113
if [ "$status" == "200" ];
@@ -19,9 +21,9 @@ then
1921
exit 1
2022
fi
2123
# update previous pipeline info
22-
mc cp -a pipeline_info.json "s3/$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA/"
24+
mc cp -a pipeline_info.json "s3/$CACHE_KEY/"
2325
fi
2426

2527
# upload current pipeline number for the next pipeline
2628
echo "PREV_PIPELINE_NUMBER=$CI_PIPELINE_NUMBER" > prev_pipeline
27-
mc cp -a prev_pipeline "s3/$PUBLIC_BUCKET/$CI_REPO_NAME/pipelines/$CI_COMMIT_SHA/"
29+
mc cp -a prev_pipeline "s3/$CACHE_KEY/"

0 commit comments

Comments
 (0)