Skip to content

Commit

Permalink
Merge pull request #2 from sailpoint-oss/parallel-lint
Browse files Browse the repository at this point in the history
Added a parallel version of lint to speed things up
  • Loading branch information
colin-mckibben-sp authored Oct 23, 2023
2 parents 34c0603 + c36380e commit 48eb4bc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions lint-parallel.sh
Original file line number Diff line number Diff line change
@@ -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 {}

0 comments on commit 48eb4bc

Please sign in to comment.