Skip to content

Commit

Permalink
Publish lib and aggregator as artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
abailly-iohk committed Apr 13, 2022
1 parent 7ded2c3 commit dd8038b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ jobs:
with:
files: ./**/test-results.xml

- name: Publish libmithril
uses: actions/upload-artifact@v3
with:
name: libmithril
path: |
mithril-core/target/release/libmithril.so
mithril-core/target/include/mithril.h
build-mithril-aggregator:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
Expand Down Expand Up @@ -148,6 +156,12 @@ jobs:
command: test
args: --release --manifest-path ./mithril-network/mithril-aggregator/Cargo.toml

- name: Publish aggregator
uses: actions/upload-artifact@v3
with:
name: mithril-aggregator
path: mithril-network/mithril-aggregator/target/release/mithril-aggregator

build-mithril-node-poc:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -378,6 +392,7 @@ jobs:
extra_nix_config: |
trusted-public-keys = iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.nixos.org https://hydra.iohk.io https://iohk.cachix.org
- name: Github cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle
uses: actions/cache@v2.1.5
with:
Expand All @@ -392,6 +407,14 @@ jobs:
run: |
nix-build shell.nix
- name: Download aggregator
uses: actions/download-artifact@v3
with:
name: mithril-aggregator
path: ~/.cabal/bin/

- run: chmod +x ~/.cabal/bin/mithril-aggregator

- name: Build
run: nix-shell --run '.github/workflows/ci-build.sh'

Expand Down
2 changes: 1 addition & 1 deletion mithril-network/mithril-aggregator/src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mod handlers {
debug!("snapshots");

// Snapshots
let snapshots = fake_data::snapshots(10);
let snapshots = fake_data::snapshots(1);

Ok(warp::reply::json(&snapshots))
}
Expand Down
18 changes: 11 additions & 7 deletions mithril-test-lab/mithril-end-to-end/src/Mithril/Aggregator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ module Mithril.Aggregator where

import Control.Tracer (Tracer, traceWith)
import Hydra.Prelude
import qualified Paths_mithril_end_to_end as Pkg
import System.Directory (doesFileExist)
import System.FilePath ((</>))
import System.Process (CreateProcess (..), StdStream (UseHandle), proc, withCreateProcess)
import Test.Hydra.Prelude (checkProcessHasNotDied)
import Test.Hydra.Prelude (checkProcessHasNotDied, failure)
import Test.Network.Ports (randomUnusedTCPPort)

data Aggregator = Aggregator {aggregatorPort :: Int}
Expand All @@ -18,13 +20,11 @@ data AggregatorLog
deriving stock (Eq, Show, Generic)
deriving anyclass (ToJSON, FromJSON)

-- TODO: start an aggregator server on some default configuration that allocates random
-- port and wait for 'action' to terminate before closing the server.
withAggregator :: FilePath -> Tracer IO AggregatorLog -> (Aggregator -> IO a) -> IO a
withAggregator workDir tracer action = do
port <- randomUnusedTCPPort
let process = aggregatorProcess (Just workDir) port
logFile = workDir </> "aggregator.log"
process <- aggregatorProcess (Just workDir) port
let logFile = workDir </> "aggregator.log"
traceWith tracer (StartingAggregator workDir)
withFile logFile WriteMode $ \out ->
withCreateProcess process {std_out = UseHandle out, std_err = UseHandle out} $ \_stdin _stdout _stderr processHandle ->
Expand All @@ -35,5 +35,9 @@ withAggregator workDir tracer action = do
Left _ -> error "should never happen"
Right a -> pure a

aggregatorProcess :: Maybe FilePath -> Int -> CreateProcess
aggregatorProcess cwd port = (proc "mithril-aggregator" ["--server-port", show port]) {cwd}
aggregatorProcess :: Maybe FilePath -> Int -> IO CreateProcess
aggregatorProcess cwd port = do
binDir <- Pkg.getBinDir
let aggregator = binDir </> "mithril-aggregator"
unlessM (doesFileExist aggregator) $ failure $ "cannot find mithril-aggregator executable in expected location (" <> binDir <> ")"
pure $ (proc aggregator ["--server-port", show port]) {cwd}

0 comments on commit dd8038b

Please sign in to comment.