Skip to content

Add overwrite input to optionally allow copying over existing dependency files from non-root directories #1149

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

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

Conversation

aparnajyothi-y
Copy link
Contributor

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:

  • [X ] Mark if documentation changes are required.
  • [ X] Mark if tests were added or updated to cover the changes.

@HarithaVattikuti HarithaVattikuti marked this pull request as ready for review July 14, 2025 02:40
@Copilot Copilot AI review requested due to automatic review settings July 14, 2025 02:40
@HarithaVattikuti HarithaVattikuti requested a review from a team as a code owner July 14, 2025 02:41
Copy link

@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

Adds an optional overwrite flag to control whether existing dependency files are overwritten when copying cache dependencies from composite actions. Key changes:

  • Introduce overwrite boolean input in action.yml and docs.
  • Update cacheDependencies to 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, and overwrite: true in 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: boolean for the overwrite input 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.warning was 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 restoreCache is called in each test to ensure cache restoration logic is exercised.
  it('copies the file if source exists and target does not', async () => {

aparnajyothi-y and others added 2 commits July 14, 2025 17:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy