Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/utils/graph-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ const calcNodeDepths = graph => {
depth[n.name] = 0;
});
graph.edges.forEach(({ src, dest }) => {
if (!nodes[src] || !nodes[dest]) {
return;
}

if (!edges[src]) {
edges[src] = [];
}
Expand Down Expand Up @@ -955,6 +959,8 @@ const decorateGraph = ({
const destNode = node(nodes, e.dest);

if (!srcNode || !destNode) {
e.hidden = true;

return;
}

Expand Down
57 changes: 57 additions & 0 deletions tests/unit/utils/graph-tools-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,63 @@ module('Unit | Utility | graph tools', function () {
assert.deepEqual(result, expectedOutput);
});

test('it hides edges from unknown external triggers to existing external jobs', function (assert) {
const inputGraph = {
nodes: [
{ name: '~commit' },
{ name: 'main-job' },
{ name: 'sd@123:external-job' }
],
edges: [
{ src: '~commit', dest: 'main-job' },
{
src: 'main-job',
dest: 'sd@123:external-job'
},
{
src: '~sd@456:upstream-job',
dest: 'sd@123:external-job'
}
]
};
const expectedOutput = {
nodes: [
{ name: '~commit', pos: { x: 0, y: 0 } },
{ name: 'main-job', pos: { x: 1, y: 0 } },
{ name: 'sd@123:external-job', pos: { x: 2, y: 0 } }
],
edges: [
{
src: '~commit',
dest: 'main-job',
from: { x: 0, y: 0 },
to: { x: 1, y: 0 }
},
{
src: 'main-job',
dest: 'sd@123:external-job',
from: { x: 1, y: 0 },
to: { x: 2, y: 0 }
},
{
src: '~sd@456:upstream-job',
dest: 'sd@123:external-job',
hidden: true
}
],
stages: [],
stageEdges: [],
meta: {
height: 1,
width: 3
}
};

const result = decorateGraph({ inputGraph });

assert.deepEqual(result, expectedOutput);
});

test('it processes a more complex graph without builds', function (assert) {
const expectedOutput = {
nodes: [
Expand Down