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: add symlink support in actions #461

Merged
merged 6 commits into from
Mar 2, 2023

Conversation

torresxb1
Copy link
Contributor

@torresxb1 torresxb1 commented Feb 28, 2023

Issue #, if available:

Description of changes:
Add symbolic link support in actions for copying code, copying dependencies, and cleaning directories. Also adds an action to support creating a symbolic link from a source path to a destination path.

Currently not used for anything, but will be used for the node_npm workflow in a subsequent PR (would be kinda big if I combined everything into one)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@torresxb1 torresxb1 requested a review from a team as a code owner February 28, 2023 21:18
@torresxb1 torresxb1 changed the title Add symlink support in actions feat: dd symlink support in actions Feb 28, 2023
@torresxb1 torresxb1 changed the title feat: dd symlink support in actions feat: add symlink support in actions Feb 28, 2023
@@ -1,59 +0,0 @@
import os
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to tests/functional/test_actions.py and added a few more tests. Since our integration tests are not counted towards code coverage, if I added tests here it would fail the 94% check. Anyway, I think these probably better suited, or at least equally suited, as functional tests.

@torresxb1 torresxb1 requested review from moelasmar and removed request for jfuss February 28, 2023 23:03
@@ -0,0 +1,127 @@
import os
Copy link
Contributor Author

@torresxb1 torresxb1 Feb 28, 2023

Choose a reason for hiding this comment

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

I added lines 34-91, and 121-127. The rest were just moved from it's previous location (tests/integration/test_actions.py)

@@ -193,7 +197,8 @@ def create_symlink_or_copy(source: str, destination: str) -> None:
os.symlink(Path(source).absolute(), Path(destination).absolute())
except OSError as ex:
LOG.warning(
"Symlink operation is failed, falling back to copying files",
"Symbolic link creation failed, falling back to copying files instead. To optimize speed, "
"consider enabling the necessary settings or privileges on your system to support symbolic links.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be prescriptive on the necessary settings? ex: set x

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'm not sure that we can pinpoint exactly why it failed or how to resolve it. It might vary by OS and version.

class LinkSinglePathAction(BaseAction):
NAME = "LinkSource"

DESCRIPTION = "Creates symbolic link at dest, pointing to source"
Copy link
Contributor

Choose a reason for hiding this comment

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

Complete nit: let's use full forms for description.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we show this description for the customers any where ?

Copy link
Contributor Author

@torresxb1 torresxb1 Mar 1, 2023

Choose a reason for hiding this comment

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

Complete nit: let's use full forms for description.

What do you mean by this @sriram-mv ?

Do we show this description for the customers any where ?

I tried looking for this and actually I don't think so. @moelasmar

Copy link
Contributor

Choose a reason for hiding this comment

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

dest -> destination.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhh I thought you were referring to a form, as in filling out a form, or something. Yeah I can change it (although again I'm not sure what this description is used for as I don't think it's displayed anywhere AFAIK)

tests/functional/test_utils.py Outdated Show resolved Hide resolved
os.makedirs(os.path.dirname(new_destination), exist_ok=True)
linkto = os.readlink(dependencies_source)
create_symlink_or_copy(linkto, new_destination)
shutil.copystat(dependencies_source, new_destination, follow_symlinks=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

create_symlink_or_copy(linkto, new_destination)
shutil.copystat(dependencies_source, new_destination, follow_symlinks=False)

We are symlinking and copying?

Copy link
Contributor

Choose a reason for hiding this comment

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

same question here ... may be I am missing something, but will the copy ovwerwrite the created symlink ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

copystat copies the metadata: https://docs.python.org/3/library/shutil.html#shutil.copystat

Since we are "copying" the symlink by creating a new one that points to the same location as the other one, I thought we might want to copy over the metadata. Let me know if you think this is not necessary.

@torresxb1 torresxb1 removed the request for review from qingchm March 1, 2023 18:31
@torresxb1 torresxb1 requested a review from sriram-mv March 1, 2023 21:48
@torresxb1 torresxb1 enabled auto-merge (squash) March 2, 2023 19:53
@torresxb1 torresxb1 merged commit 2959925 into aws:develop Mar 2, 2023
@torresxb1
Copy link
Contributor Author

Thanks for the reviews!

@torresxb1 torresxb1 deleted the add-symlink-support-in-actions branch March 2, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants