Skip to content

Commit

Permalink
Merge pull request #297 from input-output-hk/KtorZ/ci-experiments-par…
Browse files Browse the repository at this point in the history
…allel-jobs

Quickly try speeding up CI workflow by parallelizing tasks.
  • Loading branch information
KtorZ authored Apr 13, 2022
2 parents 2bd5991 + 148573d commit eb65cae
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 43 deletions.
149 changes: 123 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,31 @@ on:
- cron: "0 4 * * *"

jobs:
build-test-documentation:
name: Build, test & documentation
build-test:
name: "Build & test"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- package: plutus-cbor
bench:
shouldRun: false
- package: plutus-merkle-tree
bench:
shouldRun: false
- package: hydra-tui
bench:
shouldRun: false
- package: hydra-node
bench:
shouldRun: true
name: tx-cost
options: '--output-directory $(pwd)/docs/benchmarks'
- package: hydra-cluster
bench:
shouldRun: true
name: hydra-cluster
options: '--scaling-factor 1'
steps:
- uses: actions/[email protected]
with:
Expand Down Expand Up @@ -39,26 +61,96 @@ jobs:
~/.cabal/store
dist-newstyle
key: |
cabal-${{ runner.os }}-${{ hashFiles('cabal.project', 'default.nix', 'shell.nix') }}-${{ matrix.package }}
restore-keys: |
cabal-${{ runner.os }}-${{ hashFiles('cabal.project', 'default.nix', 'shell.nix') }}
- name: Prepare nix-shell
run: |
nix-build shell.nix
nix-build --arg withoutDevTools true shell.nix
- name: Build
run: nix-shell --run '.github/workflows/ci-build.sh'
run: |
nix-shell --arg withoutDevTools true --run 'cabal update'
nix-shell --arg withoutDevTools true --run 'cabal build ${{ matrix.package }}'
- name: Test
run: nix-shell --run '.github/workflows/ci-test.sh'
if: ${{ matrix.package != 'hydra-tui' }}
run: |
nix-shell --arg withoutDevTools true --run 'cabal test ${{ matrix.package }}'
- name: Test (TUI)
id: test_tui
if: ${{ matrix.package == 'hydra-tui' }}
# https://giters.com/gfx/example-github-actions-with-tty
# The default shell does not allocate a TTY which breaks some tests
shell: 'script -q -e -c "bash {0}"'
env:
TERM: "xterm"
continue-on-error: true
run: |
nix-shell --arg withoutDevTools true --run 'cabal test ${{ matrix.package }}'
- name: Documentation (Haddock)
- name: Test (TUI, retry)
if: steps.test_tui.outcome=='failure'
shell: 'script -q -e -c "bash {0}"'
env:
TERM: "xterm"
run: |
nix-shell --run '.github/workflows/ci-haddock.sh'
nix-shell --arg withoutDevTools true --run 'cabal test ${{ matrix.package }}'
- name: Bench
if: ${{ matrix.bench.shouldRun }}
run: |
nix-shell --arg withoutDevTools true --run 'cabal bench ${{ matrix.bench.name }} --benchmark-options "${{ matrix.bench.options }}"'
- name: Upload build & test artifacts
uses: actions/upload-artifact@v2
with:
path: ./**/test-results.xml

publish-test-results:
name: Publish test results
needs: [build-test]
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
repository: input-output-hk/hydra-poc
token: ${{ secrets.MY_TOKEN || github.token }}

- uses: actions/download-artifact@v3

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
files: ./**/test-results.xml

documentation:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
repository: input-output-hk/hydra-poc
token: ${{ secrets.MY_TOKEN || github.token }}

- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
folder-path: "hydra-cardano-api, hydra-cluster, hydra-node, hydra-plutus, hydra-prelude, hydra-test-utils, hydra-tui, plutus-cbor, plutus-merkle-tree"

- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
folder-path: "."
max-depth: 1

- name: Prepare nix
uses: cachix/install-nix-action@v13
with:
skip_adding_nixpkgs_channel: true
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: Setup Node.js
uses: actions/setup-node@v3
Expand All @@ -67,6 +159,30 @@ jobs:
cache: 'yarn'
cache-dependency-path: docs/yarn.lock

- name: Cachix cache of nix derivations
uses: cachix/cachix-action@v10
with:
name: hydra-node
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Github cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle
uses: actions/[email protected]
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: |
cabal-${{ runner.os }}-${{ hashFiles('cabal.project', 'default.nix', 'shell.nix') }}
- name: Prepare nix-shell
run: |
nix-build --arg withoutDevTools true shell.nix
- name: Documentation (Haddock)
run: |
nix-shell --run '.github/workflows/ci-haddock.sh'
- name: Documentation (Docusaurus)
working-directory: docs
run: |
Expand All @@ -77,11 +193,6 @@ jobs:
echo "hydra.family" > public/CNAME
echo '<!DOCTYPE html><html><head><meta http-equiv="Refresh" content="0; URL=https://hydra.family/head-protocol"></head></html>' > public/index.html
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
files: ./**/test-results.xml

- name: Publish Documentation
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
Expand All @@ -90,17 +201,3 @@ jobs:
publish_dir: docs/public
enable_jekyll: true
force_orphan: true

markdown-link-check:
name: "Check markdown links"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# NOTE: We do not check the 'docs' folder because links in markdown are already checked and handled by Docusaurus.
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
folder-path: "hydra-cardano-api, hydra-cluster, hydra-node, hydra-plutus, hydra-prelude, hydra-test-utils, hydra-tui, plutus-cbor, plutus-merkle-tree"
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
folder-path: "."
max-depth: 1
48 changes: 31 additions & 17 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

, hsPkgs ? import ./default.nix { }

, withoutDevTools ? false

, libsodium-vrf ? pkgs.libsodium.overrideAttrs (oldAttrs: {
name = "libsodium-1.0.18-vrf";
src = pkgs.fetchFromGitHub {
Expand All @@ -29,24 +31,41 @@ let
++
pkgs.lib.optionals (pkgs.stdenv.isLinux) [ pkgs.systemd ];

tools = [
buildInputs = [
pkgs.pkgconfig
pkgs.haskellPackages.ghcid
pkgs.haskellPackages.hspec-discover
pkgs.haskellPackages.graphmod
pkgs.haskellPackages.cabal-plan
pkgs.haskellPackages.cabal-fmt
# Handy to interact with the hydra-node via websockets
pkgs.ws
# For validating JSON instances against a pre-defined schema
pkgs.python3Packages.jsonschema
pkgs.yq
# For plotting results of hydra-cluster benchmarks
pkgs.gnuplot
# For docs/
];

devInputs = if withoutDevTools then [] else [
# The interactive Glasgow Haskell Compiler as a Daemon
pkgs.haskellPackages.ghcid
# Generate a graph of the module dependencies in the "dot" format
pkgs.haskellPackages.graphmod
# Automagically format .cabal files
pkgs.haskellPackages.cabal-fmt
# Handy to interact with the hydra-node via websockets
pkgs.ws
# Like 'jq' to manipulate JSON, but work for YAML
pkgs.yq
# For docs/ (i.e. Docusaurus, Node.js & React)
pkgs.yarn
];

# Haskell.nix managed tools (via hackage)
buildTools = {
cabal = "3.4.0.0";
};

devTools = if withoutDevTools then {} else {
fourmolu = "0.4.0.0"; # 0.5.0.0 requires Cabal 3.6
haskell-language-server = "latest";
};

haskellNixShell = hsPkgs.shellFor {
# NOTE: Explicit list of local packages as hoogle would not work otherwise.
# Make sure these are consistent with the packages in cabal.project.
Expand All @@ -62,16 +81,11 @@ let
plutus-merkle-tree
];

# Haskell.nix managed tools (via hackage)
tools = {
cabal = "3.4.0.0";
fourmolu = "0.4.0.0"; # 0.5.0.0 requires Cabal 3.6
haskell-language-server = "latest";
};
tools = buildTools // devTools;

buildInputs = libs ++ tools;
buildInputs = libs ++ buildInputs ++ devInputs;

withHoogle = true;
withHoogle = !withoutDevTools;

# Always create missing golden files
CREATE_MISSING_GOLDEN = 1;
Expand All @@ -86,7 +100,7 @@ let
pkgs.cabal-install
pkgs.git
pkgs.pkgconfig
] ++ tools;
] ++ buildInputs ++ devInputs;

# Ensure that libz.so and other libraries are available to TH splices.
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath libs;
Expand Down

0 comments on commit eb65cae

Please sign in to comment.