Create Component Library #103
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: Test | |
| on: | |
| pull_request: | |
| branches: [ "**" ] | |
| push: | |
| branches: [main, develop] | |
| jobs: | |
| unit-tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Type check | |
| run: npx tsc --noEmit | |
| - name: Lint | |
| run: npm run lint | |
| - name: Run unit tests with coverage | |
| run: npm run test -- --coverage | |
| env: | |
| CI: true | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage/lcov.info | |
| flags: unit-tests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright | |
| run: npx playwright install --with-deps | |
| - name: Run integration tests | |
| run: npm run e2e | |
| env: | |
| CI: true | |
| component-tests: | |
| name: Component Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build application | |
| run: npm run build | |
| env: | |
| CI: true | |
| NEXT_PUBLIC_NETWORK: testnet | |
| - name: Run component tests | |
| run: npm run test -- --run | |
| env: | |
| CI: true | |
| web3-tests: | |
| name: Web3 Interaction Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run Web3 interaction tests | |
| run: npm run test src/__tests__/web3-interactions.test.ts | |
| env: | |
| CI: true | |
| NEXT_PUBLIC_NETWORK: testnet | |
| NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.WALLETCONNECT_PROJECT_ID }} | |
| e2e-tests: | |
| name: E2E Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright | |
| run: npx playwright install --with-deps | |
| - name: Build application for E2E | |
| run: npm run build | |
| env: | |
| CI: true | |
| NEXT_PUBLIC_NETWORK: testnet | |
| NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.WALLETCONNECT_PROJECT_ID }} | |
| - name: Run E2E tests | |
| run: npm run e2e | |
| env: | |
| CI: true | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 30 | |
| coverage-report: | |
| name: Coverage Report | |
| needs: [unit-tests, integration-tests, component-tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run all tests with coverage | |
| run: npm run test -- --coverage | |
| env: | |
| CI: true | |
| - name: Check coverage threshold | |
| run: | | |
| # Check if coverage meets the 80% threshold | |
| npm run test -- --coverage --reporter=verbose | grep "All files" | awk '{print $4}' | sed 's/%//' | { | |
| read coverage | |
| if (( $(echo "$coverage < 80" | bc -l) )); then | |
| echo "Coverage $coverage% is below 80% threshold" | |
| exit 1 | |
| else | |
| echo "Coverage $coverage% meets the 80% threshold" | |
| fi | |
| } | |
| security-tests: | |
| name: Security Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run security tests | |
| run: npm run test src/__tests__/security.test.ts | |
| env: | |
| CI: true |