Skip to content

Conversation

shimoncohen
Copy link
Contributor

No description provided.

@shimoncohen shimoncohen self-assigned this Aug 5, 2025
Copy link
Contributor

github-actions bot commented Aug 5, 2025

🎫 Related Jira Issue: MAPCO-8106

Copy link
Contributor

github-actions bot commented Aug 5, 2025

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 96.36% (🎯 80%) 556 / 577
🟢 Statements 96.36% (🎯 80%) 556 / 577
🟢 Functions 100% (🎯 80%) 26 / 26
🟢 Branches 91.89% (🎯 80%) 136 / 148
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
actions/update-chart-dependency/main.ts 93.47% 82.6% 100% 93.47% 139-152, 387-388, 483-484, 519-521
Generated in workflow #89 for commit 28bad09 by the Vitest Coverage Report Action

@shimoncohen shimoncohen requested a review from syncush August 11, 2025 11:33
| Name | Description | Required | Default |
| -------------- | -------------------------------------------------------------------------------------------------------- | -------- | -------- |
| `service-name` | Name of the dependency to update in Chart.yaml/helmfile.yaml. | true | |
| `version` | New version to set for the dependency. | true | |
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this mandatory? shouldnt it run on tag push?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but the version is mandatory because it needs to be supplied to the action, otherwise we won't know what's the new version (you still need to pass it).

Copy link
Collaborator

Choose a reason for hiding this comment

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

you can just take the current version of the chart when you run as the default. this action wil run after a version bump anyway.

Comment on lines 92 to 99
[CHART_FILE_NAME, HELMFILE_NAME].forEach((name) => {
['yaml', 'yml'].forEach((ext) => {
const file = path.join(workspace, chartDir, `${name}.${ext}`);
if (fs.existsSync(file)) {
files.push(file);
}
});
});
Copy link
Collaborator

@CptSchnitz CptSchnitz Aug 12, 2025

Choose a reason for hiding this comment

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

consider using Iterators for better readability and more functional approach:

const files = Iterator.from([CHART_FILE_NAME, HELMFILE_NAME])
  .flatMap(name => 
    ['yaml', 'yml'].map(ext => path.join(workspace, chartDir, `${name}.${ext}`))
  )
  .filter(file => fs.existsSync(file))
  .toArray();```

Or at least flatmap instead of nested forEach.
```js
const files = [CHART_FILE_NAME, HELMFILE_NAME]
  .flatMap(name => 
    ['yaml', 'yml'].map(ext => path.join(workspace, chartDir, `${name}.${ext}`))
  )
  .filter(file => fs.existsSync(file));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

} catch {
return { updated: false };
}
if (Array.isArray(chart.dependencies)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you didnt handle the case that dependencies is not defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added handle and tests.


vi.mock('@actions/core');
vi.mock('@actions/github');
vi.mock('fs');
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use memfs to mock the filesystem and have better tests

@shimoncohen shimoncohen requested a review from Copilot August 21, 2025 09:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a new GitHub Action for automatically updating Helm chart dependencies. The action scans chart directories for Chart.yaml and helmfile.yaml files, updates dependency versions, and creates pull requests with the changes.

Key changes include:

  • New update-chart-dependency action with comprehensive input validation using Zod schema
  • Support for both Chart.yaml and helmfile.yaml dependency updates with recursive directory scanning
  • Automated PR creation with detailed commit messages and descriptions including old/new version tracking

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
release-please-config.json Adds release configuration for the new update-chart-dependency action
package.json Adds zod dependency for input validation
actions/update-chart-dependency/main.ts Core implementation with YAML parsing, GitHub API integration, and dependency update logic
actions/update-chart-dependency/tests/update-chart-dependency.spec.ts Comprehensive test suite covering all functionality including edge cases
actions/update-chart-dependency/index.ts Entry point that executes the main action
actions/update-chart-dependency/action.yaml GitHub Action metadata and input definitions
actions/update-chart-dependency/README.md Documentation with usage examples and feature descriptions
README.md Updates main repository documentation to include the new action

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@netanelC netanelC left a comment

Choose a reason for hiding this comment

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

Export the logic in run function to another functions for better readability.
I think it will be better to build the main logic this way:

  1. Iterate over the target repo
  2. If a Chart.yaml or helmfile.yaml contains the chart name:
    2.1. Create new branch (if the file already has the new version, warn since this shouldn't happen)
    2.2. Update file with new version
    2.3. Create Pull Request

No need to iterate twice and the update of the version should happen once after you created the branch

await downloadRepoDir(octokit, owner, repo, branch, '', tempDir);

// Collect all chart / helmfile files to process
const chartFilesWithDirs = getChartFilesWithDirs(tempDir);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why getting all the charts? You can filter on the first iteration instead of fetching all the charts and then filter

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 can't do this without reading all of them, this will complicate the logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

It shouldn't

await downloadRepoDir(octokit, owner, repo, branch, '', tempDir);

// Collect all chart / helmfile files to process
const chartFilesWithDirs = getChartFilesWithDirs(tempDir);
Copy link
Contributor

Choose a reason for hiding this comment

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

It shouldn't

Copy link
Contributor

@netanelC netanelC left a comment

Choose a reason for hiding this comment

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

Refer to Ofer comments

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.

4 participants