forked from filipg/gonito
info on triggering
This commit is contained in:
parent
e32a9e3aa5
commit
cf860889d7
@ -357,3 +357,8 @@ nonceGen = unsafePerformIO Nonce.new
|
|||||||
-- | Randomly create a new verification key.
|
-- | Randomly create a new verification key.
|
||||||
newToken :: MonadIO m => m Text
|
newToken :: MonadIO m => m Text
|
||||||
newToken = Nonce.nonce128urlT nonceGen
|
newToken = Nonce.nonce128urlT nonceGen
|
||||||
|
|
||||||
|
enableTriggerToken _ (Just _) = return ()
|
||||||
|
enableTriggerToken userId Nothing = do
|
||||||
|
token <- newToken
|
||||||
|
runDB $ update userId [UserTriggerToken =. Just token]
|
||||||
|
@ -75,6 +75,16 @@ getChallengeHowToR :: Text -> Handler Html
|
|||||||
getChallengeHowToR name = do
|
getChallengeHowToR name = do
|
||||||
(Entity _ challenge) <- runDB $ getBy404 $ UniqueName name
|
(Entity _ challenge) <- runDB $ getBy404 $ UniqueName name
|
||||||
maybeUser <- maybeAuth
|
maybeUser <- maybeAuth
|
||||||
|
|
||||||
|
case maybeUser of
|
||||||
|
Just (Entity userId user) -> do
|
||||||
|
enableTriggerToken userId (userTriggerToken user)
|
||||||
|
Nothing -> return ()
|
||||||
|
|
||||||
|
let mToken = case maybeUser of
|
||||||
|
Just (Entity _ user) -> userTriggerToken user
|
||||||
|
Nothing -> Nothing
|
||||||
|
|
||||||
let isIDSet = case maybeUser of
|
let isIDSet = case maybeUser of
|
||||||
Just (Entity _ user) -> isJust $ userLocalId user
|
Just (Entity _ user) -> isJust $ userLocalId user
|
||||||
Nothing -> False
|
Nothing -> False
|
||||||
@ -83,7 +93,7 @@ getChallengeHowToR name = do
|
|||||||
keys <- runDB $ selectList [PublicKeyUser ==. userId] []
|
keys <- runDB $ selectList [PublicKeyUser ==. userId] []
|
||||||
return $ not (null keys)
|
return $ not (null keys)
|
||||||
Nothing -> return False
|
Nothing -> return False
|
||||||
challengeLayout False challenge (challengeHowTo challenge (idToBeShown challenge maybeUser) isIDSet isSSHUploaded)
|
challengeLayout False challenge (challengeHowTo challenge (idToBeShown challenge maybeUser) isIDSet isSSHUploaded mToken)
|
||||||
|
|
||||||
idToBeShown challenge maybeUser =
|
idToBeShown challenge maybeUser =
|
||||||
case maybeUser of
|
case maybeUser of
|
||||||
@ -95,7 +105,7 @@ idToBeShown challenge maybeUser =
|
|||||||
|
|
||||||
defaultRepo challenge maybeUser = "ssh://gitolite@gonito.net/" ++ (idToBeShown challenge maybeUser) ++ "/" ++ (challengeName challenge)
|
defaultRepo challenge maybeUser = "ssh://gitolite@gonito.net/" ++ (idToBeShown challenge maybeUser) ++ "/" ++ (challengeName challenge)
|
||||||
|
|
||||||
challengeHowTo challenge idToBeShown isIDSet isSSHUploaded = $(widgetFile "challenge-how-to")
|
challengeHowTo challenge idToBeShown isIDSet isSSHUploaded mToken = $(widgetFile "challenge-how-to")
|
||||||
|
|
||||||
getChallengeSubmissionR :: Text -> Handler Html
|
getChallengeSubmissionR :: Text -> Handler Html
|
||||||
getChallengeSubmissionR name = do
|
getChallengeSubmissionR name = do
|
||||||
|
@ -50,12 +50,6 @@ postYourAccountR = do
|
|||||||
setTitle "Your account"
|
setTitle "Your account"
|
||||||
$(widgetFile "your-account")
|
$(widgetFile "your-account")
|
||||||
|
|
||||||
|
|
||||||
enableTriggerToken _ (Just _) = return ()
|
|
||||||
enableTriggerToken userId Nothing = do
|
|
||||||
token <- newToken
|
|
||||||
runDB $ update userId [UserTriggerToken =. Just token]
|
|
||||||
|
|
||||||
checkPassword :: Maybe Text -> Bool
|
checkPassword :: Maybe Text -> Bool
|
||||||
checkPassword Nothing = True
|
checkPassword Nothing = True
|
||||||
checkPassword (Just "") = True
|
checkPassword (Just "") = True
|
||||||
|
@ -47,9 +47,9 @@ $if not isIDSet || not isSSHUploaded
|
|||||||
cd #{challengeName challenge}
|
cd #{challengeName challenge}
|
||||||
geval --test-name dev-0
|
geval --test-name dev-0
|
||||||
|
|
||||||
<h2>Submit your solution
|
<h2>Push your solution to the git repo
|
||||||
|
|
||||||
<p>Push <tt>out.tsv</tt> files to your repo. It is also recommended to push your source codes along with <tt>out.tsv</tt> files.
|
<p>Commit and push <tt>out.tsv</tt> files to your repo. It is also recommended to push your source codes along with <tt>out.tsv</tt> files.
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
cd #{challengeName challenge}
|
cd #{challengeName challenge}
|
||||||
@ -57,4 +57,19 @@ $if not isIDSet || not isSSHUploaded
|
|||||||
git commit -m 'my brilliant solution'
|
git commit -m 'my brilliant solution'
|
||||||
git push origin master
|
git push origin master
|
||||||
|
|
||||||
<p>If you use a repo hosted on Gonito.net, a submission and evaluation is triggered automatically. Otherwise, you need to tell Gonito.net to evaluate your submission (go to the <a href="@{ChallengeSubmissionR $ challengeName challenge}">submit form</a> in such a case).
|
<h3>Repos hosted on Gonito.net
|
||||||
|
|
||||||
|
<p>If you use a repo hosted here, a submission and evaluation is triggered automatically. You'll see the evaluation results in your console while pushing.
|
||||||
|
|
||||||
|
<h3>External repos
|
||||||
|
|
||||||
|
<p>If you use an external repo (e.g. at your own of Gitolite or at GitHub), you can configure a webhook.
|
||||||
|
$maybe token <- mToken
|
||||||
|
<p>Your webook is:
|
||||||
|
<pre>
|
||||||
|
https://gonito.net/trigger-remotely?token=#{token}&branch=master&challenge=#{challengeName challenge}&url=URL_TO_YOUR_REPO
|
||||||
|
<p>(must be POSTed)
|
||||||
|
|
||||||
|
<h3>Manual submission
|
||||||
|
|
||||||
|
<p>In case other methods fail, you can submit your solution manually — go to the <a href="@{ChallengeSubmissionR $ challengeName challenge}">submit form</a>.
|
||||||
|
Loading…
Reference in New Issue
Block a user