-
Notifications
You must be signed in to change notification settings - Fork 83
feat: patch application without git #1676
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: patch application without git #1676
Conversation
087283f
to
3c8f839
Compare
I still need to figure out how to fix CI errors, but otherwise PR is ready for review. There is two kinds of errors currently, either patch application on windows, or OpenSSL version errors. I especially concerned about the latter ones as they cause most of the CI failures. Would love to hear to approach solving them. Should we store all this test data in the repository? I did this because, on my machine, scan of |
const OUTPUT_PATH: &str = "test-data/conda_forge/recipes/"; | ||
|
||
// Overview: | ||
// 1. Get repodata for conda-forge linux-64. |
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.
Interesting approach! I think I would have checked if Github has some API and tried to extract them from the feedstocks. But this obviously works nicely as well!
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 tried this initially, but hit REST API rate limit for free usage. Other option could be to use GraphQL. I haven't investigated it thoroughly yet, but it seems that it will hit rate limit as well.
Hey @remimimimimi - excellent PR and also impressive work in the The openssl errors are indeed a bit puzzling because we don't have them on Although maybe you are building an additional executable in CI? Maybe we need to enable Regarding the test data ... I think it might be better to start a second repository with the test data that we checkout during a CI run. But we can take care of that once we fixed the tests IMO. We also did indeed have some breakages with the |
@remimimimimi How I mostly diagnose the openssl errors (which can be caused by a cargo feature mismatch) is by using |
3c8f839
to
56afd9d
Compare
56afd9d
to
17191e3
Compare
df4c96d
to
c5cc6be
Compare
Introduces pure rust option to apply patches. This commit also adds tests that are automatically generated from conda-forge package recipes that use recipe.yaml and contain at least one applicable patch.
c5cc6be
to
e77f25e
Compare
I played around with this code today. A few notes:
|
Surprisingly it is not enough to just strip some prefix from the patch paths, sometimes you also have to find shortest possible matching subpath from the working directory. We fix that, and correspondingly change test to check only if diffy succeedes as git is broken here and there. There are still 4 test cases where git and diffy give different results, but that is due to git incorrect behavior. If you look at the directory diff output and patch files you'll see that diffy applies patches correctly and git silently fails. Comment is added with exact recipes that fail, so look at it if you want to check it out yourself. There are also couple of packages that still fail and we ignore them (they include mumps substring in their name) since their format is looking strange, but it is possible to easily fix this issue in practice. Final decision is postponed, since further investigation is needed on why it even works in conda. Following is the header of one of the patches in mumps recipe that fails. ```diff --- mumps/src/mumps_common_orig.h +++ mumps/src/mumps_common.h ``` In actual directory there is no file with `_orig` postfix, therefore we fail to find it. In total there is 6 different test cases that fail and we ignore it due to the reasons described above.
f5e787e
to
971a41b
Compare
Can we run the big test only when we have a certain github label, for example? They are pretty slow, I assume (downloading lots of test data) |
134f243
to
674ff26
Compare
559fb8e
to
55b4f9b
Compare
fn patches_from_str(input: &str) -> Result<Vec<Patch<'_, str>>, diffy::ParsePatchError> { | ||
patches_from_str_with_config( | ||
fn patches_from_bytes(input: &[u8]) -> Result<Vec<Patch<'_, [u8]>>, diffy::ParsePatchError> { | ||
diffy::patches_from_bytes_with_config( |
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.
Do we need to use the bytes configuration here?
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.
Yes, some of the files that are patched are not valid utf8 strings, so byte based parsing is required. This shouldn't affect errors messages that user sees, as patch application errors are currently non-existent, and parsing errors give only name of the issue, but not position. After new parser will be implemented I plan to try show string based representation for errors whenever possible.
src/source/patch.rs
Outdated
@@ -622,6 +559,12 @@ mod tests { | |||
#[exclude("mumps")] | |||
// Failed to download source | |||
#[exclude("petsc")] | |||
// GNU patch fails and diffy succeeds, seemingly correctly from the diff output. | |||
#[exclude("(fastjet-cxx)|(fenics-)|(love2d)|(flask-security-too)")] |
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.
Would be nice to at least test love2d
as it was the one we had trouble with for CLRF
.
We don't have to run it against Gnu Patch - just add some kinda snapshot test or assert that the CMakeLists file changed in the way we expect.
# Needed to use GNU patch instead of Strawberry Perl patch | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'need-patch-apply-tests') && matrix.os == 'windows-latest' }} | ||
run: Add-Content $env:GITHUB_PATH "C:\Program Files\Git\usr\bin" | ||
- name: Set up GNU patch on MacOS |
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.
Do we still need this?
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.
And if yes, I would prefer to use pixi
to install it, of course :)
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 would like to have that for consistent behavior between target operating systems. Will try pixi for MacOS.
@@ -38,12 +38,26 @@ jobs: | |||
toolchain: "1.86.0" | |||
components: clippy,rustfmt | |||
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2 | |||
# https://github.com/actions/runner-images/issues/5459#issuecomment-1532856844 | |||
- name: Set up GNU patch on Windows |
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.
Do we need this?
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 would like to have that for consistent behavior between target operating systems.
23cb6a4
to
848148e
Compare
4d56ade
to
988d448
Compare
988d448
to
32d7df6
Compare
This PR adds a pure Rust patch application using
diffy
(fork with changes is here) and includes test for sources generated from conda-forge recipes. It also adds a newpatch-apply-gen-test-data
binary to harvestrecipe.yaml
and corresponding patch files fromconda-forge
linux-64
repodata into a local ./recipes directory for testing.Initially tests data was planned to be generated from converted
meta.yaml
, but reality showed thatconda-recipe-manager
can not automatically convert most of the packages. From my trial I saw only <5 packages working, out of 17k available.Current state is draft, until some clean up is finished.