-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lint
zeebe:VersionTag
extension and zeebe:versionTag
attribute
Related to camunda/camunda#19812
- Loading branch information
1 parent
0c22fc2
commit 84a48e8
Showing
7 changed files
with
524 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const { is } = require('bpmnlint-utils'); | ||
|
||
const { hasProperties, findExtensionElement, hasNoExtensionElement } = require('../utils/element'); | ||
|
||
const { reportErrors } = require('../utils/reporter'); | ||
|
||
const { skipInNonExecutableProcess } = require('../utils/rule'); | ||
|
||
const allowedVersion = '8.6'; | ||
|
||
module.exports = skipInNonExecutableProcess(function() { | ||
function check(node, reporter) { | ||
if (is(node, 'bpmn:Process')) { | ||
const errors = hasNoExtensionElement(node, 'zeebe:VersionTag', node, allowedVersion); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
|
||
return; | ||
} | ||
|
||
let extensionElement; | ||
|
||
if (is(node, 'bpmn:BusinessRuleTask')) { | ||
extensionElement = findExtensionElement(node, 'zeebe:CalledDecision'); | ||
} else if (is(node, 'bpmn:CallActivity')) { | ||
extensionElement = findExtensionElement(node, 'zeebe:CalledElement'); | ||
} else if (is(node, 'bpmn:UserTask')) { | ||
extensionElement = findExtensionElement(node, 'zeebe:FormDefinition'); | ||
} | ||
|
||
if (extensionElement) { | ||
let errors = hasProperties(extensionElement, { | ||
bindingType: { | ||
allowed: (value) => value !== 'versionTag', | ||
allowedVersion | ||
} | ||
}, node); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
|
||
return; | ||
} | ||
|
||
errors = hasProperties(extensionElement, { | ||
versionTag: { | ||
allowed: false, | ||
allowedVersion | ||
} | ||
}, node); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0949dru" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.26.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:extensionElements> | ||
<zeebe:versionTag value="v1.0.0" /> | ||
</bpmn:extensionElements> | ||
<bpmn:callActivity id="CallActivity_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledElement processId="foo" propagateAllChildVariables="false" bindingType="versionTag" versionTag="v1.0.0" /> | ||
</bpmn:extensionElements> | ||
</bpmn:callActivity> | ||
<bpmn:businessRuleTask id="BusinessRuleTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledDecision decisionId="foo" resultVariable="foo" bindingType="versionTag" versionTag="v1.0.0" /> | ||
</bpmn:extensionElements> | ||
</bpmn:businessRuleTask> | ||
<bpmn:userTask id="UserTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:formDefinition formId="foo" bindingType="versionTag" versionTag="v1.0.0" /> | ||
</bpmn:extensionElements> | ||
</bpmn:userTask> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="Activity_04qoo0e_di" bpmnElement="CallActivity_1"> | ||
<dc:Bounds x="160" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_0rpa9kq_di" bpmnElement="BusinessRuleTask_1"> | ||
<dc:Bounds x="290" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_1t7eh0a_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="420" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const { expect } = require('chai'); | ||
|
||
const Linter = require('bpmnlint/lib/linter'); | ||
|
||
const NodeResolver = require('bpmnlint/lib/resolver/node-resolver'); | ||
|
||
const { readModdle } = require('../../helper'); | ||
|
||
const versions = [ | ||
'1.0', | ||
'1.1', | ||
'1.2', | ||
'1.3', | ||
'8.0', | ||
'8.1', | ||
'8.2', | ||
'8.3', | ||
'8.4', | ||
'8.5' | ||
]; | ||
|
||
describe('integration - no-version-tag', function() { | ||
|
||
versions.forEach(function(version) { | ||
|
||
let linter; | ||
|
||
beforeEach(function() { | ||
linter = new Linter({ | ||
config: { | ||
extends: `plugin:camunda-compat/camunda-cloud-${ version.replace('.', '-') }` | ||
}, | ||
resolver: new NodeResolver() | ||
}); | ||
}); | ||
|
||
|
||
describe(`Camunda Cloud ${ version }`, function() { | ||
|
||
describe('no errors', function() { | ||
|
||
it('should not have errors', async function() { | ||
|
||
// given | ||
const { root } = await readModdle('test/camunda-cloud/integration/no-version-tag.bpmn'); | ||
|
||
// when | ||
const reports = await linter.lint(root); | ||
|
||
// then | ||
expect(reports[ 'camunda-compat/no-version-tag' ]).not.to.exist; | ||
}); | ||
|
||
}); | ||
|
||
|
||
describe('errors', function() { | ||
|
||
it('should have errors', async function() { | ||
|
||
// given | ||
const { root } = await readModdle('test/camunda-cloud/integration/no-version-tag-errors.bpmn'); | ||
|
||
// when | ||
const reports = await linter.lint(root); | ||
|
||
// then | ||
expect(reports[ 'camunda-compat/no-version-tag' ]).to.exist; | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0949dru" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.26.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0"> | ||
<bpmn:process id="Process_1" isExecutable="true"> | ||
<bpmn:callActivity id="CallActivity_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledElement processId="foo" propagateAllChildVariables="false" bindingType="deployment" /> | ||
</bpmn:extensionElements> | ||
</bpmn:callActivity> | ||
<bpmn:businessRuleTask id="BusinessRuleTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:calledDecision decisionId="foo" resultVariable="foo" bindingType="deployment" /> | ||
</bpmn:extensionElements> | ||
</bpmn:businessRuleTask> | ||
<bpmn:userTask id="UserTask_1"> | ||
<bpmn:extensionElements> | ||
<zeebe:formDefinition formId="foo" bindingType="deployment" /> | ||
</bpmn:extensionElements> | ||
</bpmn:userTask> | ||
</bpmn:process> | ||
<bpmndi:BPMNDiagram id="BPMNDiagram_1"> | ||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1"> | ||
<bpmndi:BPMNShape id="Activity_04qoo0e_di" bpmnElement="CallActivity_1"> | ||
<dc:Bounds x="160" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_0rpa9kq_di" bpmnElement="BusinessRuleTask_1"> | ||
<dc:Bounds x="290" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
<bpmndi:BPMNShape id="Activity_1t7eh0a_di" bpmnElement="UserTask_1"> | ||
<dc:Bounds x="420" y="80" width="100" height="80" /> | ||
</bpmndi:BPMNShape> | ||
</bpmndi:BPMNPlane> | ||
</bpmndi:BPMNDiagram> | ||
</bpmn:definitions> |
Oops, something went wrong.