-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Github Action to check deprecations in PR #19666
Conversation
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 will be really useful to have! Thanks for implementing it. I have a few small suggestions.
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.
Thanks for doing this @akshya96 it's good. I added a few comments and suggestions which hopefully help. 😄
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.
Nice work Akshya! I tagged in Kuba and Marc just for a sanity check.
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.
The issues I pointed out aren't serious, but would help streamline the workflow file.
I only skimmed the bash script quickly so that I could focus on the GitHub workflow file.
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 # by default the checkout action doesn't checkout all branches |
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.
fetch-depth: 0
means getting the complete repository history. Is that necessary for this job? Alternatively, removing the fetch-depth parameter will result of a depth of 1.
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 think we need fetch-depth: 0 as we check the deprecations on changes when compared to origin/main branch. When I remove this, I get "fatal: Not a valid object name origin/main" and it shows all the deprecations in the code. Basically we need the origin/main branch to get the diff in the current branch.
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.
Looks great, thanks Akshya!
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.
Looks good! I added a couple of additional suggestions, but I don't think they're blockers to merging.
https://hashicorp.atlassian.net/browse/VAULT-8439
Recommendation:
This PR uses the
staticcheck
cmdline tool to identify the use of deprecated functions.This was initially attempted with
golangci-lint
tool withstaticcheck
. It produced inconsistent results, and there are many related issues on GitHub. Furthermore, the author ofstaticcheck
is unaware of its inclusion ingolangci-lint
. Therefore, I used thestaticcheck
tool as it is more reliable.The recommendation in the ticket was to create a GitHub action that includes an allowlist for certain findings, but this would prevent us from identifying if deprecated functions are utilized in new code.
To address this issue, the check runs on all files included in the PR.
staticcheck
runs at package level, so we need to grep the details for the changes that are included in the PR and display it. It usesrevgrep
to do this.To check deprecations locally using the script, follow these steps:
./scipts/deprecations-checker.sh <optional branch name to compare with>
on vault/vault-enterprise repository path or any package pathFor example:
./scripts/deprecations-checker.sh main
./scripts/deprecations-checker.sh
(Running this from vault repo path)
If no branch name is specified, the command will show all the deprecations in the code.
GHA runs this wrt the PR's base ref branch.
This will be added to developer documentation after this PR is approved. Also, this is not a required check.