Skip to content
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

chore: refactor the github actions has-secrets logic #26795

Closed
wants to merge 26 commits into from

Conversation

mistercrunch
Copy link
Member

[reopening] While working on #26772, I realized that the has-secret logic was broken for unclear reasons. Now after doing this fix, I looked and realized that there's similar logic across about a dozen other gh actions, and thought it'd be a good thing to refactor/fix this with a reusable action.

Now many of these workflows are set to trigger on push-on-master only meaning it's less of an issue since a false positive on has-secret dpesn't matter in that context since there's always a secret.

I still thought I should refactor this to something we can trust and build upon.

The solution introduces this new simple reusable action.

One minor note is in cases where we need multiple secrets, as in say DOCKERHUB_TOKEN and DOCKERHUB_USER, we simply look at one and assume that's clear-enough of an indicator.

@rusackas
Copy link
Member

One minor note is in cases where we need multiple secrets, as in say DOCKERHUB_TOKEN and DOCKERHUB_USER, we simply look at one and assume that's clear-enough of an indicator.

This part worries me a bit. Each key is set separately by Apache Infra, and sometimes they are (or soon will be) secrets for disparate systems (e.g. Google, Github, OpenAI, etc). I don't think it's safe to assume that if one secret exists that the others are all good... it would be best to pass an array of secrets, and have them all validated by the shared action.

@rusackas
Copy link
Member

rusackas commented Jan 25, 2024

Just to make sure I'm understanding, is this fixing the issue wherein the docker-build is currently being skipped (seemingly due to #26772)? If so, I'm down to revert that one if this one needs more discussion/eyes.

needs: config
if: needs.config.outputs.has-secrets
needs: check-secrets
if: needs.check-secrets.outputs.has-secrets == 'true'
Copy link
Member

Choose a reason for hiding this comment

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

Not totally related with this PR, but I think it only makes sense to build and push to a local file on the workspace workflow while the PR is open, so this means we are supposed to not have secrets here. the ephemeral-env workflow is expecting the build dir

needs: config
if: needs.config.outputs.has-secrets == 'true'
needs: check-secrets
if: needs.check-secrets.outputs.has-secrets == 'true'
Copy link
Member

@dpgaspar dpgaspar Jan 25, 2024

Choose a reason for hiding this comment

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

should we always build images on PRs? like we were doing before? docker_build_push.sh will only push if DOCKERHUB_USER is present

also this is kind of tricky to test, except opening a similar PR directly to the repo

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's right, more work to do here

Copy link
Member Author

Choose a reason for hiding this comment

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

About both your comments, I think I figured it out in #26801, where we always run docker, but in forks it runs without authentication, which means it builds an DOESNT push, just making sure that docker build works.

Now I was also able to improve caching there, where in forks, it's use the registry cache as input, but it cannot push the cache and won't. Unclear what the cache hit rate will be, but should be pretty good unless the PR touches dependencies. Also if you don't touch the frontend there's a lot savings on docker build time.

As docker cache can be really good if done well, it could be tempting to eventually run tests in-docker, and saving a lot on build times.

While working on #26772, I
realized that the has-secret logic was broken for unclear reasons. Now
after doing this fix, I looked and realized that there's similar logic
across about a dozen other gh actions, and thought it'd be a good thing
to refactor/fix this with a reusable action.

Now many of these workflows are set to trigger on push-on-master only
meaning it's less of an issue since a false positive on has-secret
dpesn't matter in that context since there's always a secret.

I still thought I should refactor this to something we can trust and
build upon.

The solution introduces this new simple reusable action.

One minor note is in cases where we need multiple secrets, as in say
DOCKERHUB_TOKEN and DOCKERHUB_USER, we simply look at one and assume
that's clear-enough of an indicator.
@mistercrunch mistercrunch force-pushed the has_secrets branch 2 times, most recently from 315f4b3 to d524461 Compare January 25, 2024 21:44
@mistercrunch
Copy link
Member Author

Frustrated head-butting with GitHub reusable actions not working as expected. Tried a million things and couldn't make the output value work. Closing for now

@mistercrunch mistercrunch deleted the has_secrets branch May 16, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants