Skip to content

Commit

Permalink
upload logs as artifacts on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanrikulu committed Sep 24, 2024
1 parent 26b34be commit 2391423
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['18.x', '21.x']
node: ['18.x', '20.x']
os: [ubuntu-latest, macOS-latest]

steps:
Expand All @@ -38,26 +38,50 @@ jobs:
path: './contracts'
ref: '6b9aaae963f71792ab1a75de61d5151ff1d1b7e3'

# - name: Run local node on Windows
# if: runner.os == 'Windows'
# run: cd contracts; yarn --network-timeout 100000; $env:HARDHAT_DISABLE_TELEMETRY_PROMPT = "true"; $currentDir = (Get-Location).Path; $job = Start-Job -ScriptBlock { param($dir) Set-Location -Path $dir; npx hardhat node --hostname '127.0.0.1' } -ArgumentList $currentDir; Start-Sleep -Seconds 50; Receive-Job -Job $job -Keep
# env:
# BATCH_GATEWAY_URLS: '["https://universal-offchain-unwrapper.ens-cf.workers.dev/"]'
# DOH_GATEWAY_URL: 'https://cloudflare-dns.com/dns-query'

- name: Run local node on Unix
if: runner.os != 'Windows'
run: cd ./contracts && yarn && npx hardhat node --hostname 127.0.0.1 &
- 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
uses: iFaxity/[email protected]
with:
timeout: 900000
window: 2000
resource: http://127.0.0.1:8545
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

0 comments on commit 2391423

Please sign in to comment.