diff --git a/README.md b/README.md index fe22012..c6c9e86 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,12 @@ Typically, contributions to the SailPoint OpenAPI specification involve creating sh /path/to/lint.sh ``` +Or use the parallel lint script to greatly speed up the linting process: + +```sh +sh /path/to/lint-parallel.sh +``` + This script uses the git command `git diff --name-only HEAD master` to print the file paths that have changed, and then it loops through each file and applies the appropriate ruleset based on whether the file is a root spec file, path file, or schema file. This script also has the benefit of referencing the rule files directly from this GitHub repository, so it will always apply the latest rules without the user having to download or synchronize any files. ## Understanding the Linter Results diff --git a/lint-parallel.sh b/lint-parallel.sh new file mode 100755 index 0000000..eef32dc --- /dev/null +++ b/lint-parallel.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +lint_file () { + LINTER_URL="https://raw.githubusercontent.com/sailpoint-oss/api-linter/main" + + if echo $1 | grep "sailpoint-api.*" --quiet + then + # Don't ignore unkown format because we want to know if the root API spec is a valid OpenAPI version + spectral lint $1 --ruleset "${LINTER_URL}/root-ruleset.yaml" + fi + + if echo $1 | grep paths --quiet + then + spectral lint $1 --ruleset "${LINTER_URL}/path-ruleset.yaml" --ignore-unknown-format + fi + + if echo $1 | grep schemas --quiet + then + spectral lint $1 --ruleset "${LINTER_URL}/schema-ruleset.yaml" --ignore-unknown-format + fi +} + +export -f lint_file + +git diff --name-only HEAD master | parallel --progress lint_file {}