-
Notifications
You must be signed in to change notification settings - Fork 159
Make do an array #895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cdavernas
merged 25 commits into
serverlessworkflow:main
from
matthias-pichler:matthias-pichler/invalid-do-switch-894
Jun 13, 2024
Merged
Make do an array #895
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0765c3a
feat: update schema
matthias-pichler 3166c14
docs: update examples
matthias-pichler ff4fb6e
fix: do not allow more properties in tasks
matthias-pichler 27ee947
lint: format examples
matthias-pichler 5ad9f30
refactor: add node: module prefix
matthias-pichler 36bb47d
refactor: update testing to more idiomatic JS
matthias-pichler 2709fb5
refactor: update test file to use .each
matthias-pichler 3b7d4ab
feat: switch to json schema 2020
matthias-pichler 470709a
refactor: rename index.test
matthias-pichler 06fa87a
test: add invalid workflows
matthias-pichler 1e6d28c
refactor: switch back to composite wording
matthias-pichler 270deb1
docs: update dsl
matthias-pichler f658c7d
refactor: rename branch to fork
matthias-pichler 50b93c2
test: add tests for examples in dsl-reference
matthias-pichler 9f422f5
Merge branch 'main' into matthias-pichler/invalid-do-switch-894
matthias-pichler b27cb7b
fix: rename composite ctk tests
matthias-pichler 10cab1c
fix: update export heading
matthias-pichler 2bf543b
fox: remove trailing +
matthias-pichler 89d1432
fix: apply suggestions
matthias-pichler c91754a
refactor: split schema of fork and do
matthias-pichler 51f786b
test: split ctk features
matthias-pichler 5f698ee
docs: split do & fork in dsl
matthias-pichler b5c71f1
fix: update workflow schema id
matthias-pichler a2b21f0
docs: remove requirement of 2 subtasks
matthias-pichler 57cf769
Merge branch 'main' into matthias-pichler/invalid-do-switch-894
matthias-pichler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,53 @@ | ||
/* | ||
* Copyright 2023-Present The Serverless Workflow Specification Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { SWSchemaValidator } from "./index"; | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import marked from "marked"; | ||
|
||
SWSchemaValidator.prepareSchemas(); | ||
|
||
const dslReferencePath = path.join( | ||
__dirname, | ||
"..", | ||
"..", | ||
"..", | ||
"dsl-reference.md" | ||
); | ||
|
||
describe(`Verify every example in the dsl docs`, () => { | ||
const workflows = marked | ||
.lexer(fs.readFileSync(dslReferencePath, SWSchemaValidator.defaultEncoding)) | ||
.filter((item): item is marked.Tokens.Code => item.type === "code") | ||
.filter((item) => item.lang === "yaml") | ||
.map((item) => item.text) | ||
.map((text) => SWSchemaValidator.yamlToJSON(text)) | ||
.filter((workflow) => typeof workflow === "object") | ||
.filter((workflow) => "document" in workflow) | ||
.filter((workflow) => "dsl" in workflow.document); | ||
|
||
test.each(workflows)("$document.name", (workflow) => { | ||
const results = SWSchemaValidator.validateSchema(workflow); | ||
if (results?.errors) { | ||
console.warn( | ||
`Schema validation on workflow ${workflow.document.name} failed with: `, | ||
JSON.stringify(results.errors, null, 2) | ||
); | ||
} | ||
expect(results?.valid).toBeTruthy(); | ||
}); | ||
}); |
This file contains hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
/* | ||
* Copyright 2023-Present The Serverless Workflow Specification Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { SWSchemaValidator } from "./index"; | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
|
||
SWSchemaValidator.prepareSchemas(); | ||
|
||
const invalidPath = "../test/fixtures/invalid"; | ||
|
||
describe(`Check that invalid workflows are rejected`, () => { | ||
const examples = fs | ||
.readdirSync(path.join(__dirname, invalidPath), { | ||
encoding: SWSchemaValidator.defaultEncoding, | ||
recursive: false, | ||
withFileTypes: true, | ||
}) | ||
.filter((file) => file.isFile()) | ||
.filter((file) => file.name.endsWith(".yaml")) | ||
.map((file) => file.name); | ||
|
||
test.each(examples)("Example %s", (file) => { | ||
const workflow = SWSchemaValidator.loadAsJSON( | ||
path.join(__dirname, `${invalidPath}/${file}`) | ||
); | ||
const results = SWSchemaValidator.validateSchema(workflow); | ||
expect(results?.valid).toBeFalsy(); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
.ci/validation/test/fixtures/invalid/extra-property-in-call.yaml
This file contains hidden or 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,12 @@ | ||
document: | ||
dsl: 1.0.0-alpha1 | ||
namespace: examples | ||
name: two-tasks-in-one-item | ||
version: 1.0.0-alpha1 | ||
do: | ||
- getPet: | ||
call: http | ||
with: | ||
method: get | ||
endpoint: https://petstore.swagger.io/v2/pet/{petId} | ||
foo: bar |
14 changes: 14 additions & 0 deletions
14
.ci/validation/test/fixtures/invalid/two-tasks-in-one-item.yaml
This file contains hidden or 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,14 @@ | ||
document: | ||
dsl: 1.0.0-alpha1 | ||
namespace: examples | ||
name: two-tasks-in-one-item | ||
version: 1.0.0-alpha1 | ||
do: | ||
- getPet: | ||
call: http | ||
with: | ||
method: get | ||
endpoint: https://petstore.swagger.io/v2/pet/{petId} | ||
setMessage: | ||
set: | ||
message: "Looking for {petId}" |
This file contains hidden or 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,31 @@ | ||
Feature: Composite Task | ||
As an implementer of the workflow DSL | ||
I want to ensure that composite tasks can be executed within the workflow | ||
So that my implementation conforms to the expected behavior | ||
|
||
# Tests composite tasks With competing concurrent sub tasks | ||
Scenario: Fork Task With Competing Concurrent Sub Tasks | ||
Given a workflow with definition: | ||
"""yaml | ||
document: | ||
dsl: 1.0.0-alpha1 | ||
namespace: default | ||
name: fork | ||
do: | ||
- branchWithCompete: | ||
fork: | ||
compete: true | ||
branches: | ||
- setRed: | ||
set: | ||
colors: ${ .colors + ["red"] } | ||
- setGreen: | ||
set: | ||
colors: ${ .colors + ["green"] } | ||
- setBlue: | ||
set: | ||
colors: ${ .colors + ["blue"] } | ||
""" | ||
When the workflow is executed | ||
Then the workflow should complete | ||
And the workflow output should have a 'colors' property containing 1 items |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.