-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: custom rulesets #129
Conversation
We love spectral and the action. It is a bit noisy on our side and we would like to disable some checks. It seems that we could only do that through custom rulesets so we're very eager to see progress on this PR. Is it blocked by something hard? I could help if needed. |
@rubenfiszel hey, I would love to have this feature too. It's been "coming soon" for a while, but it's the very next task that my team works on. This PR will be picked up by a team mate and should be done... well soon. This whole pandemic is messing with everyones predictions of time so no promises, but it is next. |
Got it, thanks for the update and the awesome action! |
@philsturgeon Started to work on this |
783e876
to
432d0f9
Compare
@philsturgeon I've got something that starts to work... cf. https://github.com/stoplightio/spectral-action/pull/129/checks The workflow that runs on every push/pull request now use a custom ruleset with exceptions (which are honored). @XVincentX @P0lip Would you please take a peek at this proposal? |
@XVincentX @P0lip The docker build spits an insane amount of warnings: And I'm not sure how to fix them... :-/ Help? 🙏 |
45d8328
to
66b7178
Compare
@philsturgeon @XVincentX So I've created a dedicated repo (https://github.com/stoplightio/spectral-action-example/) to test the process out from a consumer standpoint. Looks like I still need to iron out some things... |
0655244
to
1faed38
Compare
@philsturgeon @XVincentX @P0lip I think I'm done.
Some pre-existing issues are still there:
|
@philsturgeon https://github.com/stoplightio/spectral-action-example/pull/1/files is now properly decorated. However, you'll notice that Annotations seem to be hooked to the last line of the offending code block... The annotation is correctly created (from the GH api standpoint), but the resulting UI is causing me violent mixed feelings. Thoughts? |
20721b3
to
8b2b579
Compare
@rubenfiszel If you'd like to get an early peek and participate in the review from a user standpoint, that would be amazing and your feedback would be very welcome! https://github.com/stoplightio/spectral-action-example/pull/1/files shows how to reference the action from this very branch. Would you be willing to give it a try, beware that this branch is going to be short lived. So, don't merge any reference to it. It'd be safer to keep the changes in a opened PR on your side until it's reviewed, fixed, merged and officially released. |
I'll try to check out this later today! |
@nulltoken Tried on our repo. It works as expected. Thank you very much! |
@@ -0,0 +1,5 @@ | |||
{ | |||
// See https://go.microsoft.com/fwlink/?LinkId=827846 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this file in the repository?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XVincentX This will pop up a dialog driving the user to install the editorconfig
extension to try and keep the style clean by automatically applying fixups on save (trimming trailing whitespaces, ...). Of course, that will only work with vscode.
cf. https://code.visualstudio.com/docs/editor/extension-gallery#_workspace-recommended-extensions
If you don't think that adds any value, I'll drop it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am aware of the feature. I have always been against IDE specific files in the repository, but I do not mind if you want to keep it here.
I would personally remove it.
info(`Done linting '${v.path}'`); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really worth to add logging here? It's a side effect and it should be encapsulated in an IO
.
It would better to use a Writer or simply hold off on logging here
src/spectral.ts
Outdated
@@ -11,11 +13,28 @@ import { | |||
isOpenApiv3, | |||
} from '@stoplight/spectral'; | |||
|
|||
import * as SpectralPackage from '../node_modules/@stoplight/spectral/package.json'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cannot be statically imported, because this might not exist. You need to replace this with an IOEither
with a require call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XVincentX I've tried to apply your hints (Not that they were unclear, but rather because I'm not really used to fp-ts
. Hence "tried").
Could you please check that I've correctly understood the requirements?
src/spectral.ts
Outdated
if (rulesetPath.length !== 0) { | ||
info(`Loading ruleset '${rulesetPath}'...`); | ||
normRuleSet = [rulesetPath]; | ||
} else { | ||
info(`Loading built-in rulesets...`); | ||
normRuleSet = undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this with an expression so that normRuleSet is constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XVincentX Fixed. Do you like it better?
0dcb3ec
to
ba5a777
Compare
@XVincentX I believe I've fixed all your comments. Could you please take another peek? |
ba5a777
to
13042a4
Compare
Please do not do this, it makes reviewing the follow up commits almost impossible and it's forcing the to re-review the whole PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't approve this, but it would be good to get @XVincentX to take one last look anyway. I'll leave it with you two!
@nulltoken btw can you push a v2 tag when this is done? We don't have semantic release set up or anything like that. |
const retrieveSpectralPackageVersion = (): IOEither.IOEither<Error, string> => | ||
IOEither.tryCatch<Error, string>(() => { | ||
const x = require('../node_modules/@stoplight/spectral/package.json'); | ||
return String(x.version); | ||
}, E.toError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need to make a function of this
const retrieveSpectralPackageVersion = (): IOEither.IOEither<Error, string> => | |
IOEither.tryCatch<Error, string>(() => { | |
const x = require('../node_modules/@stoplight/spectral/package.json'); | |
return String(x.version); | |
}, E.toError); | |
const retrieveSpectralPackageVersion = | |
IOEither.tryCatch<Error, string>(() => { | |
const x = require('../node_modules/@stoplight/spectral/package.json'); | |
return String(x.version); | |
}, E.toError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XVincentX Duh. I now realize I didn't take this into account. Sorry :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will probably jump on this integration and clean up some stuff, but for now this is good to go.
@XVincentX It's in. Thanks a lot for your patience and your feedback! I definitely need to feel more at easy with fp-ts. |
@XVincentX Thanks. I'll read your changes to learn from them. Once you're done, could you please take care of the tagging (as requested by @philsturgeon above)? |
Work with custom rulesets in Spectral v5.0.