@@ -6,16 +6,115 @@ import Control.Monad.Except.Trans (runExceptT)
6
6
import Data.Either (Either (..))
7
7
import Data.Maybe (Maybe (..))
8
8
import Effect (Effect )
9
+ import Effect.Aff (launchAff_ , runAff_ )
10
+ import Effect.Class (liftEffect )
9
11
import Effect.Exception (message )
12
+ import GitHub.Actions.Cache as Cache
10
13
import GitHub.Actions.Core as Core
14
+ import GitHub.Actions.Exec as Exec
15
+ import GitHub.Actions.IO as IO
11
16
import GitHub.Actions.ToolCache as ToolCache
12
17
13
18
main :: Effect Unit
14
19
main = do
15
20
Core .info " Starting test action..."
21
+
22
+ -- Tests for GitHub.Actions.Core
23
+ Core .exportVariable { key: " testkey" , value: " test" }
24
+ Core .setOutput { name: " testoutput" , value: " test" }
25
+ Core .setSecret " testoutput"
26
+ Core .addPath " /test/path"
27
+ resultCore <- runExceptT do
28
+ _ <- Core .getInput' " testinput"
29
+ _ <- Core .getInput { name: " testinput" , options: Nothing }
30
+ Core .getInput { name: " testinput" , options: Just { required: true } }
31
+ case resultCore of
32
+ Left err -> Core .setFailed (message err)
33
+ Right _ -> Core .info " No errors in GitHub.Actions.Core ExceptT functions"
34
+ Core .setCommandEcho false
35
+ _ <- Core .isDebug
36
+ Core .debug " Testing debug"
37
+ Core .error " Testing error"
38
+ Core .warning " Testing warning"
39
+ Core .info " Testing info"
40
+ Core .startGroup " testgroup"
41
+ Core .endGroup
42
+ Core .saveState { name: " teststate" , value: " test" }
43
+ _ <- Core .getState " teststate"
44
+ launchAff_ $ Core .group
45
+ { name: " testGroup"
46
+ , fn: liftEffect (Core .info " In testGroup" )
47
+ }
48
+
49
+ -- Tests for GitHub.Actions.Cache
50
+ let
51
+ cacheCb = case _ of
52
+ Left err -> Core .setFailed (message err)
53
+ Right _ -> Core .info " No errors in restoreCache"
54
+ runAff_ cacheCb $ runExceptT do
55
+ _ <- Cache .saveCache' { paths: [] , key: " restorecache" }
56
+ _ <- Cache .saveCache { paths: [] , key: " restorecache" , options: Nothing }
57
+ _ <- Cache .saveCache { paths: [] , key: " restorecache" , options: Just (Cache .defaultUploadOptions { uploadConcurrency = Just 10.0 }) }
58
+ _ <- Cache .restoreCache' { paths: [] , primaryKey: " restorecache" }
59
+ _ <- Cache .restoreCache { paths: [] , primaryKey: " restorecache" , restoreKeys: Nothing , options: Nothing }
60
+ _ <- Cache .restoreCache { paths: [] , primaryKey: " restorecache" , restoreKeys: Just [ " a" ], options: Nothing }
61
+ Cache .restoreCache { paths: [] , primaryKey: " restorecaceh" , restoreKeys: Just [ " a" ], options: Just (Cache .defaultDownloadOptions { useAzureSdk = Just true , downloadConcurrency = Just true , timeoutInMs = Just 10.0 })}
62
+
63
+ -- Tests for GitHub.Actions.Exec
64
+ let
65
+ execCb = case _ of
66
+ Left err -> Core .setFailed (message err)
67
+ Right _ -> Core .info " No errors in exec"
68
+ runAff_ execCb $ runExceptT do
69
+ _ <- Exec .exec' " pwd"
70
+ _ <- Exec .exec { command: " pwd" , args: Just [ " -L" ], options: Nothing }
71
+ Exec .exec { command: " pwd" , args: Just [ " -L" ], options: Just (Exec .defaultExecOptions { delay = Just 10.0 })}
72
+
73
+ -- Tests for GitHub.Actions.IO
74
+ let
75
+ ioCb = case _ of
76
+ Left err -> Core .setFailed (message err)
77
+ Right _ -> Core .info " No errors in io"
78
+ runAff_ ioCb $ runExceptT do
79
+ _ <- Exec .exec' " touch test.txt"
80
+ _ <- IO .cp' { source: " test.txt" , dest: " test1.txt" }
81
+ _ <- IO .cp { source: " test1.txt" , dest: " test2.txt" , options: Just (IO .defaultCopyOptions { force = Just true })}
82
+ _ <- IO .mv' { source: " test2.txt" , dest: " test3.txt" }
83
+ _ <- IO .mv { source: " test3.txt" , dest: " test4.txt" , options: Just (IO .defaultMoveOptions { force = Just true }) }
84
+ _ <- IO .rmRF { inputPath: " test4.txt" }
85
+ _ <- IO .mkdirP { fsPath: " testDir" }
86
+ _ <- IO .which' " purs"
87
+ IO .which { tool: " purs" , check: Just true }
88
+
89
+ -- Tests for GitHub.Actions.ToolCache
90
+ let
91
+ toolCacheCb = case _ of
92
+ Left err -> Core .setFailed (message err)
93
+ Right _ -> Core .info " No errors in ToolCache"
94
+ runAff_ toolCacheCb $ runExceptT do
95
+ pursPath <- ToolCache .downloadTool' " https://github.com/purescript/purescript/releases/download/v0.13.8/linux64.tar.gz"
96
+ _ <- ToolCache .downloadTool { url: " https://github.com/purescript/purescript/releases/download/v0.13.8/linux64.tar.gz" , dest: Just " ~/purspath" , auth: Nothing }
97
+ _ <- ToolCache .downloadTool { url: " https://github.com/purescript/purescript/releases/download/v0.13.8/linux64.tar.gz" , dest: Just " ~/purspath" , auth: Just " blahhh" }
98
+ extractedPurs <- ToolCache .extractTar' pursPath
99
+ _ <- ToolCache .extractTar { file: pursPath, dest: Just " /extractedpurs" , flags: Nothing }
100
+ _ <- ToolCache .extractTar { file: pursPath, dest: Just " /extractedpurs" , flags: Just [] }
101
+ zipPath <- ToolCache .downloadTool' " https://github.com/purescript/purescript/archive/v0.13.8.zip"
102
+ _ <- ToolCache .extractZip' zipPath
103
+ _ <- ToolCache .extractZip { file: zipPath, dest: Just " /extractedpurszip" }
104
+ _ <- ToolCache .cacheDir' { sourceDir: extractedPurs, tool: " purs" , version: " v0.13.8" }
105
+ _ <- ToolCache .cacheDir { sourceDir: extractedPurs, tool: " purs" , version: " v0.13.8" , arch: Just " arm" }
106
+ _ <- ToolCache .cacheFile' { sourceFile: pursPath, targetFile: " testtarget" , tool: " purs" , version: " v0.13.8" }
107
+ _ <- ToolCache .cacheFile { sourceFile: pursPath, targetFile: " testtarget" , tool: " purs" , version: " v0.13.8" , arch: Just " arm" }
108
+ pursManifest <- ToolCache .getManifestFromRepo' { owner: " purescript" , repo: " purescript" }
109
+ _ <- ToolCache .getManifestFromRepo { owner: " purescript" , repo: " purescript" , auth: Just " blah" , branch: Just " master" }
110
+ _ <- ToolCache .findFromManifest { versionSpec: " v0.13.8" , stable: true , manifest: pursManifest, archFilter: Nothing }
111
+ ToolCache .findFromManifest { versionSpec: " v0.13.8" , stable: true , manifest: pursManifest, archFilter: Just " arm" }
112
+
16
113
result <- runExceptT do
17
114
_ <- ToolCache .find' { toolName: " my-tool" , versionSpec: " 12.x" }
18
- ToolCache .find { toolName: " my-tool" , versionSpec: " 12.x" , arch: Just " armv6" }
115
+ _ <- ToolCache .find { toolName: " my-tool" , versionSpec: " 12.x" , arch: Just " armv6" }
116
+ _ <- ToolCache .findAllVersions' " purs"
117
+ ToolCache .findAllVersions { toolName: " purs" , arch: Just " arm" }
19
118
case result of
20
119
Left err -> Core .setFailed (message err)
21
120
Right _ -> Core .info " No errors in find"
0 commit comments