Repository navigation
Use a local secure repositories in the test-suite. - #9540
andreabedini wants to merge 4 commits into
Conversation
|
This sounds awesome! I’ll try to have a look this week. I wonder if this will bring any performance benefit… |
ulysses4ever
left a comment
There was a problem hiding this comment.
Cool, thanks!
I’m surprised withRemoteRepo had so few clients…
| -- backoff starting from 50ms, up to a maximum wait of 60s | ||
| _ <- waitTcpVerbose putStrLn (limitRetriesByCumulativeDelay 60000000 $ exponentialBackoff 50000) "localhost" "8000" | ||
| runReaderT m (env { testHaveRepo = True })) | ||
| liftIO $ appendFile (testUserCabalConfigFile env) |
There was a problem hiding this comment.
As an option, you could use cabal user-config update? But, perhaps, this doesn’t matter.
There was a problem hiding this comment.
uhm, TIL, how does that work? I have never used it before.
There was a problem hiding this comment.
Not sure what's the right way to call cabal-install in this part of the code, but from the command line you can do something like this to experiment:
❯ CABAL_DIR=. cabal update
❯ CABAL_DIR=. cabal user-config update --augment="repository test-local-repo
url: file:some/dir/file
secure: True
root-keys: mykeys"
and observe ./config. This seems to work for a repository, but trying to update remote-repo-cache doesn't do what is desired here: it updates the existing field from the default value ./packages to whatever new value you supply. Unless I misunderstand what appendFile achieves: if it overrides the earlier value of remote-repo-cache, then maybe it's the same.
I see now that it's not your code: you just moved around what was there before, so I want to clarify that my remark about user-config shouldn't derail the PR.
mpickering
left a comment
There was a problem hiding this comment.
Looks like a very nice improvement to me. Good job @andreabedini
|
Is this a fix for #9530? I can't find any reference to that issue in the description. I guess we'll know when CI runs for a couple of days and the |
|
@andreabedini there's an issue with the new |
23ce661 to
b1edc91
Compare
|
The But we have a new challenge now. Windows strikes back… |
372df0f to
e9ea717
Compare
|
I tried to remove |
|
I cannot reproduce the error on my MSYS2 because of this failing command: Not sure what is going on here. Note that: So it seems GNU |
|
What's happening there is that standard |
|
I replaced my This is what is being written to the configuration. While uris to files in windows seem to use (ref https://en.wikipedia.org/wiki/File_URI_scheme): Although that still doesn't work for me... Also if I ctrl+click that |
|
So I think I have a veredict on what could be going wrong here. TL;DR: see below the horizontal rule at the end of this comment. First of all, local secure repos are parsed in this chunk of code: withRepo _ callback | uriScheme remoteRepoURI == "file:" = do
dir <- Sec.makeAbsolute $ Sec.fromFilePath (uriPath remoteRepoURI)Now looking into those functions from λ: u = "file:///C:/Users/Javier/code/cabal/cabal-testsuite/PackageTests/NewUpdate/UpdateIndexState/update-index-state.dist"
λ: Just uri = parseURI nu
λ: makeAbsolute $ fromFilePath $ Network.URI.uriPath uri
Path "C:\\/Users/Javier/Users/Javier/code/cabal/cabal-testsuite/PackageTests/NewUpdate/UpdateIndexState/update-index-state.dist"So it is interpreting the path as relative (see the duplicated λ: unPathNative (Path fp) = FP.Native.joinPath . FP.Posix.splitDirectories $ fp
λ: (\(FsPath p) -> putStrLn $ unPathNative p) $ fromFilePath $ Network.URI.uriPath uri
C:Users\Javier\code\cabal\cabal-testsuite\PackageTests\NewUpdate\UpdateIndexState\update-index-state.distSo at this point it is already wrong. λ: (\(FsPath p) -> FP.Native.isAbsolute $ unPathNative p) $ fromFilePath $ Network.URI.uriPath uri
FalseBut this looks fine, except for the first λ: (\(FsPath (Path p)) -> putStrLn p) $ fromFilePath $ Network.URI.uriPath uri
/C:/Users/Javier/code/cabal/cabal-testsuite/PackageTests/NewUpdate/UpdateIndexState/update-index-state.distWhich can be fixed with a call to λ: (\(FsPath (Path p)) -> putStrLn $ FP.Native.normalise p) $ fromFilePath $ Network.URI.uriPath uri
C:/Users\Javier\code\cabal\cabal-testsuite\PackageTests\NewUpdate\UpdateIndexState\update-index-state.dist
λ: (\(FsPath (Path p)) -> FP.Native.isAbsolute $ FP.Native.normalise p) $ fromFilePath $ Network.URI.uriPath uri
True
λ: (\(FsPath (Path p)) -> FP.Native.isAbsolute p) $ fromFilePath $ Network.URI.uriPath uri
FalseNote however that we should use the λ: (\(FsPath (Path p)) -> FP.Native.isAbsolute $ FP.Posix.normalise p) $ fromFilePath $ Network.URI.uriPath uri
FalseI'm unsure on how to follow here. The code in newtype Path a = Path FilePath -- always a Posix style path internallySo I think the issue is more general. Filepaths in windows will have a preceding fromFilePath :: FilePath -> FsPath
fromFilePath fp
| FP.Native.isAbsolute fp = FsPath (mkPathNative fp :: Path Absolute)will return |
|
Another possible outcome of this would be: " |
|
@gbaz, do you have thoughts on this issue related to hackage-security? (See just above.) |
|
I was pinged to comment here and I'm not sure I understand the issue. In We will lose
Also see:
The meaning of all these paths depends on the scheme, which is URI schemes are registered with the IANA: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml The relevant RFC for The ABNF here is: From what I understand here, all paths are considered "absolute":
There is an appendix for windows/DOS paths: https://www.rfc-editor.org/rfc/rfc8089.html#appendix-E.2 So the updated ABNF is And the spec gives two examples of absolute windows filepaths: These are equivalent. It doesn't say so, but I believe the third form is So the spec clearly shows what the semantics are for windows filepaths encoded in URI. I'm not sure what your question is. The
How you distinguish between windows and unix, I don't really know. Edit: yes, leading slash is a relative path on windows. |
|
@jasagredo wow, thanks for the great invetigation. I will need some time to understand what to do. |
|
@jasagredo You have done many experiments with as we are producing now. This seems to be valid as per RFC 8089, and parsed correctly by |
No, backslashes are not permitted as per RFC 3986 and neither per RFC 8089. Quoting the latter:
None of the proposed ABNFs in RFC 8089 include backslashes. So you'll have to go with a normalization function before attempting proper parsing. |
|
I've written a library that parses correctly, with the spec-deviation that when requesting to parse windows paths it would reject posix paths (otherwise it's hard to disambiguate and the ABNF is actually ambiguous): https://hackage.haskell.org/package/file-uri-0.1.0.0/docs/System-URI-File.html#v:parseFileURI This means when you get a windows path, it either starts with a drive letter or is a UNC path. |
|
It'd be good to find someone to revive this PR. |
The test-suite prelude provides the function `withRemoteRepo` to set up a secure remote repository using hackage-repo-tool. The created repository is then served using python3 internal http server. Creating the http server and waiting for it to be ready turns out to be very fragile. Moreover what we really need in the test-suite it not to check any remote connectivity but to test features related to hackage-security and index-state. This can be more reliably achieved using a local secure repository (e.g. file://). This change: - Renames withRemoteRepo to withSecureRepo, to better indicate the main difference from withRepo. - Configures the repository with a file:// url rather than http:// - Removes the need for python3 and any retry logic. - At variance with withRepo, withSecureRepo should work on Windows. - Invokes hackage-repo-tool in such a way index timestamps can be made predictable and controllable from the test.
Co-authored-by: Artem Pelenitsyn <[email protected]>
GNU tar supports the options but other tar's don't. The current Windows setup on github runners seem to use a tar that doesn't.
e9ea717 to
00d8530
Compare

The test-suite prelude provides the function
withRemoteRepoto set upa secure remote repository using hackage-repo-tool. The created
repository is then served using python3 internal http server.
Creating the http server and waiting for it to be ready turns out to be
very fragile. Moreover what we really need in the test-suite it not to
check any remote connectivity but to test features related to
hackage-security and index-state. This can be more reliably achieved
using a local secure repository (e.g. file://).
This change:
main difference from withRepo.
predictable and controllable from the test.
This solves some recent failures we have seen in CI.
Please read Github PR Conventions and then fill in one of these two templates.
Template Α: This PR modifies
cabalbehaviourInclude the following checklist in your PR:
Template Β: This PR does not modify
cabalbehaviour (documentation, tests, refactoring, etc.)Include the following checklist in your PR: