-
Notifications
You must be signed in to change notification settings - Fork 4
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
Avoid repeat installs (#6) #7
Conversation
if [ "$TRIVY_INSTALLED" == "${{ inputs.version }}-${{ inputs.path }}" ]; then | ||
echo "Trivy '${{ inputs.version }}' has already been installed by the current job, skipping reinstalling it again" | ||
echo "installed=true" >> $GITHUB_OUTPUT | ||
else |
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.
Could be an argument for having an elif [ -n "$TRIVY_INSTALLED" ]; then
branch here that generates a warning because if people are installing multiple versions of Trivy in a single job as there's a few pitfalls there:
- Only the first install will be automatically found via the
PATH
as the action always appends to$GITHUB_PATH
- If they don't set the
path
input to different values then one version overwrites the other which may/may not be what the user intended
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.
Hi @rvesse @knqyf263 what do you think about these changes? I'm not sure if this can be useful for more users It looks like if you want these changes, you can use the |
Am I understanding correctly that you are concerned about the overhead when |
So the difference there is that people are directly calling In the case of As described in my issue #6 many users, including my company, are calling the
Note also that this repeated install risks creating a new source of rate limiting errors because now user workflows are querying the GitHub API for releases every time their workflow calls
If I do that then I can't use The only way that approach would work was if you had a |
9029297
to
cdb9d8d
Compare
This commit adds tracking and detection of when the current job has already called setup-trivy (whether directly/indirectly) and avoids repeatedly installing it once it has been installed
cdb9d8d
to
5b3d6a1
Compare
It's only restored from the cache if users are using a fixed version, if they are using Yes installing it is generally fast but that's still not a justification to install it multiple times unnecessarily:
|
hm... that makes sense. It will add flexibility for users:
|
@DmitriyLewen Ok, |
The version is pinned by default, right? So, we can just add a caveat that using |
Superseded by aquasecurity/trivy-action#414 |
This commit adds tracking and detection of when the current job has already called setup-trivy (whether directly/indirectly) and avoids repeatedly installing it once it has been installed
This is my proposed fix for #6, basically the action now does the following:
TRIVY_INSTALLED
environment variable when it finishes installation which contains theversion
andpath
from the action inputs.false
Example workflow with the fix in place:
This is from my debugging repository (rvesse/setup-trivy-debugging) and you can see the full output at https://github.com/rvesse/setup-trivy-debugging/actions/runs/11325497781/job/31492526052