Skip to content

[ci] Add GHA workflows to review PRs using Verible #1427

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

Merged
merged 1 commit into from
Sep 16, 2021

Conversation

wsipak
Copy link
Contributor

@wsipak wsipak commented Aug 26, 2021

This PR adds CI scripts that use Verible Lint Action
to automatically review the changes in .v and .sv files.

You can see an example of how this works here:
antmicro/gha-playground#20

In order to post comments, the action needs a proper token.
Due to restrictions described in the docs It's not possible to create comments
in the context of pull_request from an external repository.
To tackle this problem we create two workflows:
The first workflow triggered by pull_request stores information
about the PR in artifact and triggers the main workflow.
The main workflow runs the Action using a token that allows creating review comments in any PR.

We can also add a configuration file for Verible using the config_file input.
Currently the default rule set is used.
These topics are also described in the Readme of the Action.

Copy link
Contributor

@imphil imphil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great, thanks for your work on this! Can you add a couple lines of comments to explain what the two files are doing? Effectively copy-pasting from your PR description here should do the trick.

On configuration: We currently run verible-lint through FuseSoC, which also provides our waiver file(s) and configuration. The configuration is at https://github.com/lowRISC/ibex/blob/master/vendor/lowrisc_ip/lint/tools/veriblelint/rules.vbl. Additionally, there are multiple waivers. As starting point, using the rules would probably be sufficient.

On testing: Is there a way to test this whole setup before enabling it for everybody? E.g. can we push a "known bad" RTL commit to this PR and see how it all works out?

@tgorochowik
Copy link

Thanks for the review!

We will work on adding the things you asked for.

As for testing: I think it would be easiest to do this in a fork - we could push everything that's needed to the main branch and then create PRs for making sure everything works as needed. Would that be ok?

@rswarbrick
Copy link
Contributor

As for testing: I think it would be easiest to do this in a fork - we could push everything that's needed to the main branch and then create PRs for making sure everything works as needed. Would that be ok?

I think @imphil is suggesting you push an extra commit to this PR containing a "bug" that the CI is supposed to catch and flag. Assuming that works, you can force-push to get rid of the extra commit before merging. I think this is probably simpler than what you're suggesting.

@tgorochowik
Copy link

tgorochowik commented Sep 1, 2021

Unfortunately for this to work correctly, parts of the code has to land in the main branch first.

As you can see in the config there are two pipelines added, one that does all the checking (pr_trigger.yml ) and one that posts review comments (pr_lint_review.yml ).

The pr_trigger uploads a json file to artifacts which is then parsed and converted into proper comments.

The reason for this, and the reason for the requirement of the "comment poster" to be merged first is that it needs a GITHUB_TOKEN to have the permissions to post comments. This token is not available in pull requests.

Testing only the first step is possible with the approach you're suggesting, but we will only see the output in the logs (no comments will be added).

Setting it up in a fork might be less convenient but will allow us to test the whole flow without pushing anything to your repository (we did test everything of course in the gha-playground repo mentioned above, but we could replicate it in a fork)

By the way - I think that github actions are disabled in this repository (?) - I think that at least the first step should already be starting here

@imphil
Copy link
Contributor

imphil commented Sep 1, 2021

GitHub Actions are enabled for this repository, but I've seen it in the past that they don't run for the first time if there's a PR from a fork.

I'm OK with just merging this PR and then take it from there, and back it out if it doesn't work. Commit history beauty isn't the most important goal in life. Let us know when you feel it's ready, and then we can simply give it a try.

@wsipak
Copy link
Contributor Author

wsipak commented Sep 1, 2021

Thank you. The requested changes have been applied.
The configuration file is specified here:
https://github.com/antmicro/ibex/blob/verible_ci/.github/workflows/pr_lint_review.yml#L48

Here are the steps I've taken to test this PR:

  1. Recreated and merged the same PR here:
    [ci] Add GHA workflows to review PRs using Verible antmicro/gha-playground#32

  2. Created a new PR adding a source file to trigger the automatic review:
    test new workflows antmicro/gha-playground#33
    Additionally I removed the rules file in order to forcibly get some errors.

I think it's ready!

Any activity regarding a Pull Request will trigger
workflows that create automatic code review
using outputs from Verible linter
Copy link
Contributor

@imphil imphil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, let's give this a try!

@imphil imphil merged commit 31c5b5e into lowRISC:master Sep 16, 2021
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jun 14, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jul 3, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jul 3, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/opentitan that referenced this pull request Jul 3, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
engdoreis pushed a commit to lowRISC/opentitan that referenced this pull request Jul 4, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
dmcardle pushed a commit to dmcardle/opentitan that referenced this pull request Jul 6, 2023
Running the verible linter and adding review comments to the pull request
previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull request
did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which triggers
when pull requests change, but runs in the context of the repo's HEAD and
has the permissions to create comments.

See lowRISC/ibex#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
Signed-off-by: Dan McArdle <[email protected]>
jwnrt added a commit to jwnrt/ibex that referenced this pull request Jul 20, 2023
Running the verible linter and adding review comments to the pull
request previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as
   artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull
request did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which
triggers when pull requests change, but runs in the context of the
repo's HEAD and has the permissions to create comments.

See lowRISC#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/ibex that referenced this pull request Jul 20, 2023
Running the verible linter and adding review comments to the pull
request previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as
   artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull
request did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which
triggers when pull requests change, but runs in the context of the
repo's HEAD and has the permissions to create comments.

See lowRISC#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
jwnrt added a commit to jwnrt/ibex that referenced this pull request Aug 4, 2023
Running the verible linter and adding review comments to the pull
request previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as
   artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull
request did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which
triggers when pull requests change, but runs in the context of the
repo's HEAD and has the permissions to create comments.

See lowRISC#1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Aug 4, 2023
Running the verible linter and adding review comments to the pull
request previously had to be done in two stages:

1. Triggered on the pull request - prepare config and waiver files as
   artifacts.
2. Running on the repo's HEAD - run Verible and add review comments.

This was required because Actions running in the context of the pull
request did not have write permissions to add comments to pull requests.

This is now possible with the `pull_request_target` event, which
triggers when pull requests change, but runs in the context of the
repo's HEAD and has the permissions to create comments.

See #1427 and
chipsalliance/verible-linter-action#31 for details.

Signed-off-by: James Wainwright <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants