@@ -5,9 +5,11 @@ import Prelude
5
5
import Control.Monad.Except.Trans (ExceptT )
6
6
import Data.Argonaut.Core (Json )
7
7
import Data.Argonaut.Decode (decodeJson , printJsonDecodeError , (.:))
8
+ import Data.Array as Array
8
9
import Data.Bifunctor (lmap )
9
10
import Data.Either (Either (..))
10
11
import Data.Foldable (fold )
12
+ import Data.Maybe (Maybe (..))
11
13
import Data.Newtype (unwrap )
12
14
import Data.Traversable (traverse )
13
15
import Data.Version (Version )
@@ -29,33 +31,41 @@ type BuildPlan = Array { tool :: Tool, version :: Version }
29
31
30
32
-- | Construct the list of tools that sholud be downloaded and cached by the action
31
33
constructBuildPlan :: Json -> ExceptT Error Effect BuildPlan
32
- constructBuildPlan json = traverse (resolve json) Tool .allTools
34
+ constructBuildPlan json = map Array .catMaybes $ traverse (resolve json) Tool .allTools
33
35
34
36
-- | The parsed value of an input field that specifies a version
35
37
data VersionField = Latest | Exact Version
36
38
37
39
-- | 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 )
39
41
getVersionField key = do
40
42
value <- Core .getInput' (unwrap key)
41
43
case value of
42
- " latest" -> pure Latest
44
+ " " ->
45
+ pure Nothing
46
+ " latest" ->
47
+ pure (pure Latest )
43
48
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))
46
54
47
55
-- | Resolve the exact version to provide for a tool in the environment, based
48
56
-- | 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 } )
50
58
resolve versionsContents tool = do
51
59
let key = Key .fromTool tool
52
60
field <- getVersionField key
53
61
case field of
54
- Exact v -> liftEffect do
62
+ Nothing -> pure Nothing
63
+
64
+ Just (Exact v) -> liftEffect do
55
65
Core .info " Found exact version"
56
- pure { tool, version: v }
66
+ pure (pure { tool, version: v })
57
67
58
- Latest -> liftEffect do
68
+ Just Latest -> liftEffect do
59
69
Core .info $ fold [ " Fetching latest tag for " , Tool .name tool ]
60
70
61
71
let
@@ -67,5 +77,5 @@ resolve versionsContents tool = do
67
77
Core .setFailed $ fold [ " Unable to parse version: " , e ]
68
78
throwError $ error " Unable to complete fetching version."
69
79
70
- Right v ->
71
- pure { tool, version: v }
80
+ Right v -> do
81
+ pure (pure { tool, version: v })
0 commit comments