diff --git a/Changelog.md b/Changelog.md index 5ac1bccaf..3e1636ec9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,14 +1,21 @@ # Spectrometer Changelog +## v2.10.1 + +- Fixes an issue where `fossa container analyze` returned 0 exit code on failure ([#275](https://github.com/fossas/spectrometer/pull/275)) + ## v2.10.0 + - Adds support for short flags to mirror CLI v1 commands ([#264](https://github.com/fossas/spectrometer/pull/264)) - Added a `remote-dependencies` section in the `fossa-deps` file to support archives at remote locations ([#260](https://github.com/fossas/spectrometer/pull/260)) - Modify the payload for `custom-dependencies` to include optional fields in a new `metadata` section ([#260](https://github.com/fossas/spectrometer/pull/260)) ## v2.9.2 + - Adds JSON-formatted project information to the output of `fossa analyze` with `--json` ([#255](https://github.com/fossas/spectrometer/pull/255)) ## v2.9.1 + - Bump wiggins - Updated vps aosp-notice-file subcommand to upload ninja files & trigger async task. ([#272](https://github.com/fossas/spectrometer/pull/272)) ## v2.9.0 diff --git a/src/App/Fossa/Container/Analyze.hs b/src/App/Fossa/Container/Analyze.hs index 6a8607a32..01b0bed28 100644 --- a/src/App/Fossa/Container/Analyze.hs +++ b/src/App/Fossa/Container/Analyze.hs @@ -7,14 +7,10 @@ import App.Fossa.Analyze (ScanDestination (..)) import App.Fossa.Container (ImageText (..), extractRevision, runSyft, toContainerScan) import App.Fossa.FossaAPIV1 (UploadResponse (uploadError, uploadLocator), uploadContainerScan) import App.Types (OverrideProject (..), ProjectRevision (..)) -import Control.Carrier.Diagnostics ( - Diagnostics, - renderFailureBundle, - runDiagnostics, - ) +import Control.Carrier.Diagnostics (Diagnostics, logWithExit_) import Control.Effect.Lift (Lift) import Control.Monad.IO.Class (MonadIO) -import Data.Aeson +import Data.Aeson (encode) import Data.Foldable (traverse_) import Data.Maybe (fromMaybe) import Data.String.Conversion (decodeUtf8) @@ -23,10 +19,7 @@ import Srclib.Types (parseLocator) analyzeMain :: ScanDestination -> Severity -> OverrideProject -> ImageText -> IO () analyzeMain scanDestination logSeverity override image = withDefaultLogger logSeverity $ do - result <- runDiagnostics $ analyze scanDestination override image - case result of - Left err -> logError (renderFailureBundle err) - Right _ -> pure () + logWithExit_ $ analyze scanDestination override image analyze :: ( Has Diagnostics sig m diff --git a/src/App/Fossa/Report.hs b/src/App/Fossa/Report.hs index 9ed7f1875..07824e449 100644 --- a/src/App/Fossa/Report.hs +++ b/src/App/Fossa/Report.hs @@ -9,7 +9,6 @@ import App.Fossa.ProjectInference import App.Types import Control.Carrier.Diagnostics import Control.Carrier.StickyLogger (logSticky, runStickyLogger) -import Control.Effect.Lift (sendIO) import Data.Aeson qualified as Aeson import Data.Functor (void) import Data.String.Conversion (decodeUtf8) @@ -18,7 +17,7 @@ import Data.Text.IO (hPutStrLn) import Effect.Logger import Effect.ReadFS import Fossa.API.Types (ApiOpts) -import System.Exit (exitFailure, exitSuccess) +import System.Exit (exitFailure) import System.IO (stderr) data ReportType @@ -50,8 +49,8 @@ reportMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds reportType overr * Timeout over `IO a` (easy to move, but where do we move it?) * CLI command refactoring as laid out in https://github.com/fossas/issues/issues/129 -} - void . timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ do - result <- runDiagnostics . runReadFSIO $ do + void . timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ + logWithExit_ . runReadFSIO $ do revision <- mergeOverride override <$> (inferProjectFromVCS basedir <||> inferProjectCached basedir <||> inferProjectDefault basedir) logInfo "" @@ -74,11 +73,5 @@ reportMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds reportType overr logStdout . decodeUtf8 $ Aeson.encode jsonValue - case result of - Left err -> do - logError $ renderFailureBundle err - sendIO exitFailure - Right _ -> sendIO exitSuccess - hPutStrLn stderr "Timed out while waiting for build/issues scan" exitFailure diff --git a/src/App/Fossa/Test.hs b/src/App/Fossa/Test.hs index 56414327b..438ff2b12 100644 --- a/src/App/Fossa/Test.hs +++ b/src/App/Fossa/Test.hs @@ -16,7 +16,7 @@ import Data.Text.IO (hPutStrLn) import Effect.Logger import Effect.ReadFS import Fossa.API.Types (ApiOpts, Issues (..)) -import System.Exit (exitFailure, exitSuccess) +import System.Exit (exitFailure) import System.IO (stderr) data TestOutputType @@ -35,8 +35,8 @@ testMain :: OverrideProject -> IO () testMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds outputType override = do - void . timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ do - result <- runDiagnostics . runReadFSIO $ do + void . timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ + logWithExit_ . runReadFSIO $ do revision <- mergeOverride override <$> (inferProjectFromVCS basedir <||> inferProjectCached basedir <||> inferProjectDefault basedir) logInfo "" @@ -64,12 +64,6 @@ testMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds outputType overrid sendIO exitFailure - case result of - Left failure -> do - logError $ renderFailureBundle failure - sendIO exitFailure - Right _ -> sendIO exitSuccess - -- we call exitSuccess/exitFailure in each branch above. the only way we get -- here is if we time out hPutStrLn stderr "Timed out while waiting for issues scan" diff --git a/src/App/Fossa/VPS/Report.hs b/src/App/Fossa/VPS/Report.hs index 5ea79e0dd..73c31d7c4 100644 --- a/src/App/Fossa/VPS/Report.hs +++ b/src/App/Fossa/VPS/Report.hs @@ -11,7 +11,6 @@ import App.Fossa.VPS.Scan.ScotlandYard qualified as ScotlandYard import App.Types import Control.Carrier.Diagnostics import Control.Carrier.StickyLogger (logSticky, runStickyLogger) -import Control.Effect.Lift (sendIO) import Data.Aeson qualified as Aeson import Data.Functor (void) import Data.String.Conversion (decodeUtf8) @@ -20,7 +19,7 @@ import Data.Text.IO (hPutStrLn) import Effect.Logger import Effect.ReadFS import Fossa.API.Types (ApiOpts) -import System.Exit (exitFailure, exitSuccess) +import System.Exit (exitFailure) import System.IO (stderr) data ReportType @@ -52,8 +51,8 @@ reportMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds reportType overr * Timeout over `IO a` (easy to move, but where do we move it?) * CLI command refactoring as laid out in https://github.com/fossas/issues/issues/129 -} - void . timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ do - result <- runDiagnostics . runReadFSIO $ do + void . timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ + logWithExit_ . runReadFSIO $ do revision <- mergeOverride override <$> (inferProjectFromVCS basedir <||> inferProjectCached basedir <||> inferProjectDefault basedir) logSticky "[ Getting latest scan ID ]" @@ -77,11 +76,5 @@ reportMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds reportType overr logStdout . decodeUtf8 $ Aeson.encode jsonValue - case result of - Left err -> do - logError $ renderFailureBundle err - sendIO exitFailure - Right _ -> sendIO exitSuccess - hPutStrLn stderr "Timed out while waiting for build/issues scan" exitFailure diff --git a/src/App/Fossa/VPS/Test.hs b/src/App/Fossa/VPS/Test.hs index ca7bd4046..ef632c32f 100644 --- a/src/App/Fossa/VPS/Test.hs +++ b/src/App/Fossa/VPS/Test.hs @@ -18,7 +18,7 @@ import Data.Text.IO (hPutStrLn) import Effect.Logger import Effect.ReadFS import Fossa.API.Types (ApiOpts, Issues (..)) -import System.Exit (exitFailure, exitSuccess) +import System.Exit (exitFailure) import System.IO (stderr) data TestOutputType @@ -37,8 +37,8 @@ testMain :: OverrideProject -> IO () testMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds outputType override = do - _ <- timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ do - result <- runDiagnostics . runReadFSIO $ do + _ <- timeout timeoutSeconds . withDefaultLogger logSeverity . runStickyLogger SevInfo $ + logWithExit_ . runReadFSIO $ do revision <- mergeOverride override <$> (inferProjectFromVCS basedir <||> inferProjectCached basedir <||> inferProjectDefault basedir) logInfo "" @@ -71,12 +71,6 @@ testMain (BaseDir basedir) apiOpts logSeverity timeoutSeconds outputType overrid TestOutputJson -> logStdout . decodeUtf8 . Aeson.encode $ issues sendIO exitFailure - case result of - Left failure -> do - logError $ renderFailureBundle failure - sendIO exitFailure - Right _ -> sendIO exitSuccess - -- we call exitSuccess/exitFailure in each branch above. the only way we get -- here is if we time out hPutStrLn stderr "Timed out while waiting for issues scan"