Skip to content

Commit 863d31d

Browse files
authored
feat: skip git clone when the sd.yaml has config-parser-error (#183)
1 parent 938ce1a commit 863d31d

9 files changed

Lines changed: 29 additions & 13 deletions

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ function parsePipelineYaml({
269269
}
270270
],
271271
secrets: [],
272-
environment: {}
272+
environment: {
273+
SD_SKIP_REPOSITORY_CLONE: 'true'
274+
}
273275
}
274276
]
275277
},

test/data/bad-build-cluster.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
}
1212
],
1313
"secrets": [],
14-
"environment": {}
14+
"environment": {
15+
"SD_SKIP_REPOSITORY_CLONE": "true"
16+
}
1517
}
1618
]
1719
},

test/data/bad-notification-email-settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
}
1212
],
1313
"secrets": [],
14-
"environment": {}
14+
"environment": {
15+
"SD_SKIP_REPOSITORY_CLONE": "true"
16+
}
1517
}
1618
]
1719
},

test/data/bad-notification-shared-settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
}
1212
],
1313
"secrets": [],
14-
"environment": {}
14+
"environment": {
15+
"SD_SKIP_REPOSITORY_CLONE": "true"
16+
}
1517
}
1618
]
1719
},

test/data/bad-notification-slack-email-settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
}
1212
],
1313
"secrets": [],
14-
"environment": {}
14+
"environment": {
15+
"SD_SKIP_REPOSITORY_CLONE": "true"
16+
}
1517
}
1618
]
1719
},

test/data/bad-notification-slack-settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
}
1212
],
1313
"secrets": [],
14-
"environment": {}
14+
"environment": {
15+
"SD_SKIP_REPOSITORY_CLONE": "true"
16+
}
1517
}
1618
]
1719
},

test/data/pipeline-cache-false-nonexist-job.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
}
1212
],
1313
"secrets": [],
14-
"environment": {}
14+
"environment": {
15+
"SD_SKIP_REPOSITORY_CLONE": "true"
16+
}
1517
}
1618
]
1719
},

test/data/pipeline-cache-nonexist-job.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
}
1212
],
1313
"secrets": [],
14-
"environment": {}
14+
"environment": {
15+
"SD_SKIP_REPOSITORY_CLONE": "true"
16+
}
1517
}
1618
]
1719
},

test/index.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('config parser', () => {
5656
});
5757
assert.strictEqual(data.jobs.main[0].image, 'node:18');
5858
assert.deepEqual(data.jobs.main[0].secrets, []);
59-
assert.deepEqual(data.jobs.main[0].environment, {});
59+
assert.deepEqual(data.jobs.main[0].environment, { SD_SKIP_REPOSITORY_CLONE: 'true' });
6060
assert.strictEqual(data.jobs.main[0].commands[0].name, 'config-parse-error');
6161
assert.match(data.jobs.main[0].commands[0].command, YAMLMISSING);
6262
assert.match(data.errors[0], YAMLMISSING);
@@ -67,7 +67,7 @@ describe('config parser', () => {
6767
parser({ yaml: 'foo: :' }).then(data => {
6868
assert.strictEqual(data.jobs.main[0].image, 'node:18');
6969
assert.deepEqual(data.jobs.main[0].secrets, []);
70-
assert.deepEqual(data.jobs.main[0].environment, {});
70+
assert.deepEqual(data.jobs.main[0].environment, { SD_SKIP_REPOSITORY_CLONE: 'true' });
7171
assert.strictEqual(data.jobs.main[0].commands[0].name, 'config-parse-error');
7272
assert.match(data.jobs.main[0].commands[0].command, /YAMLException:/);
7373
assert.match(data.errors[0], /YAMLException:/);
@@ -77,7 +77,7 @@ describe('config parser', () => {
7777
parser({ yaml: loadData('basic-job-with-duplicate-steps.yaml') }).then(data => {
7878
assert.strictEqual(data.jobs.main[0].image, 'node:18');
7979
assert.deepEqual(data.jobs.main[0].secrets, []);
80-
assert.deepEqual(data.jobs.main[0].environment, {});
80+
assert.deepEqual(data.jobs.main[0].environment, { SD_SKIP_REPOSITORY_CLONE: 'true' });
8181
assert.strictEqual(data.jobs.main[0].commands[0].name, 'config-parse-error');
8282
assert.match(data.jobs.main[0].commands[0].command, /Error:.*main has duplicate step: publish/);
8383
assert.match(data.errors[0], /Error:.*main has duplicate step: publish/);
@@ -95,7 +95,7 @@ describe('config parser', () => {
9595
parser({ yaml: 'foo: bar\n---\nfoo: baz' }).then(data => {
9696
assert.strictEqual(data.jobs.main[0].image, 'node:18');
9797
assert.deepEqual(data.jobs.main[0].secrets, []);
98-
assert.deepEqual(data.jobs.main[0].environment, {});
98+
assert.deepEqual(data.jobs.main[0].environment, { SD_SKIP_REPOSITORY_CLONE: 'true' });
9999
assert.strictEqual(data.jobs.main[0].commands[0].name, 'config-parse-error');
100100
assert.match(data.jobs.main[0].commands[0].command, /YAMLException:.*ambigious/);
101101
assert.match(data.errors[0], /YAMLException:.*ambigious/);
@@ -105,7 +105,7 @@ describe('config parser', () => {
105105
parser({ yaml: 'jobs: {}\n---\nversion: 4' }).then(data => {
106106
assert.strictEqual(data.jobs.main[0].image, 'node:18');
107107
assert.deepEqual(data.jobs.main[0].secrets, []);
108-
assert.deepEqual(data.jobs.main[0].environment, {});
108+
assert.deepEqual(data.jobs.main[0].environment, { SD_SKIP_REPOSITORY_CLONE: 'true' });
109109
assert.strictEqual(data.jobs.main[0].commands[0].name, 'config-parse-error');
110110
assert.match(data.errors[0], 'ValidationError: "jobs" is required');
111111
}));

0 commit comments

Comments
 (0)