snoyberg / tar-conduit

Conduit based tar extraction mechanism
MIT License
8 stars 9 forks source link

Move CI on to GitHub Actions and update GHC versions #35

Closed mpilgrem closed 1 year ago

mpilgrem commented 1 year ago

@snoyberg, after a couple of false starts, I think this can be merged. The test is at my fork: https://github.com/mpilgrem/tar-conduit.

mpilgrem commented 1 year ago

The Travis CI failure is not introduced by this pull request but was already present. It manifests as:

Failures:
  tests\\Spec.hs:55:17: 
  1) tar/untar/tar structure
       uncaught exception: IOException of type PermissionDenied
       System.Win32File.read: permission denied (Permission denied)
  To rerun use: --match "/tar/untar/tar/structure/"

After some investigation, it appears that this error is the one that is reported when the repository is cloned on Windows without respecting symlinks. I could not identify anywhere in the Haskell universe System.Win32File.read (note that this is not System.Win32.File.read). Also, I was getting (in PowerShell with Administrator rights) (extracts):

❯ stack --verbose test tar-conduit:test:tests --test-arguments --match="/tar/untar/tar/structure/"
...
2023-08-05 14:31:50.900485: [debug] Run process within D:\Users\mike\Code\GitHub\tar-conduit\: D:\Users\mike\Code\GitHub\tar-conduit\.stack-work\dist\c3556505\build\tests\tests.exe --match=/tar/untar/tar/structure/

tar/untar/tar
  structure [✘]

Failures:

  tests\Spec.hs:55:17:
  1) tar/untar/tar structure
       uncaught exception: IOException of type PermissionDenied
       System.Win32File.read: permission denied (Permission denied)

  To rerun use: --match "/tar/untar/tar/structure/"

Randomized with seed 1947931278

Finished in 0.7076 seconds
1 example, 1 failure
2023-08-05 14:31:52.104559: [debug] Process finished in 1204ms: D:\Users\mike\Code\GitHub\tar-conduit\.stack-work\dist\c3556505\build\tests\tests.exe --match=/tar/untar/tar/structure/

but if I ran that same tests.exe command myself (in PowerShell with Administrator rights) it did not fail:

❯ D:\Users\mike\Code\GitHub\tar-conduit\.stack-work\dist\c3556505\build\tests\tests.exe --match=/tar/untar/tar/structure/

tar/untar/tar
  structure [✔]

Finished in 23.8525 seconds
1 example, 0 failures

However, if I clone the respository in a way that respects symlinks, I get a different error which refers to Привет.xhml (which, on the remote respository, is a symlink to Здарова.xml) (extracts):

2023-08-05 14:49:53.175812: [debug] Run process within D:\Users\mike\Code\GitHub\tar-conduit\: D:\Users\mike\Code\GitHub\tar-conduit\.stack-work\dist\c3556505\build\tests\tests.exe --match=/tar/untar/tar/structure/

tar/untar/tar
  structure [✘]

Failures:

  src\Data\Conduit\Tar\Windows.hs:31:48:
  1) tar/untar/tar structure
       uncaught exception: ErrorCall
       Unsupported file type: ./tests\files\Привет.xhml
       CallStack (from HasCallStack):
         error, called at src\Data\Conduit\Tar\Windows.hs:31:48 in tar-conduit-0.3.2.1-6vL3pH0pZj23M8FL0tBk41:Data.Conduit.Tar.Windows

  To rerun use: --match "/tar/untar/tar/structure/"

Randomized with seed 1006212809

Finished in 0.0073 seconds
1 example, 1 failure
2023-08-05 14:49:53.459432: [debug] Process finished in 284ms: D:\Users\mike\Code\GitHub\tar-conduit\.stack-work\dist\c3556505\build\tests\tests.exe --match=/tar/untar/tar/structure/

and it is this error that the GitHub Actions CI will fail on for Windows only.

That is because Data.Conduit.Tar.Windows.getFileInfo has (extracts):

getFileInfo :: FilePath -> IO FileInfo
getFileInfo fp = do
    fs <- Posix.getSymbolicLinkStatus fp
    ...
    (fType, fSize) <-
        case () of
            () | Posix.isRegularFile fs     -> return (FTNormal, Posix.fileSize fs)
               | Posix.isDirectory fs       -> return (FTDirectory, 0)
               | otherwise                  -> error $ "Unsupported file type: " ++ fp

So, Spec.hs needs some attention. However that is distinct from moving the CI from Travis CI to GitHub Actions.