131 lines
4.8 KiB
YAML
Raw Permalink Normal View History

2024-10-11 11:32:03 +02:00
name: Playwright Tests
on:
push:
2024-10-11 11:33:06 +02:00
branches: [main, master, feat/tests/test-init]
tags: [releases*]
2024-10-11 11:32:03 +02:00
pull_request:
branches: [main, master]
2024-10-11 11:33:06 +02:00
tags: [releases*]
2024-10-11 11:32:03 +02:00
workflow_dispatch:
env:
codex_version: v0.1.6
2024-10-11 12:00:36 +02:00
circuit_version: v0.1.6
2024-10-11 13:11:05 +02:00
marketplace_address: "0xfE822Df439d987849a90B64a4C0e26a297DBD47F"
eth_provider: "https://rpc.testnet.codex.storage"
2024-10-11 11:32:03 +02:00
jobs:
tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
2024-10-11 13:07:50 +02:00
- name: Install dependencies
run: sudo apt update && sudo apt install libgomp1
2024-10-11 11:32:03 +02:00
2024-10-11 16:19:51 +02:00
- name: Setup env variables
run: |
echo "platform=${RUNNER_OS,,}" >> $GITHUB_ENV
echo "architecture=$([[ $RUNNER_ARCH == 'X64' ]] && echo amd64 || echo ${RUNNER_ARCH,,})" >> $GITHUB_ENV
2024-10-11 15:58:36 +02:00
- name: Restore cached circuits
2024-10-11 16:10:20 +02:00
id: circuits-cache-restore
2024-10-11 15:58:36 +02:00
uses: actions/cache/restore@v4
2024-10-11 13:07:50 +02:00
with:
2024-10-11 15:41:49 +02:00
path: |
datadir/circuits
2024-10-11 13:07:50 +02:00
key: ${{ env.circuit_version }}-circuits
- name: Download circuits
2024-10-11 16:10:20 +02:00
if: steps.circuits-cache-restore.outputs.cache-hit != 'true'
2024-10-11 13:07:50 +02:00
run: |
2024-10-11 12:00:36 +02:00
mkdir -p datadir/circuits
2024-10-11 12:30:34 +02:00
chmod 700 datadir
chmod 700 datadir/circuits
2024-10-11 12:00:36 +02:00
curl -OL https://github.com/codex-storage/nim-codex/releases/download/${circuit_version}/cirdl-${circuit_version}-${platform}-${architecture}.tar.gz
tar -xvf cirdl-${circuit_version}-${platform}-${architecture}.tar.gz
2024-10-11 12:27:17 +02:00
chmod +x cirdl-${circuit_version}-${platform}-${architecture}
2024-10-11 13:07:50 +02:00
./cirdl-${circuit_version}-${platform}-${architecture} ./datadir/circuits ${eth_provider} ${marketplace_address}
2024-10-11 15:58:36 +02:00
- name: Cache circuits
2024-10-11 16:10:20 +02:00
id: circuits-cache
2024-10-11 15:58:36 +02:00
uses: actions/cache/save@v4
with:
path: datadir/circuits
2024-10-11 16:10:20 +02:00
key: ${{ steps.circuits-cache-restore.outputs.cache-primary-key }}
2024-10-11 15:58:36 +02:00
2024-10-11 15:41:49 +02:00
- name: Restore cached codex
2024-10-11 16:10:20 +02:00
id: codex-cache-restore
2024-10-11 15:41:49 +02:00
uses: actions/cache/restore@v4
2024-10-11 13:07:50 +02:00
with:
2024-10-11 16:19:51 +02:00
path: ./codex-${{ env.codex_version }}-${{ env.platform }}-${{ env.architecture }}
2024-10-11 13:10:01 +02:00
key: ${{ env.codex_version }}-codex
2024-10-11 12:37:09 +02:00
2024-10-11 13:07:50 +02:00
- name: Download codex
2024-10-11 16:10:20 +02:00
if: steps.codex-cache-restore.outputs.cache-hit != 'true'
2024-10-11 13:07:50 +02:00
run: |
curl -LO https://github.com/codex-storage/nim-codex/releases/download/${codex_version}/codex-${codex_version}-${platform}-${architecture}.tar.gz
curl -LO https://github.com/codex-storage/nim-codex/releases/download/${codex_version}/codex-${codex_version}-${platform}-${architecture}.tar.gz.sha256
sha256sum -c codex-${codex_version}-${platform}-${architecture}.tar.gz.sha256
[[ $? -eq 0 ]] && { echo "Checksum is OK"; } || { echo "Checksum failed"; exit 1; }
tar -zxvf codex-${codex_version}-${platform}-${architecture}.tar.gz
2024-10-11 12:00:36 +02:00
2024-10-11 15:41:49 +02:00
- name: Cache codex
2024-10-11 16:10:20 +02:00
id: codex-cache
2024-10-11 15:46:12 +02:00
uses: actions/cache/save@v4
2024-10-11 15:41:49 +02:00
with:
2024-10-11 16:20:01 +02:00
path: ./codex-${{ env.codex_version }}-${{ env.platform }}-${{ env.architecture }}
2024-10-11 16:10:20 +02:00
key: ${{ steps.codex-cache-restore.outputs.cache-primary-key }}
2024-10-11 15:41:49 +02:00
2024-10-11 13:07:50 +02:00
- name: Run Codex node
run: |
2024-10-11 12:00:36 +02:00
# Get an eth address
2024-10-11 11:32:03 +02:00
response=$(curl -s https://key.codex.storage)
awk -F ': ' '/private/ {print $2}' <<<"${response}" > eth.key
awk -F ': ' '/address/ {print $2}' <<<"${response}" > eth.address
chmod 600 eth.key
# Run
2024-10-11 13:23:06 +02:00
./codex-${codex_version}-${platform}-${architecture} --data-dir=datadir --api-cors-origin="*" persistence --eth-provider=${eth_provider} --eth-private-key=./eth.key --marketplace-address=${marketplace_address} prover --circuit-dir=./datadir/circuits &
2024-10-11 11:32:03 +02:00
2024-10-11 12:41:21 +02:00
sleep 15
2024-10-11 13:07:50 +02:00
2024-10-11 11:32:03 +02:00
- name: Check Codex API
run: |
curl --max-time 5 --fail localhost:8080/api/codex/v1/debug/info -w "\n"
[[ $? -eq 0 ]] && { echo "Codex node is up"; } || { echo "Please check Codex node"; exit 1; }
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
2024-10-11 15:58:36 +02:00
- uses: actions/cache@v4
id: npm-cache
2024-10-11 13:07:50 +02:00
with:
path: ~/.npm
2024-10-11 15:58:36 +02:00
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
2024-10-11 13:07:50 +02:00
2024-10-11 16:10:20 +02:00
- name: Install dependencies
2024-10-11 11:32:03 +02:00
run: npm ci
2024-10-11 15:58:36 +02:00
- uses: actions/cache@v4
2024-10-11 16:10:20 +02:00
id: playwright-browsers-cache
2024-10-11 15:58:36 +02:00
with:
path: ~/.cache/ms-playwright
2024-10-11 16:02:21 +02:00
key: ${{ runner.os }}-node-${{ hashFiles('**/playwright.config.ts') }}
2024-10-11 15:58:36 +02:00
2024-10-11 16:19:51 +02:00
- if: steps.playwright-browsers-cache.outputs.cache-hit != 'true'
2024-10-11 15:58:36 +02:00
name: Install Playwright Browsers
2024-10-11 11:32:03 +02:00
run: npx playwright install --with-deps
- name: Run Playwright tests
2024-10-11 15:58:36 +02:00
run: npm run test
2024-10-11 11:32:03 +02:00
- uses: actions/upload-artifact@v4
# if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30