Skip to content

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

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

Closed
wants to merge 2 commits into 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.

Check list:

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

@Copilot Copilot AI review requested due to automatic review settings July 4, 2025 13:18
@aparnajyothi-y aparnajyothi-y requested a review from a team as a code owner July 4, 2025 13:18
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

Implements an optional overwrite flag to control copying of cache dependency files, preventing accidental overwrites of existing workspace files.

  • Introduce overwrite boolean input in core logic to skip or force copy based on existing targets
  • Update action.yml and docs to expose and explain the new overwrite setting
  • Extend test suite to cover overwrite-true, overwrite-false, and warning 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 and adjusted copy logic and logs
action.yml Defined new overwrite input with default and description
docs/advanced-usage.md Documented overwrite behavior in advanced usage guide
tests/setup-python.test.ts Added tests for overwrite, skip, and warning behaviors
Comments suppressed due to low confidence (2)

tests/setup-python.test.ts:44

  • None of the new tests assert that cacheDistributor.restoreCache() is called. Consider adding expect(mockRestoreCache).toHaveBeenCalled(); in each test to ensure the cache restore logic still executes.
  it('copies the file if source exists and target does not', async () => {

tests/setup-python.test.ts:149

  • The test for when source and target are the same path no longer checks the resolved path log. Add an assertion for Resolved cache-dependency-path to cover the resolvedDependencyPath logging branch.
    );

@@ -26,7 +26,8 @@ export async function cacheDependencies(cache: string, pythonVersion: string) {
const cacheDependencyPath =
core.getInput('cache-dependency-path') || undefined;
let resolvedDependencyPath: string | undefined = undefined;

const overwrite =
core.getBooleanInput('overwrite', {required: false}) ?? false;
Copy link
Preview

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

[nitpick] The nullish coalescing (?? false) is redundant because getBooleanInput always returns a boolean when required: false. You can simplify to const overwrite = core.getBooleanInput('overwrite', {required: false});.

Suggested change
core.getBooleanInput('overwrite', {required: false}) ?? false;
core.getBooleanInput('overwrite', {required: false});

Copilot uses AI. Check for mistakes.

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