Skip to content

Conversation

eduardo-getpassport
Copy link

@eduardo-getpassport eduardo-getpassport commented Nov 15, 2022

What's on this PR

  • Changes on pr-change-set.yaml:
    • Added step to download the vulnerabilities artifact from build step and post a comment with the output.
  • Changes on build.yaml:
    • Added continue-on-error: true in Audit installed packages step . In case of an audit error, the next step will run
    • Added the id audit-packages in Audit installed packages step. This is to reference this step in the later one.
    • Changed the run command to export the output.
    • Upload the output artifact
  • Updated .gitignore with vulnerabilities file to avoid issues.

What Comment vulnerabilities on PR step does:

Takes the file generated in the previous step in case of an error and posts the content inside the PR.

Example:

Screen Shot 2022-11-03 at 13 21 04

@jenstroeger jenstroeger changed the base branch from main to staging November 15, 2022 22:27
@jenstroeger jenstroeger requested review from behnazh and jenstroeger and removed request for behnazh November 15, 2022 22:27
jenstroeger
jenstroeger previously approved these changes Nov 15, 2022
Copy link
Owner

@jenstroeger jenstroeger 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 to me, thank you @eduardo-getpassport! I have only three minor notes below that you can ignore if you’d like 😉

path: .
if-no-files-found: error
retention-days: 1
if: steps.audit-packages.outputs.exit_code == 1
Copy link
Owner

Choose a reason for hiding this comment

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

I wonder if steps.audit-packages.conclusion == 'failure' is more reliable because any non-zero exit code is considered a failure (and we check only for 1*)?

—————
* At first glance, 1 seems to be the only exit code that pip-audit returns.

@jenstroeger
Copy link
Owner

@behnazh I’m actually surprised that referencing workflow steps works across different workflows (src) 🤔 I wasn’t able to find that documented, so hopefully that handy feature isn’t a bug.

For example, in pr-change-set.yaml we have:

if: steps.audit-packages.outputs.exit_code == 1

which references the audit-packages step in the reusable workflow build.yaml

behnazh
behnazh previously approved these changes Nov 16, 2022
Copy link
Collaborator

@behnazh behnazh left a comment

Choose a reason for hiding this comment

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

Thanks, looks great! But the pipelines are failing. I think the problem is storing the result file at the root directory, which flit is not tracking and therefore it complains. You can either store it at dist/ or /tmp?

@behnazh
Copy link
Collaborator

behnazh commented Nov 16, 2022

@behnazh I’m actually surprised that referencing workflow steps works across different workflows (src) thinking I wasn’t able to find that documented, so hopefully that handy feature isn’t a bug.

Good point. I had missed it. Actually I doubt it works and will probably fail at runtime.

@eduardo-getpassport have you tested these workflows?

@eduardo-getpassport
Copy link
Author

eduardo-getpassport commented Nov 16, 2022

@behnazh I’m actually surprised that referencing workflow steps works across different workflows (src) thinking I wasn’t able to find that documented, so hopefully that handy feature isn’t a bug.

Good point. I had missed it. Actually I doubt it works and will probably fail at runtime.

@eduardo-getpassport have you tested these workflows?

Yes! I just tested again.

I commented on the if: steps.audit-packages.outputs.exit_code == 1 from build and let the two others in the PR file and work as expected (didn't skip the post artifact on the build and skipped in the PR file).

After that I commenter the PR ones and works. I think since we are using the needs: build, the step can take the ID from another workflow.

This is the first run with only the build commented: Link

The second run with the if commented in both files: Link

PS: Only on my runs, I commented the Mac and Windows jobs since we are expensive 😱

@eduardo-getpassport
Copy link
Author

Thanks, looks great! But the pipelines are failing. I think the problem is storing the result file at the root directory, which flit is not tracking and therefore it complains. You can either store it at dist/ or /tmp?

Fixed on separate branch, pushing the changes rn

@behnazh
Copy link
Collaborator

behnazh commented Nov 21, 2022

Yes! I just tested again.

I commented on the if: steps.audit-packages.outputs.exit_code == 1 from build and let the two others in the PR file and work as expected (didn't skip the post artifact on the build and skipped in the PR file).

After that I commenter the PR ones and works. I think since we are using the needs: build, the step can take the ID from another workflow.

@eduardo-getpassport I'm trying to debug this. The outputs.exit_code is not defined anywhere in build.yaml and I can't find any documentation for it. Why are you using this variable? When I run echo ${{ steps.audit-packages.outputs.exit_code }} it's empty.

@behnazh behnazh dismissed stale reviews from jenstroeger and themself via 0ad2fd3 January 10, 2023 12:37
@jenstroeger
Copy link
Owner

With PR #551 in mind I wonder if it would make sense to post an informative message on a PR if package auditing is disabled?

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.

3 participants