-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b718600
commit e7879b4
Showing
4 changed files
with
96 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
import Control.Lens (asIndex, to, (&), (^.), (^?)) | ||
import Data.Aeson | ||
import qualified Data.Aeson.Key as Key | ||
import Data.Aeson.Lens | ||
import Data.ByteString.Lazy (ByteString) | ||
import qualified Data.ByteString.Lazy as LBS | ||
import Data.Maybe (fromJust) | ||
import Data.String | ||
import Data.Text (Text) | ||
import qualified Data.Text.Lazy as Text | ||
import Data.Text.Lazy.Encoding (decodeLatin1) | ||
import Shh | ||
import System.Environment | ||
|
||
runRemoteTxCost :: ByteString -> Integer -> IO ByteString | ||
runRemoteTxCost revision seed = do | ||
exe | ||
"nix" | ||
"run" | ||
("git+https://github.com/cardano-scaling/hydra?" <> revision <> "#tx-cost") | ||
"--" | ||
"--seed" | ||
seed | ||
|> capture | ||
|
||
runLocalTxCost :: Integer -> IO ByteString | ||
runLocalTxCost seed = do | ||
exe | ||
"nix" | ||
"run" | ||
".#tx-cost" | ||
"--" | ||
"--seed" | ||
seed | ||
|> capture | ||
|
||
runPandoc :: FilePath -> FilePath -> IO ByteString | ||
runPandoc i o = do | ||
exe | ||
"pandoc" | ||
"-i" | ||
i | ||
"-o" | ||
o | ||
|> capture | ||
|
||
extractHeaders :: ByteString -> IO ByteString | ||
extractHeaders md = do | ||
exe "echo" md |> exe "grep" "##" |> capture | ||
|
||
runPandasDiff :: FilePath -> FilePath -> FilePath -> IO ByteString | ||
runPandasDiff headers old new = do | ||
exe | ||
"./scripts/diff.py" | ||
headers | ||
old | ||
new | ||
|> capture | ||
|
||
main :: IO () | ||
main = do | ||
args <- getArgs | ||
let revision = | ||
case args of | ||
[x] -> "rev=" <> x | ||
_ -> "ref=master" | ||
a <- runLocalTxCost 0 | ||
b <- runRemoteTxCost (fromString revision) 0 | ||
LBS.writeFile "new.md" a | ||
LBS.writeFile "old.md" b | ||
runPandoc "new.md" "new.html" | ||
runPandoc "old.md" "old.html" | ||
x <- extractHeaders a | ||
y <- extractHeaders b | ||
LBS.writeFile "new-headers.txt" x | ||
k <- runPandasDiff "new-headers.txt" "old.html" "new.html" | ||
LBS.writeFile "diff.md" k |