@@ -5,9 +5,11 @@ import Prelude
55import Control.Monad.Except.Trans (ExceptT )
66import Data.Argonaut.Core (Json )
77import Data.Argonaut.Decode (decodeJson , printJsonDecodeError , (.:))
8+ import Data.Array as Array
89import Data.Bifunctor (lmap )
910import Data.Either (Either (..))
1011import Data.Foldable (fold )
12+ import Data.Maybe (Maybe (..))
1113import Data.Newtype (unwrap )
1214import Data.Traversable (traverse )
1315import Data.Version (Version )
@@ -29,33 +31,41 @@ type BuildPlan = Array { tool :: Tool, version :: Version }
2931
3032-- | Construct the list of tools that sholud be downloaded and cached by the action
3133constructBuildPlan :: Json -> ExceptT Error Effect BuildPlan
32- constructBuildPlan json = traverse (resolve json) Tool .allTools
34+ constructBuildPlan json = map Array .catMaybes $ traverse (resolve json) Tool .allTools
3335
3436-- | The parsed value of an input field that specifies a version
3537data VersionField = Latest | Exact Version
3638
3739-- | Attempt to read the value of an input specifying a tool version
38- getVersionField :: Key -> ExceptT Error Effect VersionField
40+ getVersionField :: Key -> ExceptT Error Effect ( Maybe VersionField )
3941getVersionField key = do
4042 value <- Core .getInput' (unwrap key)
4143 case value of
42- " latest" -> pure Latest
44+ " " ->
45+ pure Nothing
46+ " latest" ->
47+ pure (pure Latest )
4348 val -> case Version .parseVersion val of
44- Left msg -> throwError (error (ParseError .parseErrorMessage msg))
45- Right version -> pure (Exact version)
49+ Left msg -> do
50+ liftEffect $ Core .error $ fold [ " Failed to parse version " , val ]
51+ throwError (error (ParseError .parseErrorMessage msg))
52+ Right version ->
53+ pure (pure (Exact version))
4654
4755-- | Resolve the exact version to provide for a tool in the environment, based
4856-- | on the action.yml file.
49- resolve :: Json -> Tool -> ExceptT Error Effect { tool :: Tool , version :: Version }
57+ resolve :: Json -> Tool -> ExceptT Error Effect ( Maybe { tool :: Tool , version :: Version } )
5058resolve versionsContents tool = do
5159 let key = Key .fromTool tool
5260 field <- getVersionField key
5361 case field of
54- Exact v -> liftEffect do
62+ Nothing -> pure Nothing
63+
64+ Just (Exact v) -> liftEffect do
5565 Core .info " Found exact version"
56- pure { tool, version: v }
66+ pure (pure { tool, version: v })
5767
58- Latest -> liftEffect do
68+ Just Latest -> liftEffect do
5969 Core .info $ fold [ " Fetching latest tag for " , Tool .name tool ]
6070
6171 let
@@ -67,5 +77,5 @@ resolve versionsContents tool = do
6777 Core .setFailed $ fold [ " Unable to parse version: " , e ]
6878 throwError $ error " Unable to complete fetching version."
6979
70- Right v ->
71- pure { tool, version: v }
80+ Right v -> do
81+ pure (pure { tool, version: v })
0 commit comments