@@ -7,7 +7,7 @@ module User.Requester.Cli
7
7
, NewTestRunCreated (.. )
8
8
) where
9
9
10
- import Control.Monad (forM , forM_ , void )
10
+ import Control.Monad (void )
11
11
import Control.Monad.Trans.Class (lift )
12
12
import Core.Context
13
13
( WithContext
@@ -19,7 +19,6 @@ import Core.Context
19
19
import Core.Types.Basic
20
20
( Directory (.. )
21
21
, Duration
22
- , FileName (.. )
23
22
, Repository (.. )
24
23
, Success (.. )
25
24
, TokenId
@@ -30,9 +29,9 @@ import Core.Types.Operation (Operation (..))
30
29
import Core.Types.Tx (TxHash , WithTxHash (.. ))
31
30
import Core.Types.Wallet (Wallet )
32
31
import Crypto.PubKey.Ed25519 (Signature )
33
- import Data.Bifunctor (Bifunctor (.. ))
34
32
import Data.ByteString.Lazy qualified as BL
35
33
import Data.Functor (($>) )
34
+ import Lib.GitHub (GetGithubFileFailure )
36
35
import Lib.JSON.Canonical.Extra (object , (.=) )
37
36
import Lib.SSH.Private
38
37
( KeyPair (.. )
@@ -66,9 +65,7 @@ import Oracle.Validate.Types
66
65
( AValidationResult
67
66
, ForRole (.. )
68
67
, liftMaybe
69
- , mapFailure
70
68
, runValidate
71
- , sequenceValidate
72
69
, throwLeft
73
70
)
74
71
import Submitting (Submission (.. ))
@@ -82,21 +79,6 @@ import User.Types
82
79
, TestRunState (.. )
83
80
)
84
81
import Validation (Validation (.. ), hoistValidation )
85
- import Validation.DownloadFile (DownloadedFileFailure )
86
-
87
- newtype GenerateAssetsFailure
88
- = GenerateAssetsFailure [(FileName , DownloadedFileFailure )]
89
-
90
- instance Monad m => ToJSON m GenerateAssetsFailure where
91
- toJSON (GenerateAssetsFailure failures) =
92
- object
93
- [
94
- ( " generateAssetsFailure"
95
- , mapM
96
- (\ (FileName fn, err) -> object [" file" .= fn, " error" .= err])
97
- failures
98
- )
99
- ]
100
82
101
83
data RequesterCommand a where
102
84
RegisterUser
@@ -134,7 +116,7 @@ data RequesterCommand a where
134
116
:: Directory
135
117
-> RequesterCommand
136
118
( AValidationResult
137
- GenerateAssetsFailure
119
+ GetGithubFileFailure
138
120
Success
139
121
)
140
122
@@ -167,25 +149,20 @@ requesterCmd command = do
167
149
generateAssets
168
150
:: Monad m
169
151
=> Directory
170
- -> WithContext m (AValidationResult GenerateAssetsFailure Success )
152
+ -> WithContext m (AValidationResult GetGithubFileFailure Success )
171
153
generateAssets (Directory targetDirectory) = do
172
- Validation {githubGetFile, writeTextFile} <- askValidation Nothing
173
- lift $ runValidate $ do
174
- downloads <- forM [" docker-compose.yaml" , " README.md" , " testnet.yaml" ] $ \ filename -> do
175
- fmap (bimap (FileName filename,) (filename,))
176
- $ lift
177
- $ githubGetFile
178
- (Repository " cardano-foundation" " antithesis" )
179
- Nothing
180
- (FileName $ " compose/testnets/cardano_node_master/" <> filename)
181
- contents <-
182
- mapFailure GenerateAssetsFailure
183
- $ sequenceValidate
184
- $ fmap (throwLeft id ) downloads
185
- forM_ contents $ \ (filename, content) -> do
186
- let filePath = targetDirectory <> " /" <> filename
187
- lift $ writeTextFile filePath content
188
- pure Success
154
+ Validation {githubDownloadDirectory} <- askValidation Nothing
155
+ lift
156
+ $ runValidate
157
+ $ do
158
+ r <-
159
+ lift
160
+ $ githubDownloadDirectory
161
+ (Repository " cardano-foundation" " antithesis" )
162
+ Nothing
163
+ (Directory " compose/testnet/cardano_node_master" )
164
+ (Directory targetDirectory)
165
+ throwLeft id r $> Success
189
166
190
167
signKey
191
168
:: (ToJSON m key , Monad m ) => KeyPair -> key -> m (JSValue , Signature )
0 commit comments