-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13f3cf8
commit 979c666
Showing
14 changed files
with
171 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
branches: [ main ] | ||
|
||
jobs: | ||
build-and-test-valid-example: | ||
build-and-test-valid-examples: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
|
@@ -22,10 +22,13 @@ jobs: | |
- name: Install poltergust | ||
run: npm ci | ||
|
||
- name: Test the valid example ruleset | ||
run: npx poltergust ./examples/valid | ||
- name: Run the simple example | ||
run: npx poltergust ./examples/simple | ||
|
||
- name: Commit updated valid ruleset | ||
- name: Run the complex example | ||
run: npx poltergust ./examples/complex | ||
|
||
- name: Commit aggregated rulesets | ||
run: | | ||
git config --global user.name '👻poltergust' | ||
git config --global user.email '[email protected]' | ||
|
@@ -34,7 +37,7 @@ jobs: | |
build-and-test-invalid-example: | ||
needs: build-and-test-valid-example | ||
needs: build-and-test-valid-examples | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
@@ -47,6 +50,6 @@ jobs: | |
- name: Install poltergust | ||
run: npm ci | ||
|
||
- name: Test the invalid example ruleset (should exit 1) | ||
- name: Run the invalid example (should exit 1) | ||
run: npx poltergust ./examples/invalid || (exitcode=$?; [ $exitcode -eq 1 ] || exit $exitcode) | ||
shell: bash |
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,36 @@ | ||
# Complex example | ||
|
||
* This example contains rules accross several markdown files: [rules1.md](rules1.md) and [rules2.md](rules2.md) and even subdirectories [subdirectory/subrules.md](subdirectory/subrules.md) | ||
* ✅ All the test declared in those files are expected to pass | ||
* Some of the rules use custom functions defined in the [functions](functions) directory | ||
* [spectral.base.yaml](spectral.base.yaml) contains the base rule files that will be used to merge the rules into. For example, it contains the extends, aliases and functions declarations | ||
* [spectral.yaml](spectral.yaml) is the output of the merge operation: [spectral.base.yaml](spectral.base.yaml) + all the rules found in [rules1.md](rules1.md) and [rules2.md](rules2.md) | ||
|
||
## Test ouput | ||
|
||
``` | ||
npx poltergust .\examples\simple | ||
🔎 Testing the spectral rules from the .md files in the directory: .\examples\simple | ||
👻 operation-parameters-must-have-description (examples\simple\README.md:6) | ||
✅ Test OK (examples\simple\README.md:18) | ||
✅ Spectral rules merged in the file: examples\simple\spectral.yaml | ||
PS C:\Users\jb.muscat\sources\GitHub\api-guidelines> npx poltergust .\examples\complex | ||
🔎 Testing the spectral rules from the .md files in the directory: .\examples\complex | ||
👻 base-path-must-start-with-slash (examples\complex\rules1.md:39) | ||
✅ Test OK (examples\complex\rules1.md:16) | ||
✅ Test OK (examples\complex\rules1.md:26) | ||
👻 operation-parameters-must-have-description (examples\complex\rules1.md:90) | ||
✅ Test OK (examples\complex\rules1.md:57) | ||
✅ Test OK (examples\complex\rules1.md:72) | ||
👻 operation-must-have-description (examples\complex\rules1.md:106) | ||
👻 operation-must-have-no-summary (examples\complex\rules1.md:121) | ||
👻 operation-must-have-at-least-one-response (examples\complex\rules1.md:134) | ||
👻 path-parameters-must-be-kebab-case (examples\complex\rules2.md:49) | ||
✅ Test OK (examples\complex\rules2.md:11) | ||
👻 required-property-must-exist (examples\complex\rules2.md:96) | ||
✅ Test OK (examples\complex\rules2.md:66) | ||
👻 request-bodies-must-have-a-content (examples\complex\subdirectory\subrules.md:41) | ||
✅ Test OK (examples\complex\subdirectory\subrules.md:8) | ||
✅ Test OK (examples\complex\subdirectory\subrules.md:25) | ||
✅ Spectral rules merged in the file: examples\complex\spectral.yaml | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,30 @@ | ||
# Simple example | ||
|
||
1. This is a Spectral rule: | ||
|
||
```yaml | ||
#👻-rule | ||
operation-parameters-must-have-description: | ||
description: Operation parameters must have a description | ||
given: $.paths[*][*].parameters[*] | ||
severity: error | ||
then: | ||
field: description | ||
function: truthy | ||
``` | ||
2. This is a test case for this rule: | ||
```yaml | ||
#👻-failures: 1 operation-parameters-must-have-description | ||
openapi: 3.0.1 | ||
paths: | ||
/test/{id}: | ||
get: | ||
parameters: | ||
# the 'id' parameter needs a description | ||
- name: id #👻-fails-here: operation-parameters-must-have-description | ||
in: path | ||
required: true | ||
schema: | ||
type: string | ||
``` |
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,3 @@ | ||
formats: ["oas3"] | ||
rules: | ||
#rules will be injected by poltergust |
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,11 @@ | ||
formats: ["oas3"] | ||
rules: | ||
#rules will be injected by poltergust | ||
operation-parameters-must-have-description: | ||
description: Operation parameters must have a description | ||
given: $.paths[*][*].parameters[*] | ||
severity: error | ||
then: | ||
field: description | ||
function: truthy | ||
|
This file was deleted.
Oops, something went wrong.