Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
task: rainix-rs-static
fail-fast: false
runs-on: ${{ matrix.os }}
env:
DEPLOYMENT_KEY: ${{ secrets.PRIVATE_KEY }}
defaults:
run:
working-directory: test/fixture
Expand Down Expand Up @@ -65,8 +63,8 @@ jobs:
restore-keys: |
foundry-full-${{ runner.os }}-
- run: nix develop ../.. --command forge soldeer install
# rainix-sol-artifacts runs hermetically here: with no ETH_RPC_URL the
# task deploys against its own ephemeral anvil, so this job needs no RPC
# or key secrets.
- name: Run ${{ matrix.task }}
env:
ETH_RPC_URL: ${{ secrets.CI_DEPLOY_SEPOLIA_RPC_URL || vars.CI_DEPLOY_SEPOLIA_RPC_URL }}
ETHERSCAN_API_KEY: ${{ secrets.EXPLORER_VERIFICATION_KEY }}
run: nix develop ../.. --command ${{ matrix.task }}
17 changes: 17 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,23 @@
# Upload all function selectors to the registry.
forge selectors up --all

# With no ETH_RPC_URL the task is hermetic: it runs against its own
# ephemeral anvil instance with anvil's first funded dev account as
# the deployment key, so it needs no secrets and no external RPC.
# An explicit ETH_RPC_URL (a real deploy) always wins and leaves
# DEPLOYMENT_KEY untouched. Port 18545 avoids clobbering a dev's
# own anvil on the default 8545.
if [[ -z "''${ETH_RPC_URL:-}" ]]; then
anvil --port 18545 --silent &
anvil_pid=$!
trap 'kill "''${anvil_pid}" 2>/dev/null' EXIT
export ETH_RPC_URL='http://127.0.0.1:18545'
export DEPLOYMENT_KEY='0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
until cast chain-id --rpc-url "''${ETH_RPC_URL}" >/dev/null 2>&1; do
sleep 0.2
done
Comment thread
coderabbitai[bot] marked this conversation as resolved.
fi

# Deploy all contracts to testnet.
# Assumes the existence of a `Deploy.sol` script in the `script` directory.
# Echos the deploy pubkey to stdout to make it easy to add gas to the account.
Expand Down
6 changes: 4 additions & 2 deletions test/bats/task/skip-simulation.test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ teardown() {
}

forge_deploy() {
forge script script/Deploy.sol:Deploy \
# The fixture Deploy.sol reads DEPLOYMENT_KEY itself (consumer convention);
# anvil's first funded dev account.
DEPLOYMENT_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
forge script script/Deploy.sol:Deploy \
-vvvvv \
--broadcast \
${DEPLOY_SKIP_SIMULATION:+--skip-simulation} \
--rpc-url http://127.0.0.1:8545 \
--private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
2>&1
}

Expand Down
8 changes: 7 additions & 1 deletion test/fixture/script/Deploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ import {Counter} from "../src/Counter.sol";
contract Deploy is Script {
function setUp() public {}

/// Reads the deployer key from `DEPLOYMENT_KEY`, the same convention as
/// the consumer `Deploy.sol` scripts `rainix-sol-artifacts` runs, so the
/// fixture exercises the task exactly as consumers do (broadcast included
/// — a bare `vm.broadcast()` would hit foundry's default-sender refusal).
function run() public {
vm.broadcast();
uint256 deployerPrivateKey = vm.envUint("DEPLOYMENT_KEY");
vm.startBroadcast(deployerPrivateKey);
new Counter();
vm.stopBroadcast();
}
}
Loading