Skip to content

Commit cb4760e

Browse files
Add extra debug statements and fix build plan (#15)
1 parent 3565bfc commit cb4760e

File tree

7 files changed

+31
-16
lines changed

7 files changed

+31
-16
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/update.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"purs":"0.13.8","spago":"0.16.0","psa":"0.8.0","purty":"6.2.0","zephyr":"0.3.2"}
1+
{"purs":"0.13.8","spago":"0.16.0","psa":"0.8.0","purty":"6.2.0","zephyr":"0.3.2"}

spago.dhall

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
, "argonaut-codecs"
88
, "argonaut-core"
99
, "console"
10+
, "debug"
1011
, "effect"
1112
, "github-actions-toolkit"
13+
, "monad-loops"
1214
, "node-fs"
1315
, "node-path"
1416
, "node-process"
1517
, "nullable"
1618
, "psci-support"
1719
, "record"
1820
, "versions"
19-
, "monad-loops"
2021
]
2122
, packages = ./packages.dhall
22-
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
23+
, sources = [ "src/**/*.purs" ]
2324
}

src/Main.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import Setup.UpdateVersions (updateVersions)
1818
main :: Json -> Effect Unit
1919
main json = runAff_ go $ runExceptT do
2020
tools <- mapExceptT liftEffect $ constructBuildPlan json
21+
liftEffect $ Core.info "Constructed build plan."
2122
traverse_ getTool tools
23+
liftEffect $ Core.info "Fetched tools."
2224
where
2325
go res = case join res of
2426
Left err -> Core.setFailed (message err)

src/Setup/BuildPlan.purs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import Prelude
55
import Control.Monad.Except.Trans (ExceptT)
66
import Data.Argonaut.Core (Json)
77
import Data.Argonaut.Decode (decodeJson, printJsonDecodeError, (.:))
8+
import Data.Array as Array
89
import Data.Bifunctor (lmap)
910
import Data.Either (Either(..))
1011
import Data.Foldable (fold)
12+
import Data.Maybe (Maybe(..))
1113
import Data.Newtype (unwrap)
1214
import Data.Traversable (traverse)
1315
import 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
3133
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
3335

3436
-- | The parsed value of an input field that specifies a version
3537
data 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)
3941
getVersionField 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 })
5058
resolve 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 })

src/Setup/GetTool.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ getTool { tool, version } = do
2323
name = Tool.name tool
2424
installMethod = Tool.installMethod tool version
2525

26+
liftEffect $ Core.info $ fold [ "Fetching ", name ]
27+
2628
case installMethod of
2729
Tarball opts -> do
2830
mbPath <- mapExceptT liftEffect $ ToolCache.find { arch: Nothing, toolName: name, versionSpec: Version.showVersion version }

0 commit comments

Comments
 (0)