Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
99 changes: 99 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Test and Build

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.12.0'

# Frontend Linting
- name: Install frontend dependencies
working-directory: packages/demo-app-frontend
run: npm ci

- name: Run ESLint (Frontend)
working-directory: packages/demo-app-frontend
run: npm run lint

- name: Check Prettier formatting (Frontend)
working-directory: packages/demo-app-frontend
run: npx prettier --check .

# Solidity Linting
- name: Install contract dependencies
working-directory: packages/trust-anchor-did-ethr
run: npm ci

- name: Run Solhint (Contracts)
working-directory: packages/trust-anchor-did-ethr
run: npx solhint 'contracts/**/*.sol'

test:
name: Test
needs: lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.12.0'
cache: 'npm'
cache-dependency-path: packages/trust-anchor-did-ethr/package-lock.json

- name: Install dependencies
working-directory: packages/trust-anchor-did-ethr
run: npm ci

- name: Run Hardhat tests
working-directory: packages/trust-anchor-did-ethr
run: npx hardhat test

build:
name: Build
needs: test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.12.0'

# Compile Contracts
- name: Install contract dependencies
working-directory: packages/trust-anchor-did-ethr
run: npm ci

- name: Compile smart contracts
working-directory: packages/trust-anchor-did-ethr
run: npx hardhat compile

# Build Frontend
- name: Install frontend dependencies
working-directory: packages/demo-app-frontend
run: npm ci

- name: Build frontend
working-directory: packages/demo-app-frontend
run: npm run build
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cd packages/demo-app-frontend && npx lint-staged
48 changes: 48 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Installation](#installation)
- [Running the Project](#running-the-project)
- [Testing](#testing)
- [Development Workflow](#development-workflow)
- [TypeScript Configuration](#typescript-configuration)
- [Platform-Specific Notes](#platform-specific-notes)
- [Deployment](#deployment)
Expand Down Expand Up @@ -66,6 +67,14 @@ This project uses the following key dependencies:

## Installation

### Install Root Dependencies

First, install root dependencies (required for Husky pre-commit hooks):

```bash
npm install
```

### Install Dependencies for Each Package

#### 1. Smart Contracts (trust-anchor-did-ethr)
Expand Down Expand Up @@ -187,6 +196,45 @@ cd packages/demo-app-frontend
npm run lint
```

## Development Workflow

### Pre-commit Hooks

This project uses [Husky](https://typicode.github.io/husky/) and [lint-staged](https://github.com/okonet/lint-staged) to automatically lint your code before commits:

**What happens when you commit:**
1. You stage files: `git add src/components/MyComponent.tsx`
2. You commit: `git commit -m "fix: update component"`
3. Pre-commit hook runs automatically:
- ESLint checks code quality and fixes issues
- Prettier formats code (indentation, spacing, etc.)
- Both tools auto-fix and re-stage files
- Unfixable errors block the commit
4. If successful, commit proceeds with clean, formatted code

**Manual formatting:**
```bash
npm run format # Format all files with Prettier
npm run lint # Check code quality with ESLint
```

**Configuration:**
- Hook script: `.husky/pre-commit`
- Prettier rules: `packages/demo-app-frontend/.prettierrc`
- ESLint rules: `packages/demo-app-frontend/eslint.config.js`
- Staged file rules: `packages/demo-app-frontend/package.json` → `lint-staged` section

### Continuous Integration (GitHub Actions)

Pull requests and pushes to `main` trigger automated checks (`.github/workflows/ci.yml`):

**CI Jobs:**
1. **Frontend Linting**: Runs ESLint on entire frontend codebase
2. **Frontend Formatting**: Checks Prettier formatting compliance
3. **Contract Validation**: Compiles smart contracts and runs full test suite

**All checks must pass before merging.** The CI uses Node.js 22.12.0 to match local development.

## TypeScript Configuration

### Smart Contracts (trust-anchor-did-ethr)
Expand Down
Loading