self-hosted CI #5467
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
name: "CI" | |
# Limit concurrent runs of this workflow within a single PR | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- master | |
- release | |
pull_request: | |
schedule: | |
# Everyday at 4:00 AM | |
- cron: "0 4 * * *" | |
permissions: | |
checks: write | |
pull-requests: write | |
jobs: | |
build-test: | |
name: "Build & test" | |
runs-on: [self-hosted, nixos] | |
strategy: | |
matrix: | |
include: | |
- package: plutus-cbor | |
- package: plutus-merkle-tree | |
- package: hydra-plutus | |
- package: hydra-node | |
- package: hydra-tui | |
- package: hydra-tx | |
- package: hydra-cluster | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v4 | |
- name: β Prepare nix | |
uses: cachix/install-nix-action@V28 | |
with: | |
extra_nix_config: | | |
accept-flake-config = true | |
log-lines = 1000 | |
- name: β Test | |
if: ${{ matrix.package != 'hydra-tui' | |
&& matrix.package != 'hydra-cluster' | |
&& matrix.package != 'hydra-node' | |
}} | |
run: | | |
cd ${{ matrix.package }} | |
nix build .#${{ matrix.package }}-tests | |
nix develop .#${{ matrix.package }}-tests --command tests | |
- name: β Test | |
if: ${{ matrix.package == 'hydra-cluster' | |
|| matrix.package == 'hydra-node' }} | |
run: | | |
nix build --option sandbox false .#checks.x86_64-linux.${{ matrix.package }} -L | |
# This one is special, as it requires a tty. | |
- name: β Test (TUI) | |
id: test_tui | |
if: ${{ matrix.package == 'hydra-tui' }} | |
run: | | |
cd ${{ matrix.package }} | |
nix build .#${{ matrix.package }}-tests | |
nix develop .#${{ matrix.package }}-tests --command tests | |
- name: πΎ Upload build & test artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.package }} | |
path: | | |
./**/test-results.xml | |
./**/hspec-results.md | |
if-no-files-found: ignore | |
# NOTE: This depends on the path used in hydra-cluster e2e tests | |
- name: πΎ Upload logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hydra-cluster-e2e-test-logs | |
path: /tmp/nix-shell.*/hydra-cluster-e2e-*/logs/* | |
if-no-files-found: ignore | |
publish-test-results: | |
name: Publish test results | |
needs: [build-test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: π₯ Download test results | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test-results-* | |
merge-multiple: true | |
- name: β Publish test results to PR | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
junit_files: ./**/test-results.xml | |
haddock: | |
name: "Build haddock using nix" | |
runs-on: [self-hosted, nixos] | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v4 | |
- name: β Prepare nix | |
uses: cachix/install-nix-action@V28 | |
with: | |
extra_nix_config: | | |
accept-flake-config = true | |
log-lines = 1000 | |
- name: π Documentation (Haddock) | |
run: | | |
nix build .#haddocks | |
- name: πΎ Upload haddock artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: haddocks | |
path: result | |
benchmarks: | |
name: "Benchmarks" | |
runs-on: [self-hosted, nixos] | |
strategy: | |
matrix: | |
include: | |
- package: hydra-node | |
bench: tx-cost | |
options: '--output-directory $(pwd)/../benchmarks' | |
- package: hydra-node | |
bench: micro | |
options: '-o $(pwd)/../benchmarks/ledger-bench.html' | |
- package: hydra-cluster | |
bench: bench-e2e | |
options: 'datasets datasets/1-node.json datasets/3-nodes.json --output-directory $(pwd)/../benchmarks --timeout 1000s' | |
- package: plutus-merkle-tree | |
bench: on-chain-cost | |
options: '$(pwd)/../benchmarks' | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v4 | |
- name: β Prepare nix | |
uses: cachix/install-nix-action@V28 | |
with: | |
extra_nix_config: | | |
accept-flake-config = true | |
log-lines = 1000 | |
- name: π Benchmark | |
run: | | |
mkdir -p benchmarks | |
cd ${{ matrix.package }} | |
nix build .#${{ matrix.package }}-bench | |
nix develop .#${{ matrix.package }}-bench --command ${{ matrix.bench }} ${{ matrix.options }} | |
- name: πΎ Upload build & test artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: benchmarks-${{matrix.package}}-${{matrix.bench}} | |
path: benchmarks | |
# NOTE: This depends on the path used in hydra-cluster bench | |
- name: πΎ Upload logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hydra-cluster-bench-logs | |
path: /tmp/nix-shell.*/bench-*/**/*.log | |
if-no-files-found: ignore | |
publish-benchmark-results: | |
name: Publish benchmark results | |
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
# TODO: this is actually only requires the tx-cost benchmark results | |
needs: [benchmarks] | |
runs-on: [self-hosted, nixos] | |
steps: | |
- name: π₯ Download generated documentation | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifact | |
pattern: benchmarks-* | |
merge-multiple: true | |
- name: β Prepare comment body | |
id: comment-body | |
run: | | |
# Drop first 5 header lines and demote headlines one level | |
cat <(cat artifact/transaction-cost.md | sed '1,5d;s/^#/##/') <(cat artifact/end-to-end-benchmarks.md | sed '1,5d;s/^#/##/') | grep -v '^:::' > comment-body.md | |
- name: π Find Comment | |
uses: peter-evans/find-comment@v3 | |
id: find-comment | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Transaction costs | |
- name: β Create or update comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
edit-mode: replace | |
issue-number: ${{ github.event.pull_request.number }} | |
body-file: comment-body.md | |
reactions: rocket | |
nix-flake-check: | |
name: "nix flake check" | |
runs-on: [self-hosted, nixos] | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v4 | |
- name: β Prepare nix | |
uses: cachix/install-nix-action@V28 | |
with: | |
extra_nix_config: | | |
accept-flake-config = true | |
log-lines = 1000 | |
- name: β Nix Flake Check | |
run: | | |
nix --option sandbox false flake check -L | |
build-specification: | |
name: "Build specification using nix" | |
runs-on: [self-hosted, nixos] | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v4 | |
- name: β Prepare nix | |
uses: cachix/install-nix-action@V28 | |
with: | |
extra_nix_config: | | |
accept-flake-config = true | |
log-lines = 1000 | |
- name: β Build specification PDF | |
run: | | |
nix build .#spec && cp result/*.pdf . | |
- name: πΎ Upload specification | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hydra-spec | |
path: | | |
documentation: | |
name: Documentation | |
needs: [haddock,benchmarks,build-test,build-specification] | |
runs-on: [self-hosted, nixos] | |
steps: | |
- name: π₯ Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# For the cardanonical json schemas | |
submodules: true | |
# Ensure we have all history with all commits | |
fetch-depth: 0 | |
- name: β Prepare nix | |
uses: cachix/install-nix-action@V28 | |
with: | |
extra_nix_config: | | |
accept-flake-config = true | |
log-lines = 1000 | |
- name: β Test API reference | |
working-directory: docs | |
run: | | |
nix develop .#ci --command yarn | |
nix develop .#ci --command bash -c "yarn validate" | |
- name: π₯ Download benchmark results | |
uses: actions/download-artifact@v4 | |
with: | |
path: docs/benchmarks | |
pattern: benchmarks-* | |
merge-multiple: true | |
- name: π₯ Download haddock documentation | |
uses: actions/download-artifact@v4 | |
with: | |
name: haddocks | |
path: docs/static/haddock | |
- name: π₯ Download test results | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: test-results-* | |
merge-multiple: true | |
path: docs/benchmarks/tests | |
- name: π₯ Download specification PDF | |
uses: actions/download-artifact@v4 | |
with: | |
name: hydra-spec | |
path: docs/static/ | |
- name: π Documentation sanity check | |
working-directory: docs | |
run: | | |
nix develop .#ci --command yarn | |
nix develop .#ci --command bash -c "yarn build-dev" |