Add overwrite input to optionally allow copying over existing dependency files from non-root directories#1149
Closed
aparnajyothi-y wants to merge 5 commits intoactions:mainfrom
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds an optional overwrite flag to control whether existing dependency files are overwritten when copying cache dependencies from composite actions. Key changes:
- Introduce
overwriteboolean input in action.yml and docs. - Update
cacheDependenciesto check for target file existence and skip or overwrite based on flag. - Add tests covering overwrite, skip, and error scenarios.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/setup-python.ts | Added overwrite input handling, checking file existence, and conditional copy/overwrite logic |
| docs/advanced-usage.md | Updated advanced usage docs to describe new overwrite input behavior |
| action.yml | Declared new overwrite input with default false |
| tests/setup-python.test.ts | Expanded test suite to cover overwrite, skip, and error conditions |
Comments suppressed due to low confidence (5)
docs/advanced-usage.md:417
- [nitpick] Wrap
overwrite,cache-dependency-path, andoverwrite: truein backticks to clearly denote input names and code values.
A new input overwrite has been introduced to prevent accidental overwriting of existing files in the workspace when a composite action’s cache-dependency-path refers to common filenames like requirements.txt. By default, if a file with the same path already exists in the workspace, it will not be copied from the action unless overwrite: true is explicitly set.
action.yml:34
- Consider adding
type: booleanfor theoverwriteinput in action.yml to enforce boolean validation and improve input clarity.
overwrite:
tests/setup-python.test.ts:83
- Add an assertion to check that
core.warningwas called when the copy is skipped, to ensure the warning path is covered in the test.
it('skips copy if file exists and overwrite is false', async () => {
tests/setup-python.test.ts:51
- Include an assertion that
restoreCacheis called in each test to ensure cache restoration logic is exercised.
it('copies the file if source exists and target does not', async () => {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Jul 14, 2025
Contributor
Author
|
Closing this PR as it’s not required. The fix will be incorporated directly from the toolkit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Adds an overwrite input to prevent unintended overwrites when a composite action defines a cache-dependency-path (e.g., subdir/requirements.txt) that matches a file in the user’s workspace. By default, the copy is skipped if the target file exists, unless overwrite: true is explicitly set. This avoids silently replacing user files with the same name and path structure.
Related issue:
Add link to the related issue.
Check list: