upload logs as artifacts on failure #56
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: test CI | |
on: [push] | |
env: | |
BATCH_GATEWAY_URLS: '["https://universal-offchain-unwrapper.ens-cf.workers.dev/"]' | |
DOH_GATEWAY_URL: 'https://cloudflare-dns.com/dns-query' | |
HARDHAT_DISABLE_TELEMETRY_PROMPT: true | |
REGISTRAR_ADDRESS: ${{ vars.REGISTRAR_ADDRESS }} | |
REGISTRY_ADDRESS: ${{ vars.REGISTRY_ADDRESS }} | |
RESOLVER_ADDRESS: ${{ vars.RESOLVER_ADDRESS }} | |
WRAPPER_ADDRESS: ${{ vars.WRAPPER_ADDRESS }} | |
jobs: | |
e2e: | |
name: Run tests on Node ${{ matrix.node }} and ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node: ['18.x', '20.x'] | |
os: [ubuntu-latest, macOS-latest] | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Use Node ${{ matrix.node }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Install deps and build (with cache) | |
uses: bahmutov/npm-install@v1 | |
- name: Check out ENS contracts | |
uses: actions/checkout@v3 | |
with: | |
repository: ensdomains/ens-contracts | |
path: './contracts' | |
ref: '6b9aaae963f71792ab1a75de61d5151ff1d1b7e3' | |
- name: Run local node | |
run: | | |
cd ./contracts | |
yarn | |
npx hardhat node --hostname 127.0.0.1 > hardhat_output.log 2>&1 & | |
echo $! > hardhat_pid.txt | |
env: | |
BATCH_GATEWAY_URLS: '["https://universal-offchain-unwrapper.ens-cf.workers.dev/"]' | |
DOH_GATEWAY_URL: 'https://cloudflare-dns.com/dns-query' | |
- name: Wait for local node | |
run: | | |
timeout=300 | |
while true; do | |
if [ $timeout -le 0 ]; then | |
echo "Timeout waiting for Hardhat node" | |
cat hardhat_output.log | |
exit 1 | |
fi | |
if nc -z localhost 8545 2>/dev/null; then | |
echo "Hardhat node is up and running" | |
break | |
fi | |
echo "Waiting for Hardhat node... ($timeout seconds left)" | |
sleep 5 | |
timeout=$((timeout - 5)) | |
done | |
shell: bash | |
- name: Test | |
run: yarn test --ci --coverage --maxWorkers=2 | |
- name: Upload Hardhat logs on failure | |
if: failure() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: hardhat-logs | |
path: ./contracts/hardhat_output.log | |
- name: Cleanup Hardhat process | |
if: always() | |
run: | | |
if [ -f ./contracts/hardhat_pid.txt ]; then | |
pid=$(cat ./contracts/hardhat_pid.txt) | |
kill $pid 2>/dev/null || true | |
fi | |
shell: bash |