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
285 changes: 163 additions & 122 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

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

env:
CARGO_TERM_COLOR: always
Expand All @@ -14,42 +14,42 @@ jobs:
frontend:
name: Frontend Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
run: |
cd frontend
npm ci
- name: Run linter
run: |
cd frontend
npm run lint
- name: Run tests
run: |
cd frontend
npm run test:run
- name: Build frontend
run: |
cd frontend
npm run build
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json

- name: Install dependencies
run: |
cd frontend
npm ci

- name: Run linter
run: |
cd frontend
npm run lint

- name: Run tests
run: |
cd frontend
npm run test:run

- name: Build frontend
run: |
cd frontend
npm run build

backend:
name: Backend Tests
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
Expand All @@ -64,57 +64,99 @@ jobs:
--health-retries 5
ports:
- 5432:5432

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

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
override: true

- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
backend/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install dependencies
run: |
cd backend
cargo build --verbose

- name: Run clippy
run: |
cd backend
cargo clippy --all-targets --all-features -- -D warnings

- name: Run rustfmt
run: |
cd backend
cargo fmt --all -- --check

- name: Run tests
run: |
cd backend
cargo test --verbose
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
override: true

- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
backend/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Install dependencies
run: |
cd backend
cargo build --verbose

- name: Run clippy
run: |
cd backend
cargo clippy --all-targets --all-features -- -D warnings

- name: Run rustfmt
run: |
cd backend
cargo fmt --all -- --check

- name: Run tests
run: |
cd backend
cargo test --verbose
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test

smart-contracts:
name: Smart Contracts Tests
runs-on: ubuntu-latest

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

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
components: forge, cast, anvil, chisel

- name: Cache Foundry
uses: actions/cache@v3
with:
path: |
~/.foundry
the-guild-smart-contracts/cache
the-guild-smart-contracts/out
key: ${{ runner.os }}-foundry-${{ hashFiles('the-guild-smart-contracts/foundry.lock') }}
restore-keys: |
${{ runner.os }}-foundry-

- name: Build contracts
run: |
cd the-guild-smart-contracts
forge build

- name: Run tests
run: |
cd the-guild-smart-contracts
forge test --verbosity

- name: Run tests with gas reporting
run: |
cd the-guild-smart-contracts
forge test --gas-report

integration:
name: Integration Tests
runs-on: ubuntu-latest
needs: [frontend, backend]
needs: [frontend, backend, smart-contracts]

services:
postgres:
image: postgres:15
Expand All @@ -129,53 +171,52 @@ jobs:
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install dependencies
run: |
cd frontend && npm ci
cd ../backend && cargo build
- name: Run integration tests
run: |
cd backend
cargo test --test integration_tests --verbose
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: frontend/package-lock.json

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install dependencies
run: |
cd frontend && npm ci
cd ../backend && cargo build

- name: Run integration tests
run: |
cd backend
cargo test --test integration_tests --verbose
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test
TEST_DATABASE_URL: postgres://postgres:postgres@localhost:5432/guild_genesis_test

docker:
name: Docker Build Test
runs-on: ubuntu-latest
needs: [frontend, backend]
needs: [frontend, backend, smart-contracts]

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and test Docker images
run: |
docker-compose build
docker-compose up -d postgres
sleep 10
docker-compose up --build --abort-on-container-exit backend frontend
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and test Docker images
run: |
docker-compose build
docker-compose up -d postgres
sleep 10
docker-compose up --build --abort-on-container-exit backend frontend
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "the-guild-smart-contracts/lib/forge-std"]
path = the-guild-smart-contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
Loading
Loading