@@ -14,6 +14,7 @@ import Registry.App.Prelude
1414
1515import Data.Array as Array
1616import Data.Array.NonEmpty as NonEmptyArray
17+ import Data.FoldableWithIndex (foldMapWithIndex )
1718import Data.Map as Map
1819import Data.Set as Set
1920import Data.Set.NonEmpty as NonEmptySet
@@ -187,9 +188,11 @@ solveForAllCompilers { compilerIndex, name, version, compiler, dependencies } =
187188 newJobs <- for compilers \target -> do
188189 Log .debug $ " Trying compiler " <> Version .print target <> " for package " <> PackageName .print name
189190 case Solver .solveWithCompiler (Range .exact target) compilerIndex dependencies of
190- Left _solverErrors -> do
191- Log .info $ " Failed to solve with compiler " <> Version .print target
192- -- Log.debug $ Solver.printSolverError solverErrors
191+ Left solverErrors -> do
192+ Log .info $ " Failed to solve with compiler " <> Version .print target <> " : " <> PackageName .print name <> " @" <> Version .print version
193+ Log .debug $ " Solver errors:\n " <> foldMapWithIndex
194+ (\i error -> " [Error " <> show (i + 1 ) <> " ]\n " <> Solver .printSolverError error <> " \n " )
195+ solverErrors
193196 pure Nothing
194197 Right (Tuple solvedCompiler resolutions) -> case solvedCompiler == target of
195198 true -> do
@@ -211,28 +214,37 @@ solveDependantsForCompiler { compilerIndex, name, version, compiler } = do
211214 manifestIndex <- Registry .readAllManifests
212215 let dependentManifests = ManifestIndex .dependants manifestIndex name version
213216 newJobs <- for dependentManifests \(Manifest manifest) -> do
214- -- we first verify if we have already attempted this package with this compiler,
215- -- either in the form of having it in the metadata already, or as a failed compilation
216- -- (i.e. if we find compilers in the metadata for this version we only check this one
217- -- if it's newer, because all the previous ones have been tried)
217+ -- We skip if this compiler is already in the package's metadata compilers
218+ -- list (meaning it was already successfully tested). Failed compilations
219+ -- are not recorded in metadata, but the DB deduplication in insertMatrixJob
220+ -- prevents re-enqueuing jobs that already exist.
218221 shouldAttemptToCompile <- Registry .readMetadata manifest.name >>= case _ of
219- Nothing -> pure false
220- Just metadata -> pure $ case Map .lookup version (un Metadata metadata).published of
221- Nothing -> false
222- Just { compilers } -> any (_ > compiler) compilers
222+ Nothing -> do
223+ Log .debug $ " Skipping " <> PackageName .print manifest.name <> " @" <> Version .print manifest.version <> " : no metadata found"
224+ pure false
225+ Just metadata -> do
226+ let
227+ result = case Map .lookup manifest.version (un Metadata metadata).published of
228+ Nothing -> false
229+ Just { compilers } -> all (_ /= compiler) compilers
230+ unless result do
231+ Log .debug $ " Skipping " <> PackageName .print manifest.name <> " @" <> Version .print manifest.version <> " : compiler " <> Version .print compiler <> " already tested or version not published"
232+ pure result
223233 case shouldAttemptToCompile of
224234 false -> pure Nothing
225235 true -> do
226236 -- if all good then run the solver
227237 Log .debug $ " Trying compiler " <> Version .print compiler <> " for package " <> PackageName .print manifest.name
228238 case Solver .solveWithCompiler (Range .exact compiler) compilerIndex manifest.dependencies of
229- Left _solverErrors -> do
230- Log .info $ " Failed to solve with compiler " <> Version .print compiler
231- -- Log.debug $ Solver.printSolverError solverErrors
239+ Left solverErrors -> do
240+ Log .info $ " Failed to solve with compiler " <> Version .print compiler <> " : " <> PackageName .print manifest.name <> " @" <> Version .print manifest.version
241+ Log .debug $ " Solver errors:\n " <> foldMapWithIndex
242+ (\i error -> " [Error " <> show (i + 1 ) <> " ]\n " <> Solver .printSolverError error <> " \n " )
243+ solverErrors
232244 pure Nothing
233245 Right (Tuple solvedCompiler resolutions) -> case compiler == solvedCompiler of
234246 true -> do
235- Log .debug $ " Solved with compiler " <> Version .print solvedCompiler
247+ Log .debug $ " Solved " <> PackageName .print manifest.name <> " @ " <> Version .print manifest.version <> " with compiler " <> Version .print solvedCompiler
236248 pure $ Just { compiler, resolutions, name: manifest.name, version: manifest.version }
237249 false -> do
238250 Log .debug $ Array .fold
0 commit comments