Merge pull request #228 from milah-247/test/utility-functions-158-161 #160
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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18.x, 20.x] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Cache node_modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Cache Next.js build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.npm | |
| ${{ github.workspace }}/.next/cache | |
| key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Create env file | |
| run: | | |
| cp .env.example .env.local | |
| sed -i 's|=your_paycrest_api_key_here|=dummy_value|' .env.local | |
| sed -i 's|=your_paycrest_webhook_secret_here|=dummy_value|' .env.local | |
| sed -i 's|=0xyour_base_private_key_here|=0x0000000000000000000000000000000000000000000000000000000000000001|' .env.local | |
| sed -i 's|=0xyour_base_return_address_here|=0x0000000000000000000000000000000000000001|g' .env.local | |
| sed -i 's|=your_stellar_usdc_issuer_here|=GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5|' .env.local | |
| sed -i 's|=your_sentry_dsn_here|=|g' .env.local | |
| sed -i 's|=your_sentry_org_slug|=dummy|' .env.local | |
| sed -i 's|=your_sentry_project_slug|=dummy|' .env.local | |
| sed -i 's|=your_sentry_auth_token_here|=|' .env.local | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Run build | |
| run: npm run build | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| - name: Run tests | |
| run: npm test | |
| - name: Check bundle size | |
| if: matrix.node-version == '20.x' | |
| run: | | |
| BUILD_SIZE=$(du -sb .next | cut -f1) | |
| echo "Build size: $BUILD_SIZE bytes" | |
| # Fail if build size exceeds 150MB (adjust baseline as needed) | |
| MAX_SIZE=157286400 | |
| if [ "$BUILD_SIZE" -gt "$MAX_SIZE" ]; then | |
| echo "Bundle size $BUILD_SIZE exceeds limit $MAX_SIZE" | |
| exit 1 | |
| fi | |
| - name: Upload build artifacts | |
| if: matrix.node-version == '20.x' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-files | |
| path: .next/ | |
| retention-days: 1 |