-
Notifications
You must be signed in to change notification settings - Fork 10
Support git-lfs (large file storage) #64
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
base: master
Are you sure you want to change the base?
Conversation
The tests I added are in the "Git.jl" testset, failures seem to occur in the OpenSSH tests that only run on CI. Looks like a permissions issue -- LMK if it requires any changes on my end. |
Likely because @giordano We should set up GitHub Merge Queue on this repo. |
Sounds like that test should be run only when the env var exists/is non-empty. |
I tried to fix the OpenSSH tests but I'm not having luck. It seems like it's detecting the env var and starting the OpenSSH tests despite my new check but failing when it actually tries to use the key, I think in this line Line 112 in bf81c75
I'd like to get this merged and don't have much experience with these permissions issues. Could we merge this regardless of the CI issue? I can revert my attempts to fix it if you'd like. |
☝️ Emphasis is mine |
Also, doing this in a separate PR would be a good idea, since it's logically unrelated to this PR. |
test/runtests.jl
Outdated
ssh_privkey = get(ENV, "CI_READONLY_DEPLOYKEY_FOR_CI_TESTSUITE_PRIVATEKEY", nothing) | ||
if is_ci && is_gha && !isnothing(ssh_privkey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is logically the same as b98ca06, not a great surprise this doesn't work either. My suggestion was
ssh_privkey = get(ENV, "CI_READONLY_DEPLOYKEY_FOR_CI_TESTSUITE_PRIVATEKEY", "")
if !isempty(ssh_privkey
Also, the other checks are useless at this point.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #64 +/- ##
==========================================
- Coverage 96.96% 95.00% -1.97%
==========================================
Files 1 1
Lines 33 40 +7
==========================================
+ Hits 32 38 +6
- Misses 1 2 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thanks for the tip! I implemented your suggestion and most of the tests are passing now. I'm not sure what's causing the "Julia min" tests to fail on windows, they seem to have passed the last time full CI was run (see here). |
src/git_function.jl
Outdated
@@ -52,8 +53,8 @@ function git(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true) | |||
end | |||
|
|||
# Use OpenSSH from the JLL: <https://github.com/JuliaVersionControl/Git.jl/issues/51>. | |||
path = split(get(ENV, "PATH", ""), pathsep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be incorrect? On Windows, this means that git
will now use the system ENV
, rather than the one set by the JLL, right? So it's missing the relevant JLL paths? Which might also be the reason for the CI failure?
I was just implementing my own version of this PR (as I hadn't notice this one 😅), and I ended up parsing git_cmd.env
to ensure that I push to the correct path always. It's a bit noisy and ugly, but it was looking like this:
function _push_git_lfs_to_path!(git_cmd::Cmd)
GitLFSExt = Base.get_extension(@__MODULE__, :GitLFSExt)
if isnothing(GitLFSExt)
throw(GitLFSNotLoadedError())
end
idx = findfirst(startswith("PATH="), git_cmd.env)
path = if isnothing(idx)
""
else
# dropping the `PATH=` part
git_cmd.env[idx][6:end]
end
path = split(get(ENV, LIBPATH_env, ""), path)
pushfirst!(path, GitLFSExt.git_lfs_path())
return addenv(git_cmd, "PATH" => join(path, pathsep))
end
A simpler approach might be to pull something like
path = vcat(dirname(Git_jll.git_path), split(get(ENV, "PATH", ""), pathsep))
libpath = vcat(Git_jll.LIBPATH_list, split(get(ENV, LIBPATH_env, ""), pathsep))
out of the if
and conditionally only add the OpenSSH paths in the if
? But I wasn't 100% sure that's correct either, so I opted for the more convoluted approach where I know I am only minimally changing the PATH
variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, I pulled path = split(get(ENV, "PATH", ""), pathsep)
out of a block that only runs if the system is not windows so it would make sense I could have missed something like this. The part that confused me was why it passed on the Windows runs with more recent Julia versions and failed on the Julia 1.6 run.
I'll try to give this another try tonight or tomorrow. If you see an easy solution, you're welcome to submit a PR against my branch here if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mortenpi, thanks for the suggestion! I think I have something working based on your solution that I'm about to push to see if it fixes the CI errors, but I'm not sure what your line
path = split(get(ENV, LIBPATH_env, ""), path)
is supposed to do and it was causing errors so I removed it. LMK of any other changes you would suggest.
Edit: new commit did not fix CI errors -.-
☝️ |
Ok, let's fix the CI for external PRs first and then we can revisit this. See #66. |
The path can be modified by preceding code, so we need to read it from `git_cmd`, append the `git-lfs` directory, then write back to `git_cmd`.
CI issue could be related to single quotes in `cmd.exec` entries?
I was able to repro this (on a Windows machine) locally with Julia 1.6.0, but the tests pass with 1.6.7. I'll try to figure out what actually is failing (and if it's a bug that got fixed), but in the meanwhile, any thoughts on bumping minimum Julia to 1.6.X or even 1.10.0? |
Sounds OK to me, @DilumAluthge? |
This looks like and MWE (for 1.6.0). This works on 1.6.7. So no fault of this PR as far as I can tell.
|
This is the first Julia version that can handle nested `addenv` calls on Windows (for JuliaVersionControl#64).
Need bugfix to multiple calls to `addenv` on Windows
Yes, that sounds good. |
the `version: 'min'` jobs hit Julia 1.6.6 but we should also test against 1.7.3 on Windows to ensure the `addenv` calls are working
Okay I added a single job on windows-latest with Julia 1.7.3 which passes (see here). It doesn't seem worth it to add 1.7.3 to the full CI matrix since we only ever had issues on Windows, but LMK if you'd like to have it in the matrix so we run Julia 1.7.3 against all the other OSes as well. |
This adds the path to the
git-lfs
binary provided by Git_LFS_jll.jl to the PATH in the environment of the command returned byGit.git()
. This enables working with repositories that use the Git LFS protocol.I wrote a test case (which does work) but the test repo it clones is a bit big (~200 MB) so if anyone knows of / can create a smaller test repo with LFS files we can test, feel free to suggest a different one.
With respect to the tests, I think all github runners have git-lfs installed by default and so I don't know if we should be testing something to make sure we are using the correct git-lfs. Anecdotally I have a mac OS laptop that does not have git-lfs installed in its global path and I can confirm that this works on that machine.
Thanks to @giordano for providing advice on how to get started with this implementation.