Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
Monorepo fossa test and fossa report fix (#290)
Browse files Browse the repository at this point in the history
* Support monorepo scans in `fossa test` and `fossa report`
* Make attribution report dependencies optional
  • Loading branch information
jssblck authored and meghfossa committed Jul 22, 2021
1 parent 74d6848 commit 64318f1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Spectrometer Changelog

## Unreleased

- Support `fossa test` and `fossa report` for monorepo projects ([#290](https://github.com/fossas/spectrometer/pull/290))

## v2.10.3

- Support ReleaseGroup configuration ([#283](https://github.com/fossas/spectrometer/pull/283))
Expand Down
18 changes: 18 additions & 0 deletions src/App/Fossa/API/BuildWait.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module App.Fossa.API.BuildWait (
waitForBuild,
waitForMonorepoScan,
waitForIssues,
waitForSherlockScan,
timeout,
Expand Down Expand Up @@ -47,6 +48,23 @@ waitForBuild apiOpts revision = do
sendIO $ threadDelay (pollDelaySeconds * 1_000_000)
waitForBuild apiOpts revision

-- | Wait for monorepo scan completion
waitForMonorepoScan ::
(Has Diagnostics sig m, Has (Lift IO) sig m, Has Logger sig m, Has StickyLogger sig m) =>
ApiOpts ->
ProjectRevision ->
m ()
waitForMonorepoScan apiOpts revision = do
Fossa.Organization orgId _ <- Fossa.getOrganization apiOpts
let locator = VPSCore.createLocator (projectName revision) orgId

logSticky' "[ Getting latest scan ID ]"
scan <- ScotlandYard.getLatestScan apiOpts locator (projectRevision revision)

logSticky' "[ Waiting for monorepo scan... ]"
waitForSherlockScan apiOpts locator (ScotlandYard.responseScanId scan)
pure ()

waitForIssues ::
(Has Diagnostics sig m, Has (Lift IO) sig m, Has Logger sig m) =>
ApiOpts ->
Expand Down
2 changes: 1 addition & 1 deletion src/App/Fossa/Report.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ reportMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds reportType overr

logSticky "[ Waiting for build completion... ]"

waitForBuild apiOpts revision
waitForBuild apiOpts revision <||> waitForMonorepoScan apiOpts revision

logSticky "[ Waiting for issue scan completion... ]"

Expand Down
4 changes: 2 additions & 2 deletions src/App/Fossa/Report/Attribution.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ instance FromJSON Attribution where
parseJSON = withObject "Attribution" $ \obj ->
Attribution
<$> obj .: "project"
<*> obj .: "directDependencies"
<*> obj .: "deepDependencies"
<*> obj .:? "directDependencies" .!= []
<*> obj .:? "deepDependencies" .!= []
<*> obj .: "licenses"

instance ToJSON Attribution where
Expand Down
2 changes: 1 addition & 1 deletion src/App/Fossa/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ testMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds outputType overrid

logSticky "[ Waiting for build completion... ]"

waitForBuild apiOpts revision
waitForBuild apiOpts revision <||> waitForMonorepoScan apiOpts revision

logSticky "[ Waiting for issue scan completion... ]"
issues <- waitForIssues apiOpts revision
Expand Down

0 comments on commit 64318f1

Please sign in to comment.