Skip to content

Merge pull request #255 from Oluwatomilola/restructure #302

Merge pull request #255 from Oluwatomilola/restructure

Merge pull request #255 from Oluwatomilola/restructure #302

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: [ main ]
workflow_dispatch:
inputs:
deploy:
description: 'Run optional deploy job'
required: false
default: 'false'
jobs:
test:
name: Lint, Type-check, Build (Frontend)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: frontend
run: npm ci
- name: Lint
working-directory: frontend
run: npm run lint
- name: Type check
working-directory: frontend
run: npm run type-check
- name: Build
working-directory: frontend
run: npm run build
foundry-tests:
name: Contracts Tests (Foundry) — optional if foundry.toml exists
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Fetch full history for better dependency caching
fetch-depth: 0
- name: Check if foundry.toml exists
id: check-foundry
run: |
if [ -f "foundry.toml" ]; then
echo "foundry_exists=true" >> $GITHUB_OUTPUT
echo "Foundry configuration found"
else
echo "foundry_exists=false" >> $GITHUB_OUTPUT
echo "No foundry.toml found, skipping Foundry tests"
fi
- name: Install Foundry
if: steps.check-foundry.outputs.foundry_exists == 'true'
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Cache Foundry dependencies
if: steps.check-foundry.outputs.foundry_exists == 'true'
uses: actions/cache@v4
with:
path: |
~/.foundry//cache
~/.foundry/toolchains
key: foundry-${{ runner.os }}-${{ hashFiles('**/foundry.toml', '**/lock') }}
restore-keys: |
foundry-${{ runner.os }}-
foundry-
- name: Install deps (forge install)
if: steps.check-foundry.outputs.foundry_exists == 'true'
run: |
# Install git submodules if they exist
if [ -f .gitmodules ]; then
git submodule sync --recursive
git submodule update --init --recursive
fi
forge install
- name: Build (forge build)
if: steps.check-foundry.outputs.foundry_exists == 'true'
run: forge build
- name: Test (forge test)
if: steps.check-foundry.outputs.foundry_exists == 'true'
run: |
# Only run tests if test files exist
if [ -d "test" ] && [ "$(find test -name "*.sol" | wc -l)" -gt 0 ]; then
forge test -vvv
else
echo "No test files found, skipping forge test"
fi
deploy:
name: Optional Deploy (manual)
needs: [ test ]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && inputs.deploy == 'true'
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
RPC_URL: ${{ secrets.RPC_URL }}
EXPLORER_API_KEY: ${{ secrets.EXPLORER_API_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Verify required secrets
run: |
if [ -z "${PRIVATE_KEY}" ] || [ -z "${RPC_URL}" ]; then
echo "Missing secrets PRIVATE_KEY or RPC_URL"; exit 1; fi
echo "Secrets present. This repo hosts the frontend; deploy/verify typically runs in the contracts repo."
- name: Placeholder deploy step
run: echo "Implement deployment in the contracts repository or add your scripts here."