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

fix: do not update manifest on PRs without stack label #331

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

wontonst
Copy link
Contributor

@wontonst wontonst commented Jan 15, 2025

Attempts to address https://github.com/chanzuckerberg/argus/issues/655 by running Update ArgoCD manifests only if a PR associated with a push has the stack label.

Tested via https://github.com/chanzuckerberg/core-platform-example-app/pull/112 which is on 2.X of this action (hence the merge conflicts).

If we like this approach, what should I do? Maybe create 2.16.0 and 3.7.0? Do we care about supporting 2.X apps? It would be simpler to ask those app owners to use 3.X to gain this benefit. Prior to merging I will rebase on latest and test again on an app using 3.X.

Requires application owners to upgrade their argus-docker-build.yaml version target

  • after merging update the tag of build-prep

with:
filterOutClosed: true
filterOutDraft: false
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/build-prep@rzheng/stack-label
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is our versioning strategy? continue using a sha1? leave it pointing to a branch like this PR? maybe we can create a tag?

Copy link
Contributor

Choose a reason for hiding this comment

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

we use release-please to propose releases based on our conventional commits and merging the release proposal PR creates the actual release/tag. the reason this uses a sha instead of one of those tags is that it allows us to make a single release with the update instead of first releasing build-prep and then coming back and updating the version of build-prep used in this file and making another release

@@ -120,4 +134,5 @@ runs:
script: |
const branchMatched = `${{ steps.branch_filter.outputs.match }}` === 'true';
const filesMatched = `${{ steps.file_filter.outputs.run_on }}` === 'true';
core.setOutput('should_build', filesMatched && branchMatched);
const prHasStackLabel = `${{ steps.require_stack_label.outputs.has_label }}` === 'true';
core.setOutput('should_build', filesMatched && branchMatched && prHasStackLabel);
Copy link
Contributor Author

@wontonst wontonst Jan 15, 2025

Choose a reason for hiding this comment

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

note this also skips Update Manifest in manifest-update.

is that okay or should I modify the manifest-update action to only skip the step that adds the values.yaml change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait that step only writes the values.yml changes so it's safe to skip

Comment on lines 24 to 27
labels:
description: 'Labels attached to an associated PR'
requred: false
default: ''
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to something that indicates these are the labels currently attached to the PR. Then we need another input for the name of the label with the default value being "stack". I think we should allow for the name of the label to be configured, with a sane default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

with:
script: |
const labels = `${{ inputs.labels }}`;
let hasStackLabel = labels.split(',').includes("stack")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let hasStackLabel = labels.split(',').includes("stack")
let hasStackLabel = labels.split(',').includes("{{inputs.label}}")

see comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@wontonst wontonst force-pushed the rzheng/stack-label branch 8 times, most recently from b7a9dca to 280fc38 Compare January 17, 2025 17:50
@wontonst
Copy link
Contributor Author

wontonst commented Jan 17, 2025

PR should be ready for review now.

Todo:

  • Pin argus-builder/build-prep to a commit that is approved by reviewers
  • Bump argus-docker-build version in relevant repos

Side note I noticed that rerunning jobs via the Github UI when a values.yaml commit has been created always results in the manifest update step not getting executed. My guess is because the file filters thinks the base commit is the commit before the values.yaml file commit so it thinks there are no files matching the path filters. I think we can ignore this since most folks are probably pushing to their branch to trigger a build but good to know since I wasted time figuring out why steps were getting skipped.

@wontonst wontonst marked this pull request as ready for review January 17, 2025 18:10
core.setOutput('should_build', filesMatched && branchMatched);
const prHasStackLabel = `${{ steps.require_stack_label.outputs.has_trigger_label }}` === 'true';
const shouldBuild = filesMatched && branchMatched && prHasStackLabel;
core.setOutput('should_build', shouldBuild);
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be good to have the image still get built, the benefits of that would be even without making a stack a user would still be able to see whether their code introduced a bug that prevents the image from building. @jakeyheath what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think given that the main artifact for a build is often times an image, and given the low cost of building an image, we should just always build an image. what do we think about removing should_build from build-docker's if condition?

if: needs.prep.outputs.should_build == 'true' && needs.prep.outputs.images != '[]'

alternatively I can create a new output like shouldDeploy and use that to separately control Update manifest

Copy link
Contributor

Choose a reason for hiding this comment

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

yea that would be more clear @wontonst . Let's go forward with that

description: 'Labels attached to an associated PR'
required: false
default: ''
manifest_trigger_label:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to allow multiple values, comma delimited

We don't have anyone with this setup right now but we've previously had people build a monorepo with multiple Argus apps that use independent labels to control stack creation. We have an example monorepo set up to work like that: https://github.com/chanzuckerberg/argus-example-monorepo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, this could get confusing. some folks might want it to mean "any of these labels should trigger a manifest update" and others "these labels must all be applied to trigger a manifest update"

what do you think about crossing that bridge when we come to it?

Copy link
Contributor

@hspitzley-czi hspitzley-czi Jan 21, 2025

Choose a reason for hiding this comment

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

I'm good with that, alternatively it could take a regex which would make it support the "any of these labels" case. Up to you

with:
filterOutClosed: true
filterOutDraft: false
- uses: chanzuckerberg/github-actions/.github/actions/argus-builder/build-prep@rzheng/stack-label
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget to change this in a follow up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wontonst wontonst force-pushed the rzheng/stack-label branch 2 times, most recently from a0a27c4 to 23a4c16 Compare January 24, 2025 19:20
@wontonst
Copy link
Contributor Author

@wontonst wontonst merged commit 90e3b17 into main Jan 24, 2025
9 checks passed
@wontonst wontonst deleted the rzheng/stack-label branch January 24, 2025 19:42
@czi-github-helper czi-github-helper bot mentioned this pull request Jan 24, 2025
@wontonst
Copy link
Contributor Author

will defer upgrading other repos until https://czi.atlassian.net/browse/CCIE-3947

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