Skip to content

Commit 4c52173

Browse files
authored
Merge pull request #32 from kdnutrien/issue-31-preserve-skipped-steps
fix(#31): preserve skipped steps to avoid Drone DAG reference errors
2 parents 1a1155e + 455305d commit 4c52173

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

plugin.js

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

61-
const trimmedSteps = py.steps.filter(s => {
62-
if (!s.when || !s.when.changeset || !s.when.changeset.includes) return true
61+
const transformedSteps = py.steps.map(s => {
62+
if (!s.when || !s.when.changeset || !s.when.changeset.includes) {
63+
return s;
64+
}
65+
6366
const requiredFiles = s.when.changeset.includes
6467
const matchedFiles = glob.match(requiredFiles, filesChanged, { dot: true })
6568
console.log('Matched files for step:', matchedFiles.length, 'Allowed matches:', requiredFiles)
66-
return matchedFiles.length
69+
70+
if (!matchedFiles.length) {
71+
// Add an impossible conditional which guarantees the step gets skipped
72+
s.when = {
73+
...s.when,
74+
event: { exclude: ['*'] },
75+
}
76+
}
77+
78+
return s;
6779
})
6880

69-
return trimmedSteps.length ? yaml.stringify({ ...py, steps: trimmedSteps }) : nullYaml(index)
81+
return transformedSteps.length ? yaml.stringify({ ...py, steps: transformedSteps }) : nullYaml(index)
7082
})
7183

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

0 commit comments

Comments
 (0)