Skip to content

Commit d2c1c4c

Browse files
committed
fix(#31): preserve skipped steps to avoid Drone DAG reference errors
1 parent 1a1155e commit d2c1c4c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

plugin.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,26 @@ app.post('/', bodyParser.json({limit: '50mb'}), async (req, res) => {
5858
}
5959
}
6060

61-
const trimmedSteps = py.steps.filter(s => {
61+
const transformedSteps = py.steps.map(s => {
6262
if (!s.when || !s.when.changeset || !s.when.changeset.includes) return true
6363
const requiredFiles = s.when.changeset.includes
6464
const matchedFiles = glob.match(requiredFiles, filesChanged, { dot: true })
6565
console.log('Matched files for step:', matchedFiles.length, 'Allowed matches:', requiredFiles)
66-
return matchedFiles.length
66+
67+
if (matchedFiles.length) {
68+
// Allow it through unchanged
69+
return s;
70+
} else {
71+
// Add an impossible conditional which guarantees the step gets skipped
72+
s.when = {
73+
...s.when,
74+
event: { exclude: ['*']},
75+
}
76+
return s;
77+
}
6778
})
6879

69-
return trimmedSteps.length ? yaml.stringify({ ...py, steps: trimmedSteps }) : nullYaml(index)
80+
return transformedSteps.length ? yaml.stringify({ ...py, steps: transformedSteps }) : nullYaml(index)
7081
})
7182

7283
res.json({ Data: finalYamlDocs.join('\n---\n') })

0 commit comments

Comments
 (0)