-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add Windows compatibility #3
Draft
amotl
wants to merge
11
commits into
pipifein:master
Choose a base branch
from
pyveci:amo/gha-windows
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
Open
Now, `jenkins_env` and `github_action_env` will only be tested through `get_ci_info`. That is the main adapter function anyway.
This is just a minor fix for the test suite to adjust path semantics for Windows, which uses backslashes as directory separators instead of slashes.
Actually, the `test_upload_files_success` test should have revealed it. However, we discovered that when mocking the `NamedTemporaryFile` object, we created an instance instead of propagating a factory. That is wrong, because it expands the scope of the temporary file to the whole test case, and not the scope of the `test_upload_files` function only.
Apparently, mocking `urllib.urlopen()` will not trigger the flaw within a test case on Windows. So, let's use a different strategy by mocking the socket object instead. In this manner, the whole machinery of `urllib` and `http.client` will still be active, hopefully revealing the incompatibility with Windows.
Windows places an exclusive lock on files opened for writing. So, opening the temporary tarfile twice (once by `NamedTemporaryFile` and another time by `tarfile.open(fd.name)` makes things croak with `PermissionError: [Errno 13] Permission denied`. Instead, let's reuse the file handle already opened by `NamedTemporaryFile`.
dedd122
to
f795774
Compare
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.
Dear Mathias,
CrateDB build #4567182253, triggered by crate/crate#11994, revealed a Windows compatibility issue with
wacklig-uploader
, it looks like:The reason is that Windows places an exclusive lock on files opened for writing [1]. So, opening the temporary tarfile twice (once by
NamedTemporaryFile
and another time bytarfile.open(fd.name)
makes things croak withPermissionError: [Errno 13] Permission denied
.Instead, with this patch, the file handle already opened by
NamedTemporaryFile
will be reused for writing to [2].At wacklig-uploader build #4574519892, we have been able to verify it with a corresponding test case, added with 1f84ee6. Now, Windows compatibility has been added with dedd122, wacklig-uploader build #4575000733 demonstrates it.
The baseline test harness to reveal and mitigate this issue has been added with a previous patch set submitted as #2, where this patch is based upon.
With kind regards,
Andreas.
[1] https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file
[2] https://stackoverflow.com/questions/15857792/how-to-construct-a-tarfile-object-in-memory-from-byte-buffer-in-python-3