-
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
Fix computing effective branch name from GITHUB_REF
on GHA
#4
Draft
amotl
wants to merge
12
commits into
pipifein:master
Choose a base branch
from
pyveci:amo/fix-gha-branch-name-from-ref
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.
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
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`.
There was a flaw when running directly on a branch (no PR) on GHA, and the branch contained slashes.
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.
Hi again,
while working on #2 and #3, I discovered that the
github_action_env
routine did not compute thebranch
attribute from theGITHUB_REF
environment variable properly, when the effective branch name contained slashes.661ed32 fixes it and adds another test
test_github_parse_branch_from_ref
, which exercisesGITHUB_REF
with those combinations:refs/heads/feature-branch-1
refs/heads/author/feature-branch-1
refs/heads/realm/author/feature-branch-1
With kind regards,
Andreas.