From d4470ad2465ce118a3f6ebc102b328b5c4552932 Mon Sep 17 00:00:00 2001 From: colin-mckibben-sp Date: Mon, 7 Mar 2022 14:34:43 -0500 Subject: [PATCH 1/3] Added a parallel version of lint to speed things up --- lint-parallel.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 lint-parallel.sh diff --git a/lint-parallel.sh b/lint-parallel.sh new file mode 100755 index 0000000..6ff8f56 --- /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 + +find . -type f | grep -v "legacy\|DS_Store" | parallel --progress lint_file {} From 51432a9f055e52b7d4eb696263fe3d738ffda3b1 Mon Sep 17 00:00:00 2001 From: colin-mckibben-sp Date: Mon, 7 Mar 2022 14:40:21 -0500 Subject: [PATCH 2/3] Added the git diff command to find the changed files --- lint-parallel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lint-parallel.sh b/lint-parallel.sh index 6ff8f56..eef32dc 100755 --- a/lint-parallel.sh +++ b/lint-parallel.sh @@ -22,4 +22,4 @@ lint_file () { export -f lint_file -find . -type f | grep -v "legacy\|DS_Store" | parallel --progress lint_file {} +git diff --name-only HEAD master | parallel --progress lint_file {} From c36380e8ee5818588638b317f81d1589d07cc100 Mon Sep 17 00:00:00 2001 From: Colin McKibben Date: Mon, 23 Oct 2023 09:41:49 -0400 Subject: [PATCH 3/3] Added lint parallel command to the readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) 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