Skip to content

Commit b9fc1a4

Browse files
committed
[cli] feat: add anti agent collect-all-results command
1 parent d1bfc3b commit b9fc1a4

File tree

3 files changed

+66
-30
lines changed

3 files changed

+66
-30
lines changed

cli/docs/antithesis-agent-role.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export ANTI_AGENT_EMAIL="<your-email>"
9494
Then you can check for the completion of a test-run via
9595

9696
```bash
97-
anti agent collect-email-results --days <n> --ask-agent-email-password
97+
anti agent collect-results-for --test-run-id <test-run-id> --days <n> --ask-agent-email-password
9898
```
9999

100100
> HAL Team

cli/src/User/Agent/Cli.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import Core.Types.Tx (WithTxHash (..))
4747
import Core.Types.Wallet (Wallet (..))
4848
import Data.ByteString.Base64 qualified as Base64
4949
import Data.ByteString.Char8 qualified as B8
50+
import Data.Either (rights)
5051
import Data.Function ((&))
5152
import Data.Functor (($>), (<&>))
5253
import Data.Functor.Identity (Identity (..))
@@ -239,6 +240,15 @@ agentCmd = \case
239240
Left err -> notValidated $ CheckResultsEmail err
240241
Right Nothing -> notValidated $ CheckResultsNoEmailsFor key
241242
Right (Just result) -> pure result
243+
CheckAllResults emailUser emailPassword days -> runValidate $ do
244+
r <-
245+
liftIO
246+
$ runExceptT
247+
$ readEmails emailUser emailPassword days
248+
& S.toList_
249+
case r of
250+
Left err -> notValidated $ CheckResultsEmail err
251+
Right results -> pure $ rights results
242252

243253
data IsReady = NotReady | Ready
244254
deriving (Show, Eq)
@@ -357,6 +367,12 @@ data AgentCommand (phase :: IsReady) result where
357367
-> Int
358368
-- ^ limit to last N days
359369
-> AgentCommand phase (AValidationResult CheckResultsFailure Result)
370+
CheckAllResults
371+
:: EmailUser
372+
-> EmailPassword
373+
-> Int
374+
-- ^ limit to last N days
375+
-> AgentCommand phase (AValidationResult CheckResultsFailure [Result])
360376
PushTest
361377
:: TokenId
362378
-> Registry

cli/src/User/Agent/Options.hs

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,44 @@ agentCommandParser =
8989
$ Box <$> downloadAssetsOptions
9090
, command "push-test" "Push a test run to Antithesis"
9191
$ Box <$> pushTestOptions
92-
, command "collect-email-results" "Collect test results from email"
92+
, command "collect-results-for" "Collect test results from email"
9393
$ Box <$> emailResultsOptions
94+
, command "collect-all-results" "Collect all test results from email"
95+
$ Box <$> emailAllResultsOptions
96+
]
97+
98+
agentEmailOption :: Parser EmailUser
99+
agentEmailOption =
100+
EmailUser
101+
<$> setting
102+
[ env "ANTI_AGENT_EMAIL"
103+
, metavar "EMAIL"
104+
, help "The agent email to access the results mailbox"
105+
, reader str
106+
, long "email-user"
107+
, option
108+
]
109+
agentEmailPasswordOption :: Parser EmailPassword
110+
agentEmailPasswordOption =
111+
EmailPassword
112+
<$> secretsParser
113+
"Enter the agent email password to access the mailbox"
114+
"The agent email password to access the mailbox"
115+
"ANTI_AGENT_EMAIL_PASSWORD"
116+
"EMAIL_PASSWORD"
117+
"ask-agent-email-password"
118+
"agentEmailPassword"
119+
120+
daysOption :: Parser Int
121+
daysOption =
122+
setting
123+
[ long "days"
124+
, help
125+
"Number of days in the past to check for test results (default: 7)"
126+
, metavar "DAYS"
127+
, reader auto
128+
, value 7
129+
, option
94130
]
95131

96132
emailResultsOptions
@@ -99,35 +135,19 @@ emailResultsOptions
99135
emailResultsOptions =
100136
CheckResultFor
101137
<$> tokenIdOption
102-
<*> ( EmailUser
103-
<$> setting
104-
[ env "ANTI_AGENT_EMAIL"
105-
, metavar "EMAIL"
106-
, help "The agent email to access the results mailbox"
107-
, reader str
108-
, long "email-user"
109-
, option
110-
]
111-
)
112-
<*> ( EmailPassword
113-
<$> secretsParser
114-
"Enter the agent email password to access the mailbox"
115-
"The agent email password to access the mailbox"
116-
"ANTI_AGENT_EMAIL_PASSWORD"
117-
"EMAIL_PASSWORD"
118-
"ask-agent-email-password"
119-
"agentEmailPassword"
120-
)
138+
<*> agentEmailOption
139+
<*> agentEmailPasswordOption
121140
<*> testRunIdOption "check results for"
122-
<*> setting
123-
[ long "days"
124-
, help
125-
"Number of days in the past to check for test results (default: 7)"
126-
, metavar "DAYS"
127-
, reader auto
128-
, value 7
129-
, option
130-
]
141+
<*> daysOption
142+
143+
emailAllResultsOptions
144+
:: Parser
145+
(AgentCommand NotReady (AValidationResult CheckResultsFailure [Result]))
146+
emailAllResultsOptions =
147+
CheckAllResults
148+
<$> agentEmailOption
149+
<*> agentEmailPasswordOption
150+
<*> daysOption
131151

132152
pushTestOptions
133153
:: Parser

0 commit comments

Comments
 (0)