103 lines
3.2 KiB
Text
Executable file
103 lines
3.2 KiB
Text
Executable file
#!/usr/bin/env pil
|
|
(de protection ()
|
|
(let C 0
|
|
(in '(pgrep -f start.l)
|
|
(while (line)
|
|
(inc 'C) ) )
|
|
(when (>= C 2) (bye)) ) )
|
|
(de ok (S)
|
|
(push '*Res (cons 0 S)) )
|
|
(de fatal (S)
|
|
(nil (push '*Res (cons 1 S))) )
|
|
(de connection ()
|
|
(if
|
|
(and
|
|
(call 'bash '-c "curl --ipv4 -m15 --silent https://nest.pijul.com/pijul/pijul/changes > /dev/null")
|
|
(call 'bash '-c "curl --ipv6 -m15 --silent https://nest.pijul.com/pijul/pijul/changes > /dev/null") )
|
|
(ok "connect")
|
|
(throw 'exit) ) )
|
|
(de pijul-tests ()
|
|
(if
|
|
(and
|
|
(cd "/home/suite")
|
|
(call 'git 'clone 'https://git.envs.net/mpech/pijul-tests)
|
|
(cd "/home/suite/pijul-tests")
|
|
(call 'bash 'braid.sh) )
|
|
(ok "get tests")
|
|
(fatal "get tests") ) )
|
|
(de getstate ()
|
|
(if
|
|
(and
|
|
(connection)
|
|
(in '(bash -c "curl -m15 --silent https://nest.pijul.com/pijul/pijul/changes | htmlq -t code")
|
|
(setq *Hash (pack (head 8 (line)))) )
|
|
(> (length *Hash) 5) )
|
|
(ok "get state")
|
|
(fatal "get state") ) )
|
|
(de recompile ()
|
|
(if
|
|
(and
|
|
(cd "/home/suite")
|
|
(call 'pijul 'clone 'https://nest.pijul.com/pijul/pijul)
|
|
(cd "/home/suite/pijul")
|
|
(call 'cargo 'update)
|
|
(call 'cargo 'build '--release)
|
|
(call '/home/suite/pijul/target/release/pijul '-V) )
|
|
(ok "recompile")
|
|
(fatal "recompile") ) )
|
|
(de suite ()
|
|
(cd "/home/suite/pijul-tests")
|
|
(for File (sort (dir "./"))
|
|
(let (C (chop File) Task (pack (car (split C '.))))
|
|
(when (match '`(chop (if *Dbg "braid.sh" "@.sh")) C)
|
|
(if (call 'bash File)
|
|
(ok Task)
|
|
(fatal Task) ) ) ) ) )
|
|
(de fatal? ()
|
|
(if (fully '((L) (=0 (car L))) *Res)
|
|
"-OK"
|
|
"-FATAL" ) )
|
|
(de found? ()
|
|
(t
|
|
(when (and (not *Dbg) (= *Hash (rc *RC 'last)))
|
|
(throw 'exit) ) ) )
|
|
(de writelog ()
|
|
(let
|
|
(Base (pack "/var/www/localhost/htdocs/suite/" *Hash)
|
|
File (pack Base (fatal?) ".txt")
|
|
Fmt (25 10) )
|
|
(call 'bash '-c (pack "rm -f " Base "*"))
|
|
(out File
|
|
(for L (reverse *Res)
|
|
(tab
|
|
Fmt
|
|
(cdr L)
|
|
(if (=0 (car L)) 'OK 'FATAL) ) ) ) ) )
|
|
(de main ()
|
|
(protection)
|
|
(setq *RC "~/.pil/suite")
|
|
(unless (info *RC)
|
|
(rc *RC 'last NIL) )
|
|
# Global state are two vars
|
|
(let (*Res NIL *Hash "CONNECTION")
|
|
(catch 'exit
|
|
(and
|
|
(getstate) # + connection check
|
|
(found?) # throw 'exit, total silent stop
|
|
(recompile)
|
|
(pijul-tests)
|
|
(ok "---------")
|
|
# never fallthru
|
|
# always finish and collects all tests
|
|
(suite) )
|
|
(writelog)
|
|
(mail "localhost" 25 "mpech@envs.net" (quote "tankf33der@disroot.org") (pack "pulsarCT: " *Hash (fatal?)))
|
|
(when (== "-OK" (fatal?))
|
|
(rc *RC 'last *Hash) )
|
|
(unless *Dbg
|
|
(call 'toot 'post (pack "pulsarCT: " *Hash (fatal?))) )
|
|
) # catch
|
|
(call 'rm '-rf '/home/suite/pijul)
|
|
(call 'rm '-rf '/home/suite/pijul-tests)
|
|
(call 'rm '-rf '/home/suite/pijul-tests-data) )
|
|
(bye) )
|