Skip to content
midnight-tooling:midnight-ci logo

midnight-tooling:midnight-ci

Use when setting up CI/CD for Midnight projects, configuring GitHub Actions for Compact contract compilation, running TypeScript tests in CI, validating version consistency, or automating contract builds.

SKILL.md

Full skill instructions

Midnight CI/​CD Setup

Configure continuous integration for Midnight smart contract projects using GitHub Actions.

Overview

CI for Midnight projects should:

  1. Verify contract compilation
  2. Run TypeScript/​JavaScript tests
  3. Validate version consistency
  4. Optionally run integration tests with proof server

Quick Start

Copy the appropriate workflow template to your project:

mkdir -p .github/​workflows

# For contract compilation
cp ${CLAUDE_PLUGIN_ROOT}/​skills/​midnight-ci/​templates/​github-workflows/​compile-contracts.yml .github/​workflows/

# For full dApp testing
cp ${CLAUDE_PLUGIN_ROOT}/​skills/​midnight-ci/​templates/​github-workflows/​test-dapp.yml .github/​workflows/

Available Templates

TemplatePurpose
compile-contracts.ymlBasic contract compilation check
test-dapp.ymlFull dApp testing with proof server
release.ymlRelease workflow with versioning

Workflow Configuration

Environment Setup

All workflows need these tools:

  • Node.js 18+
  • Compact developer tools and compiler
  • Docker (for proof server tests)

Compact Installation in CI

- name: Install Compact developer tools
  run: |
    curl --proto '=https' --tlsv1.2 -LsSf \
      https://github.com/​midnightntwrk/​compact/​releases/​latest/​download/​compact-installer.sh | sh
    echo "$HOME/​.compact/​bin" >> $GITHUB_PATH

- name: Install Compact compiler
  run: compact update

Caching

Cache Compact compiler for faster builds:

- name: Cache Compact compiler
  uses: actions/​cache@v4
  with:
    path: ~/​.compact
    key: compact-${{ runner.os }}-${{ hashFiles('.compact-version') }}
    restore-keys: |
      compact-${{ runner.os }}-

Create .compact-version file:

0.26.0

Version Pinning

For reproducible CI, pin the compiler version:

- name: Install specific compiler version
  run: |
    compact update 0.26.0
    compact compile --version  # Verify

Template Details

compile-contracts.yml

Minimal workflow for contract compilation:

name: Compile Contracts
on: [push, pull_request]

jobs:
  compile:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/​checkout@v4

      - name: Setup Node.js
        uses: actions/​setup-node@v4
        with:
          node-version: '20'

      - name: Install Compact
        run: |
          curl --proto '=https' --tlsv1.2 -LsSf \
            https://github.com/​midnightntwrk/​compact/​releases/​latest/​download/​compact-installer.sh | sh
          echo "$HOME/​.compact/​bin" >> $GITHUB_PATH
          compact update

      - name: Compile contracts
        run: compact compile contracts/​*.compact build/

test-dapp.yml

Full testing with proof server:

name: Test dApp
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    services:
      proof-server:
        image: midnightnetwork/​proof-server:latest
        ports:
          - 6300:6300
        options: >-
          --health-cmd "curl -f http://localhost:6300/​health || exit 1"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      # ... setup steps ...

      - name: Run tests
        run: npm test
        env:
          PROOF_SERVER_URL: http://localhost:6300

Best Practices

1. Pin All Versions

env:
  NODE_VERSION: '20'
  COMPACT_VERSION: '0.26.0'
  PROOF_SERVER_TAG: '4.0.0'

2. Use npm ci

- name: Install dependencies
  run: npm ci

3. Cache Dependencies

- name: Cache node modules
  uses: actions/​cache@v4
  with:
    path: node_modules
    key: npm-${{ hashFiles('package-lock.json') }}

4. Fail Fast on Version Mismatch

Add a version check step:

- name: Verify version consistency
  run: |
    COMPILER_VERSION=$(compact compile --version)
    EXPECTED="0.26.0"
    if [[ "$COMPILER_VERSION" != *"$EXPECTED"* ]]; then
      echo "Version mismatch: expected $EXPECTED, got $COMPILER_VERSION"
      exit 1
    fi

5. Artifact Upload

Save compiled contracts:

- name: Upload compiled contracts
  uses: actions/​upload-artifact@v4
  with:
    name: contracts
    path: build/
    retention-days: 7

Troubleshooting CI

Compact not found

Ensure PATH is updated:

echo "$HOME/​.compact/​bin" >> $GITHUB_PATH

Proof server unhealthy

Increase startup time:

options: >-
  --health-retries 10
  --health-start-period 30s

Node version issues

Specify exact version:

node-version: '20.10.0'

Cache invalidation

Include version in cache key:

key: compact-${{ env.COMPACT_VERSION }}-${{ runner.os }}

Additional Resources

  • templates/​github-workflows/ - Ready-to-use workflow files
  • references/​ci-best-practices.md - Detailed CI guidance

For local environment setup, see the midnight-setup skill.

More skills from aaronbassett

compact-core:ledger-adts logo
aaronbassett/midnight-knowledgebase

compact-core:ledger-adts

Use when working with Compact on-chain state management using ledger ADTs including Cell, Counter, Map, Set, List, MerkleTree, or HistoricMerkleTree, or when needing to understand which operations are available in Compact vs TypeScript.

0 0
View
dapp-sdd:implement logo
aaronbassett/midnight-knowledgebase

dapp-sdd:implement

Use when executing implementation tasks with commits after each task and reviews after each phase.

0 0
View
compact-core:clone-examples logo
aaronbassett/midnight-knowledgebase

compact-core:clone-examples

Use when starting a new Midnight project, cloning example contracts (counter, tokens, NFTs, DEX), scaffolding from OpenZeppelin templates, or bootstrapping a Compact contract development environment with working starter code.

0 0
View
compact-core:compilation-tooling logo
aaronbassett/midnight-knowledgebase

compact-core:compilation-tooling

Use when working with the Compact compiler (compactc), configuring build settings, understanding zkir/prover/verifier output artifacts, setting up COMPACT_PATH, or integrating VS Code language server support for Midnight smart contract development.

0 0
View
midnight-proofs:proof-caching logo
aaronbassett/midnight-knowledgebase

midnight-proofs:proof-caching

Use when caching ZK proofs for performance, implementing proof cache invalidation, storing verification results, caching intermediate proof components, or building distributed proof caches with Redis.

0 0
View
midnight-dapp:proof-handling logo
aaronbassett/midnight-knowledgebase

midnight-dapp:proof-handling

Use when building witness data for ZK proofs, showing proof generation progress to users, implementing disclosure consent flows, handling proof timeouts and retries, or explaining privacy guarantees.

0 0
View
dapp-sdd:constitution logo
aaronbassett/midnight-knowledgebase

dapp-sdd:constitution

Use when implementing any Midnight example dApp to ensure compliance with quality standards and project conventions.

0 0
View
compact-core:typescript-integration logo
aaronbassett/midnight-knowledgebase

compact-core:typescript-integration

Use when implementing witness functions in TypeScript, mapping Compact types to TypeScript (Field→bigint, Bytes→Uint8Array), deploying contracts, calling circuits from TypeScript, reading ledger state, or building Midnight DApps with the JavaScript SDK.

0 0
View
midnight-dapp:state-management logo
aaronbassett/midnight-knowledgebase

midnight-dapp:state-management

Use when reading public ledger state, implementing reactive UI that updates with chain state, caching state for performance, or understanding public vs private state in Midnight DApps.

0 0
View
midnight-proofs:prover-optimization logo
aaronbassett/midnight-knowledgebase

midnight-proofs:prover-optimization

Use when optimizing prover performance, reducing proof generation memory usage, configuring prover infrastructure in Docker or Kubernetes, implementing parallel proof generation, or diagnosing prover bottlenecks.

0 0
View
dapp-sdd:plan logo
aaronbassett/midnight-knowledgebase

dapp-sdd:plan

Use when creating a phased implementation plan from a specification, with review gates after each phase.

0 0
View
midnight-tooling:contract-calling logo
aaronbassett/midnight-knowledgebase

midnight-tooling:contract-calling

Use when calling deployed Midnight contracts from Node.js backends, querying contract state, executing state-changing transactions, building API endpoints that interact with contracts, or automating contract interactions.

0 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View