Skip to content
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

[WIP] Optimistic download #184

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

[WIP] Optimistic download #184

wants to merge 28 commits into from

Conversation

tmspzz
Copy link
Owner

@tmspzz tmspzz commented May 15, 2019

As per #181 , if a version file exists trust that everything else is there too.

@hlintBot
Copy link

hlintBot commented May 15, 2019

22 Warnings
⚠️ PR is classed as Work in Progress
⚠️ src/CommandParsers.hs#L112 - Found Use <$>

pure Download <*> udcPayloadParser

Why Not

Download <$> udcPayloadParser

    
⚠️ src/Lib.hs#L256 - Found Reduce duplication

let finalRepositoryMapEntries
      = if _noIgnore noIgnoreFlag then repositoryMapEntries else
          repositoryMapEntries `filterRomeFileEntriesByPlatforms`
            ignoreMapEntries
let repositoryMap = toRepositoryMap finalRepositoryMapEntries
let reverseRepositoryMap
      = toInvertedRepositoryMap finalRepositoryMapEntries
let finalIgnoreNames
      = if _noIgnore noIgnoreFlag then [] else ignoreFrameworks

Why Not

Combine with src/Lib.hs:359:5

    
⚠️ src/Lib.hs#L275 - Found Reduce duplication

let filteredCurrentMapEntries
      = currentMapEntries `filterRomeFileEntriesByPlatforms`
          ignoreMapEntries
let currentFrameworks
      = concatMap (snd . romeFileEntryToTuple) filteredCurrentMapEntries
let currentFrameworkVersions
      = map (flip FrameworkVersion currentVersion) currentFrameworks
let currentInvertedMap
      = toInvertedRepositoryMap filteredCurrentMapEntries

Why Not

Combine with src/Lib.hs:400:15

    
⚠️ src/Lib.hs#L295 - Found Redundant bracket

if _noSkipCurrent noSkipCurrentFlag then
  (currentFrameworkVersions `filterOutFrameworksAndVersionsIfNotIn`
     finalIgnoreNames)
  else []

Why Not

if _noSkipCurrent noSkipCurrentFlag then
  currentFrameworkVersions `filterOutFrameworksAndVersionsIfNotIn`
    finalIgnoreNames
  else []

    
⚠️ src/Lib.hs#L973 - Found Reduce duplication

dwarfUUIDs <- dwarfUUIDsFrom (frameworkDirectory </> fwn)
maybeUUIDsArchives <- liftIO $
                        forM dwarfUUIDs $
                          \ dwarfUUID ->
                            runMaybeT $
                              do dwarfArchive <- exceptToMaybeT $
                                                   createZipArchive (bcSymbolMapPath dwarfUUID)
                                                     verbose
                                 return (dwarfUUID, dwarfArchive)
unless skipLocalCache $
  forM_ maybeUUIDsArchives $
    mapM $
      \ (dwarfUUID, dwarfArchive) ->
        maybe (return ()) liftIO $
          runReaderT <$>
            (saveBcsymbolmapToLocalCache <$> mlCacheDir <*> Just dwarfUUID <*>
               Just dwarfArchive
               <*> Just reverseRomeMap
               <*> Just fVersion
               <*> Just platform)
            <*> Just (cachePrefix, s, verbose)

Why Not

Combine with src/Lib.hs:1189:7

    
⚠️ src/Lib.hs#L1008 - Found Reduce duplication

frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory
  = carthageArtifactsBuildDirectoryForPlatform platform f
frameworkDirectory
  = platformBuildDirectory </> frameworkNameWithFrameworkExtension
dSYMNameWithDSYMExtension
  = frameworkNameWithFrameworkExtension <> ".dSYM"
dSYMdirectory
  = platformBuildDirectory </> dSYMNameWithDSYMExtension
bcSymbolMapPath d
  = platformBuildDirectory </> bcsymbolmapNameFrom d

Why Not

Combine with src/Lib.hs:1088:3

    
⚠️ src/Lib.hs#L1008 - Found Reduce duplication

frameworkNameWithFrameworkExtension = appendFrameworkExtensionTo f
platformBuildDirectory
  = carthageArtifactsBuildDirectoryForPlatform platform f
frameworkDirectory
  = platformBuildDirectory </> frameworkNameWithFrameworkExtension
dSYMNameWithDSYMExtension
  = frameworkNameWithFrameworkExtension <> ".dSYM"
dSYMdirectory
  = platformBuildDirectory </> dSYMNameWithDSYMExtension
bcSymbolMapPath d
  = platformBuildDirectory </> bcsymbolmapNameFrom d

Why Not

Combine with src/Lib.hs:1224:3

    
⚠️ src/Lib.hs#L1282 - Found Reduce duplication

saveBinaryToLocalCache lCacheDir versionFileBinary
  (prefix </> versionFileRemotePath)
  versionFileName
  verbose
liftIO $ saveBinaryToFile versionFileBinary versionFileLocalPath
sayFunc $
  "Copied " <> versionFileName <> " to: " <> versionFileLocalPath

Why Not

Combine with src/Lib.hs:1801:17

    
⚠️ src/Lib.hs#L1297 - Found Reduce duplication

versionFileName
  = versionFileNameForProjectName $ fst projectNameAndVersion
versionFileLocalPath = carthageBuildDirectory </> versionFileName
versionFileRemotePath = remoteVersionFilePath projectNameAndVersion

Why Not

Combine with src/Lib.hs:1816:3

    
⚠️ src/Lib.hs#L1398 - Found Reduce duplication

saveBinaryToLocalCache lCacheDir frameworkBinary
  (prefix </> remoteFrameworkUploadPath)
  fwn
  verbose
deleteFrameworkDirectory fVersion platform verbose
unzipBinary frameworkBinary fwn frameworkZipName verbose <*
  ifExists frameworkExecutablePath
    (makeExecutable frameworkExecutablePath)

Why Not

Combine with src/Lib.hs:1616:17

    
⚠️ src/Lib.hs#L1430 - Found Reduce duplication

let symbolmapLoggingName
      = fwn <> "." <> bcsymbolmapNameFrom dwarfUUID
let bcsymbolmapZipName d = bcsymbolmapArchiveName d version
let localBcsymbolmapPathFrom d
      = platformBuildDirectory </> bcsymbolmapNameFrom d

Why Not

Combine with src/Lib.hs:1647:21

    
⚠️ src/Lib.hs#L1440 - Found Reduce duplication

saveBinaryToLocalCache lCacheDir symbolmapBinary
  (prefix </> remoteBcSymbolmapUploadPathFromDwarf dwarfUUID)
  fwn
  verbose
deleteFile (localBcsymbolmapPathFrom dwarfUUID) verbose
unzipBinary symbolmapBinary symbolmapLoggingName
  (bcsymbolmapZipName dwarfUUID)
  verbose

Why Not

Combine with src/Lib.hs:1657:21

    
⚠️ src/Lib.hs#L1475 - Found Reduce duplication

saveBinaryToLocalCache lCacheDir dSYMBinary
  (prefix </> remotedSYMUploadPath)
  dSYMName
  verbose
deleteDSYMDirectory fVersion platform verbose
unzipBinary dSYMBinary dSYMName dSYMZipName verbose

Why Not

Combine with src/Lib.hs:1691:17

    
⚠️ src/Lib.hs#L1486 - Found Reduce duplication

frameworkZipName = frameworkArchiveName f version
remoteFrameworkUploadPath
  = remoteFrameworkPath platform reverseRomeMap f version
remoteBcSymbolmapUploadPathFromDwarf dwarfUUID
  = remoteBcsymbolmapPath dwarfUUID platform reverseRomeMap f version
dSYMZipName = dSYMArchiveName f version
remotedSYMUploadPath
  = remoteDsymPath platform reverseRomeMap f version
platformBuildDirectory
  = carthageArtifactsBuildDirectoryForPlatform platform f
dSYMName = fwn <> ".dSYM"
frameworkExecutablePath
  = frameworkBuildBundleForPlatform platform f </> fwn

Why Not

Combine with src/Lib.hs:1702:3

    
⚠️ src/Lib.hs#L1528 - Found Use lambda-case

\ e ->
  case e of
      ErrorGettingDwarfUUIDs -> sayFunc $
                                  "Error: Cannot retrieve symbolmaps ids for " <> fwn
      (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                  dwardUUIDsAndErrors

Why Not

\case
    ErrorGettingDwarfUUIDs -> sayFunc $
                                "Error: Cannot retrieve symbolmaps ids for " <> fwn
    (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                dwardUUIDsAndErrors

    
⚠️ src/Types/Commands.hs#L28 - Found Use newtype instead of data

data RomeUtilsPayload = RomeUtilsPayload{_subcommand ::
                                         RomeUtilsSubcommand}
                          deriving (Show, Eq)

Why Not

newtype RomeUtilsPayload = RomeUtilsPayload{_subcommand ::
                                            RomeUtilsSubcommand}
                             deriving (Show, Eq)

    
⚠️ src/Utils.hs#L378 - Found Use tuple-section

\ f -> (f, g)

Why Not

(, g)

    
⚠️ tests/Tests.hs#L138 - Found Use uncurry

\ (a, b) -> a || b

Why Not

uncurry (||)

    
⚠️ tests/Tests.hs#L155 - Found Redundant bracket

(unProjectName (_projectName r)) ++ " = " ++ f

Why Not

unProjectName (_projectName r) ++ " = " ++ f

    
⚠️ tests/Tests.hs#L156 - Found Redundant bracket

(map show) (_frameworks r)

Why Not

map show (_frameworks r)

    
⚠️ tests/Tests.hs#L183 - Found Move brackets to avoid $

(length $ base `filterRomeFileEntriesByPlatforms` filteringValues)
  <= length base

Why Not

length (base `filterRomeFileEntriesByPlatforms` filteringValues) <=
  length base

    

Generated by 🚫 Danger

@tmspzz tmspzz force-pushed the feature/optimistic-download branch from e9a3d00 to 66ed491 Compare May 20, 2019 16:00
@ollieatkinson
Copy link

ollieatkinson commented May 31, 2019

@blender Thanks for this work, it will certainly save us a lot of time... would you be able to make a pre-release binary (or point me in the right direction) so I can test it and provide feedback?

@tmspzz
Copy link
Owner Author

tmspzz commented May 31, 2019 via email

@ollieatkinson
Copy link

ollieatkinson commented Jun 1, 2019

Thanks for the pointer @blender - I got the branch compiled, but it did not do what I expect. I assumed it would do the following:

  1. Check the Cartfile.resolved against the .version file
  2. If a match, no files relating to the framework would be requested (including bcsymbolmaps)
  3. If there's a version mismatch, or lack of a version file then it would download all of the files relating to the framework.

I was not seeing the above behaviour, all files relating to the frameworks with valid version files were still being downloaded.

However, there's a good chance I did not set it up correctly as I'm new to Rome.

edit:

That could be useful but still .dYSM and .bcsymbolmap are not checksummed in the .version file so they would need to be downloaded again.

I have just seen your comment on the original issue, maybe this is what I am seeing - is it safe to add an option which does not download those files if the version file is present?

@tmspzz
Copy link
Owner Author

tmspzz commented Jun 1, 2019 via email

@ollieatkinson
Copy link

Did you run it with —optimistic ?

Yes

@tmspzz tmspzz changed the title [WIP ] Optimistic download [WIP] Optimistic download Jun 3, 2019
@tmspzz
Copy link
Owner Author

tmspzz commented Oct 8, 2019

This needs tests if anyone looking for hacktoberfest issues wants to finish it

@@ -96,6 +103,7 @@ udcPayloadParser =
<*> noIgnoreParser
<*> noSkipCurrentParser
<*> concurrentlyParser
<*> optimisticParser

uploadParser :: Opts.Parser RomeCommand
uploadParser = pure Upload <*> udcPayloadParser

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Found Use <$>

pure Upload <*> udcPayloadParser

Why Not

Upload <$> udcPayloadParser

    

reverseRomeMap
fVersion
platform
flip whenLeft eitherSymbolmapsOrErrors $ \e -> case e of

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Found Use lambda-case

\ e ->
  case e of
      ErrorGettingDwarfUUIDs -> sayFunc $
                                  "Error: Cannot retrieve symbolmaps ids for " <> fwn
      (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                  dwardUUIDsAndErrors

Why Not

\case
    ErrorGettingDwarfUUIDs -> sayFunc $
                                "Error: Cannot retrieve symbolmaps ids for " <> fwn
    (FailedDwarfUUIDs dwardUUIDsAndErrors) -> mapM_ (sayFunc . snd)
                                                dwardUUIDsAndErrors

    

@vytautasgimbutas
Copy link
Contributor

Any progress on this PR?

@tmspzz
Copy link
Owner Author

tmspzz commented Mar 4, 2020

@vytautasgimbutas it needs to be adapted to the current code base and it needs integration tests. Do you want to give it a shot?

@felipe-azevedo
Copy link

I'd be very interested in this too.
Is there an ETA for it?

@felipe-azevedo
Copy link

felipe-azevedo commented Mar 30, 2020

When this is made available, can you also please include the "optimistic" parameter in the fasltane rome plugin?
Many thanks for this!

@ollieatkinson
Copy link

Contributions are accepted @felipe-azevedo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants