Skip to content

Hardhat EVM Setup for Polkadot Hub #25

Hardhat EVM Setup for Polkadot Hub

Hardhat EVM Setup for Polkadot Hub #25

name: Hardhat EVM Setup for Polkadot Hub
on:
push:
branches: [master]
paths:
- 'polkadot-docs/smart-contracts/dev-environments/hardhat-evm/**'
- '!polkadot-docs/smart-contracts/dev-environments/hardhat-evm/README.md'
pull_request:
paths:
- 'polkadot-docs/smart-contracts/dev-environments/hardhat-evm/**'
- '!polkadot-docs/smart-contracts/dev-environments/hardhat-evm/README.md'
workflow_dispatch:
jobs:
test:
# Guard: only run in the canonical repository to protect CI secrets
if: github.repository == 'polkadot-developers/polkadot-cookbook'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
# Cache the scaffolded project's node_modules.
# Keyed on the test file: when the pinned Hardhat version or project
# setup changes the test file will change, busting the cache.
- name: Cache npm dependencies (hardhat-evm project)
uses: actions/cache@v4
with:
path: |
polkadot-docs/smart-contracts/dev-environments/hardhat-evm/.test-workspace/hardhat-evm/node_modules
key: ${{ runner.os }}-hardhat-evm-npm-${{ hashFiles('polkadot-docs/smart-contracts/dev-environments/hardhat-evm/tests/docs.test.ts') }}
# Install the Vitest wrapper's own dependencies (not the Hardhat project)
- name: Install wrapper dependencies
run: |
cd polkadot-docs/smart-contracts/dev-environments/hardhat-evm
npm ci
# Run the full 6-phase test suite.
# PRIVATE_KEY maps to HARDHAT_VAR_PRIVATE_KEY inside the test so
# Hardhat resolves vars.get('PRIVATE_KEY') without interactive prompts.
- name: Run tests
run: |
cd polkadot-docs/smart-contracts/dev-environments/hardhat-evm
npm test
env:
PRIVATE_KEY: ${{ secrets.TESTNET_PRIVATE_KEY }}
timeout-minutes: 20
post-test:
needs: test
# Only file issues on master — not on every PR failure
if: >
github.repository == 'polkadot-developers/polkadot-cookbook' &&
always() &&
github.ref == 'refs/heads/master'
uses: ./.github/workflows/post-cleanup.yml
with:
test_result: ${{ needs.test.result }}
readme_path: 'polkadot-docs/smart-contracts/dev-environments/hardhat-evm/README.md'
workflow_name: 'Hardhat EVM Setup for Polkadot Hub'
permissions:
contents: read
issues: write