test: add comprehensive unit and integration tests for tokenomics (#50) #61
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| NODE_VERSION: '18' | |
| jobs: | |
| # ─── Smart Contracts ───────────────────────────────────────────── | |
| contracts: | |
| name: Contracts | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Build contracts | |
| run: cd contracts && cargo build --lib | |
| - name: Run contract tests | |
| continue-on-error: true | |
| run: cd contracts && cargo test | |
| # ─── Backend ───────────────────────────────────────────────────── | |
| backend: | |
| name: Backend | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: starked_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Install dependencies | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 5 | |
| max_attempts: 2 | |
| retry_on: error | |
| command: cd backend && npm ci | |
| - name: Type check | |
| run: cd backend && npx tsc --noEmit | |
| - name: Lint | |
| continue-on-error: true | |
| run: cd backend && npm run lint | |
| - name: Test | |
| continue-on-error: true | |
| timeout-minutes: 10 | |
| run: cd backend && npm run test:ci | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/starked_test | |
| REDIS_URL: redis://localhost:6379 | |
| JWT_SECRET: test_secret | |
| - name: Build | |
| run: cd backend && npm run build | |
| # ─── Frontend ──────────────────────────────────────────────────── | |
| frontend: | |
| name: Frontend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Install dependencies | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 5 | |
| max_attempts: 2 | |
| retry_on: error | |
| command: cd frontend && npm ci | |
| - name: Type check | |
| continue-on-error: true | |
| run: cd frontend && npx tsc --noEmit | |
| - name: Lint | |
| continue-on-error: true | |
| run: cd frontend && npm run lint | |
| - name: Test | |
| continue-on-error: true | |
| timeout-minutes: 10 | |
| run: cd frontend && npm run test:ci | |
| - name: Build | |
| continue-on-error: true | |
| timeout-minutes: 15 | |
| run: cd frontend && NODE_OPTIONS="--max-old-space-size=4096" npm run build | |
| # ─── Security Scan ─────────────────────────────────────────────── | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run Trivy vulnerability scan | |
| uses: aquasecurity/trivy-action@master | |
| continue-on-error: true | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| - name: Upload scan results | |
| if: always() | |
| continue-on-error: true | |
| uses: github/codeql-action/upload-sarif@v3 | |
| with: | |
| sarif_file: 'trivy-results.sarif' |