github check created after loading ruleset #643
Merged
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.
Motivation and Context
Fix regression of this: https://github.com/stoplightio/spectral-action/issues/506
Github check Lint(push) remains in progress until it times out.
#640
Description
Lint(push) would get stuck if there was an error thrown in createSpectral(), more specifically getRuleset().
If there were no rulesets found in the repo, an error was thrown in getRuleset() but that didn't cause the Lint(push) check to fail. Instead the check would hang because it wasn't able to continue to the next step (updateGithubCheck()).
I changed the github check to be created after finding and loading a ruleset. If there were any errors thrown in that process, the github check never gets created. If there is a valid ruleset, the check is created and the linting happens as usual.
If there is an error thrown while loading the ruleset, the Run Spectral actions fails with the correct error message.
How Has This Been Tested?
I tested this on a private repo and followed the testing steps in #506. I've tested it with no rulesets in the repo, a ruleset that would return an error after linting, and a ruleset that returned a warning after linting.
All had expected behaviors of failing/succeeding when supposed to (and never hanging).
Screenshot(s)/recordings(s)
What happens now when an error is thrown while loading the Spectral ruleset:
Types of changes
Checklist