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

feat: Trigger warning for PRs likely requiring updates to management-plane-charts #2219

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

medmes
Copy link
Member

@medmes medmes commented Jan 30, 2025

Description

This PR introduce a Github wokflow for detecting changes on the config directory which needs to be reflected into management-plane-chart repository.

Changes proposed in this pull request:

  • Github Workflow.

The PR was tested against this Upsttream PR in order to bypass permission complexity:

#2223

For the PR merger
After the Pull request is merged. Please delete the trigger_warning_job_on_pr branch from the upstream.

Related issue(s)
#2089

@medmes medmes requested a review from a team as a code owner January 30, 2025 09:28
@kyma-bot kyma-bot added cla: yes Indicates the PR's author has signed the CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 30, 2025
@medmes medmes changed the title Trigger warning for PRs likely requiring updates to management-plane-charts feat: Trigger warning for PRs likely requiring updates to management-plane-charts Jan 30, 2025
@kyma-bot kyma-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 30, 2025
@kyma-bot kyma-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 30, 2025
@kyma-bot kyma-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 30, 2025
@kyma-bot kyma-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 30, 2025
@kyma-bot kyma-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 30, 2025
@medmes medmes linked an issue Jan 30, 2025 that may be closed by this pull request
2 tasks
Copy link
Contributor

@c-pius c-pius left a comment

Choose a reason for hiding this comment

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

Overall looks good, just some general suggestions:

  • I think I would split this into two workflows, one verifying that manifests are up to date, one checking if there are relevant changes
  • regarding the config changes, I think it would be more robust if we work on the actual output based on the configuration
    • so instead of checking if there are changes on the config files, I would suggest that we generate the KLM manifests from PR and main and compare if there are changes
    • we already did this in an earlier implementation that can be used as a base again: chore: Verify diff in manifests #1358
  • the previous point will cover the configuration part, but the ticket also says that the e2e test files are relevant. Here I don't think that we have output to work on, so an approach where we just look if there is a diff in the files should be sufficient. The GH actions and scripts part should be the most relevant. Also, on top level the scripts/tests part should be included in the check.
  • I personally prefer consistency in approaches whenever possible. Here, we have multiple cases where we share info between different steps. First, we use the outputs of the previous steps, later, we use env variables. I would suggest to consistently use outputs in this case.

@c-pius c-pius assigned medmes and unassigned c-pius and medmes Jan 31, 2025

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
Copy link
Contributor

Choose a reason for hiding this comment

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

Labeled and unlabeled were needed on the previous approach but not here. Let's remove them. And since opened, synchronize and reopened are the default types, I think we should omit it entirely.


on:
pull_request:
types: [opened, synchronize, reopened]
Copy link
Contributor

Choose a reason for hiding this comment

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

See above, I would remove the default types

Comment on lines +16 to +19
- name: Install Dependencies
run: |
sudo apt update
sudo apt install -y make
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure we need to install it explicitly? https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#installed-apt-packages

Also looks like we are not even using make in this action? Is it a leftover from testing?

Comment on lines +21 to +32
- name: Get list of changed files
id: changed-files
uses: actions/github-script@v7
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const configFiles = files.filter(file => file.filename.startsWith('config/'));
core.setOutput('configFiles', configFiles.map(file => file.filename).join(','));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is still targeting the config/ folder. These are the sources for generating the manifest output via make dry-run-control-plane. As we already check the output in the other action, I don't think it makes sense to check the sources here. Eventually, we only care about the output, not the sources.

So this one should be replaced with the other files that we care about, but don't have an output. These are:

  • .github/actions (if we change an action, we should make sure it still works in the other repos where we import these)
  • .github/workflows (if we change a workflow, we should check whether we also need to change the same in management-plane-charts)
  • ./tests/scripts (those are used by the actions, so again we should check if it still works in the other repos)
  • versions.yaml (we should check if our tooling version changes still work in the other repos)

The workflow then also needs to be renamed. Maybe something like "check-pipeline-changes`

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of this workflow looks good. Maybe update the descriptions to be more general and not only about /config files

Comment on lines +83 to +99
- name: Add PR Comment if Manifests Are Outdated
if: steps.compare-manifests.outputs.outdated_manifests == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "❌ **Detected diff in manifests!** Run 'make manifests' and commit changes."
});
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["outdated-manifests"]
});
Copy link
Contributor

@c-pius c-pius Feb 4, 2025

Choose a reason for hiding this comment

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

The check above (compare-manifests) doesn't determine if the manifests are "outdated". It determines if there is a diff between main and PR which may be an intended thing. Please adjust the descriptions and variable names accordingly.

owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "❌ **Detected diff in manifests!** Run 'make manifests' and commit changes."
Copy link
Contributor

Choose a reason for hiding this comment

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

This is also not entirely true anymore. See my other comment for this block. I would propose that we ignore the make manifests case for now and add that with a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indicates the PR's author has signed the CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trigger warning for PRs likely requiring updates to management-plane-charts
3 participants