Use less nix in CI #5483
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, benchmark and generate haskell documentation | ||
build: | ||
name: "Build" | ||
runs-on: ["Linux", "X64", "explorer"] | ||
# TODO: only use runs-on: ["Linux", "X64"] | ||
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: ❄ Cachix cache of nix derivations | ||
uses: cachix/cachix-action@v15 | ||
with: | ||
name: cardano-scaling | ||
authToken: '${{ secrets.CACHIX_CARDANO_SCALING_AUTH_TOKEN }}' | ||
- name: Set up and use the default devShell | ||
uses: nicknovitski/nix-develop@v1 | ||
- name: 🔨 Build | ||
run: | | ||
cabal build all | ||
- name: 🧪 Test | ||
# The default shell does not allocate a TTY which is needed by hydra-tui | ||
# https://giters.com/gfx/example-github-actions-with-tty | ||
shell: 'script -q -e -c "bash {0}"' | ||
env: | ||
TERM: "xterm" | ||
run: | | ||
cabal test all | ||
- name: 💾 Upload test results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-results | ||
path: | | ||
./**/test-results.xml | ||
./**/hspec-results.md | ||
if-no-files-found: ignore | ||
- name: ✏ Publish test results to PR | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
with: | ||
junit_files: ./**/test-results.xml | ||
- name: 📈 Benchmark | ||
run: | | ||
mkdir -p benchmarks | ||
cd ${{ matrix.package }} | ||
nix build .#${{ matrix.package }}-bench | ||
nix develop .#${{ matrix.package }}-bench --command ${{ matrix.bench }} ${{ matrix.options }} | ||
cabal bench on-chain-cost --benchmark-options "./benchmarks" | ||
cabal bench tx-cost --benchmark-options "--output-directory ./benchmarks" | ||
cabal bench micro --benchmark-options "-o ./benchmarks/ledger-bench.html" | ||
cabal bench bench-e2e --benchmark-options "datasets datasets/1-node.json datasets/3-nodes.json --output-directory ./benchmarks --timeout 1000s" | ||
- name: ⚙ Prepare benchmark comment body | ||
id: comment-body | ||
run: | | ||
# Drop first 5 header lines and demote headlines one level | ||
cat <(cat benchmarks/transaction-cost.md | sed '1,5d;s/^#/##/') <(cat benchmarks/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 | ||
- name: 💾 Upload benchmarks | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: benchmarks | ||
path: benchmarks | ||
# 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 | ||
- name: 📚 Documentation (Haddock) | ||
# TODO: use cabal haddock-project instead | ||
run: | | ||
nix build .#haddocks | ||
mkdir -p haddocks | ||
cp -aL result/* haddocks/ | ||
- name: 💾 Upload haddocks | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: haddocks | ||
path: haddocks | ||
nix-flake-check: | ||
name: "nix flake check" | ||
runs-on: ubuntu-latest | ||
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: ❄ Cachix cache of nix derivations | ||
uses: cachix/cachix-action@v15 | ||
with: | ||
name: cardano-scaling | ||
authToken: '${{ secrets.CACHIX_CARDANO_SCALING_AUTH_TOKEN }}' | ||
- name: ❄ Nix Flake Check | ||
run: | | ||
nix flake check -L | ||
build-specification: | ||
name: "Build specification using nix" | ||
runs-on: ubuntu-latest | ||
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: ❄ Cachix cache of nix derivations | ||
uses: cachix/cachix-action@v15 | ||
with: | ||
name: cardano-scaling | ||
authToken: '${{ secrets.CACHIX_CARDANO_SCALING_AUTH_TOKEN }}' | ||
- 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] | ||
Check failure on line 196 in .github/workflows/ci-nix.yaml GitHub Actions / CIInvalid workflow file
|
||
runs-on: ubuntu-latest | ||
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: Set up and use the "ci" devShell | ||
uses: nicknovitski/nix-develop@v1 | ||
with: | ||
arguments: ".#ci" | ||
# Technically, we don't need this, given we're in a Nix shell; | ||
# but we will keep it for the caching. | ||
- name: 🚧 Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: 'yarn' | ||
cache-dependency-path: docs/yarn.lock | ||
- name: ❓ Test API reference | ||
working-directory: docs | ||
run: | | ||
yarn | ||
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: | | ||
yarn | ||
yarn build-dev |