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

Clean up the managed directories to avoid external side effect influence #15

Closed
wants to merge 5 commits into from

Conversation

exp-hc
Copy link

@exp-hc exp-hc commented Nov 21, 2021

To avoid issue #14, I'm proposing using rsync to copy the new collection content and then deleting the original temp directory instead of using mv. I also found the title of this block of code did not represent the action.

action.yml Show resolved Hide resolved
action.yml Outdated
run: >-
set -x
;
mkdir -pv
"${{ steps.collection-metadata.outputs.collection-namespace-path }}"
;
mv -v
rsync -a
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't support working in a dirty working dir. I was about to suggest doing the cleanup in the post stage (https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#post) but it looks like only JS actions support that: actions/runner#1478.

So for now, I'd go for rm -rf .tmp-ansible-collection-checkout/ as the first step.

Copy link
Author

Choose a reason for hiding this comment

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

We would need to rm -rf "${{ steps.collection-metadata.outputs.collection-namespace-path }}" as the destination directory of the move is the issue. I can update this PR if that is the route you prefer.

Copy link
Author

Choose a reason for hiding this comment

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

@webknjaz change pushed

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to clean up the whole directory we manage to prevent any similar problems with other dirs. Especially as we never expect external influence on that dir.

Copy link
Member

Choose a reason for hiding this comment

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

As a side note: maybe I'll consider using ln -sf instead of mv in the future. But this is out of the scope here.

action.yml Outdated
run: >-
set -x
;
rm -rf
"${{ steps.collection-metadata.outputs.checkout-path }}"
Copy link
Member

Choose a reason for hiding this comment

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

This should:

  1. Clean up the whole directory structure we manage to prevent any further side effects.
  2. Do (1) as the very first step in this action, before the checkout.

Copy link
Member

Choose a reason for hiding this comment

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

Moreover, I'd probably clean up both dirs, I think. Maybe the whole collections dir too.

Copy link
Author

Choose a reason for hiding this comment

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

That makes sense, I've implemented the change per your suggestion.

@webknjaz webknjaz changed the base branch from main to unstable/v1 November 22, 2021 17:56
@webknjaz webknjaz changed the title Replace mv with rsync Replace mv with rsync Nov 22, 2021
@webknjaz webknjaz changed the title Replace mv with rsync Clean up the managed directories to avoid external side effect influence Nov 22, 2021
@exp-hc
Copy link
Author

exp-hc commented Nov 29, 2021

as another follow-up here, without removing the directories even a successful job will break subsequent jobs.

First job log output

Run set -x ; mkdir -pv "ansible_collections/expedient" ; mv -v ".tmp-ansible-collection-checkout" "ansible_collections/expedient/smc" ; set +x
  set -x ; mkdir -pv "ansible_collections/expedient" ; mv -v ".tmp-ansible-collection-checkout" "ansible_collections/expedient/smc" ; set +x
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.9/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.9/x64/lib
+ mkdir -pv ansible_collections/expedient
mkdir: created directory 'ansible_collections'
mkdir: created directory 'ansible_collections/expedient'
+ mv -v .tmp-ansible-collection-checkout ansible_collections/expedient/smc
renamed '.tmp-ansible-collection-checkout' -> 'ansible_collections/expedient/smc'
+ set +x

Second job log output

Run set -x ; mkdir -pv "ansible_collections/expedient" ; mv -v ".tmp-ansible-collection-checkout" "ansible_collections/expedient/smc" ; set +x
  set -x ; mkdir -pv "ansible_collections/expedient" ; mv -v ".tmp-ansible-collection-checkout" "ansible_collections/expedient/smc" ; set +x
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.9.9/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.9/x64/lib
+ mkdir -pv ansible_collections/expedient
+ mv -v .tmp-ansible-collection-checkout ansible_collections/expedient/smc
renamed '.tmp-ansible-collection-checkout' -> 'ansible_collections/expedient/smc/.tmp-ansible-collection-checkout'
+ set +x

@exp-hc exp-hc closed this Dec 16, 2021
@exp-hc exp-hc deleted the bug_mv branch December 16, 2021 14:07
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.

2 participants