|
| 1 | +name: PR Validation |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: pr-validation-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - "**" # Run on push to any branch |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - "**" # Run on PR to any branch |
| 14 | + schedule: |
| 15 | + - cron: "0 0 * * 3" # Wednesdays at midnight check all node js versions |
| 16 | + |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +jobs: |
| 20 | + validate: |
| 21 | + name: Check Code Quality on Node.js ${{ matrix.node-version }} |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 45 |
| 24 | + env: |
| 25 | + TURBO_TELEMETRY_DISABLED: 1 |
| 26 | + |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + # The fromJSON() function converts the JSON string into an actual array |
| 30 | + node-version: ${{ fromJSON((github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') && '[22]' || '[22, 24]') }} |
| 31 | + fail-fast: false |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@v4 |
| 36 | + |
| 37 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: ${{ matrix.node-version }} |
| 41 | + cache: "npm" |
| 42 | + cache-dependency-path: "package-lock.json" |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: npm install |
| 46 | + |
| 47 | + - name: Create environment files for tests |
| 48 | + run: | |
| 49 | + # Create main .env file for agent (mainnet by default) |
| 50 | + # Use absolute path for DATABASE_URL to work from any directory |
| 51 | + # IMPORTANT: No quotes around DATABASE_URL path! |
| 52 | + cat > apps/agent/.env << EOF |
| 53 | + PORT=9200 |
| 54 | + EXPO_PUBLIC_MCP_URL=http://localhost:9200 |
| 55 | + EXPO_PUBLIC_APP_URL=http://localhost:9200 |
| 56 | + DATABASE_URL=${GITHUB_WORKSPACE}/apps/agent/test.db |
| 57 | + OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} |
| 58 | + DKG_PUBLISH_WALLET=${{ secrets.DKG_Node_Private_key }} |
| 59 | + DKG_BLOCKCHAIN=otp:2043 |
| 60 | + DKG_OTNODE_URL=https://positron.origin-trail.network |
| 61 | + EOF |
| 62 | +
|
| 63 | + # Create root .env file for turbo dev (when running from root directory) |
| 64 | + # This is needed because turbo dev runs from root and dotenv looks for .env in cwd |
| 65 | + cat > .env << EOF |
| 66 | + PORT=9200 |
| 67 | + EXPO_PUBLIC_MCP_URL=http://localhost:9200 |
| 68 | + EXPO_PUBLIC_APP_URL=http://localhost:9200 |
| 69 | + DATABASE_URL=${GITHUB_WORKSPACE}/apps/agent/test.db |
| 70 | + OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} |
| 71 | + DKG_PUBLISH_WALLET=${{ secrets.DKG_Node_Private_key }} |
| 72 | + DKG_BLOCKCHAIN=otp:2043 |
| 73 | + DKG_OTNODE_URL=https://positron.origin-trail.network |
| 74 | + EOF |
| 75 | +
|
| 76 | + # Create development override file |
| 77 | + cat > apps/agent/.env.development.local << 'EOF' |
| 78 | + # These values will override the .env file during the development |
| 79 | + EXPO_PUBLIC_APP_URL=http://localhost:8081 |
| 80 | + EOF |
| 81 | +
|
| 82 | + # Create testnet environment file |
| 83 | + mkdir -p apps/agent/tests |
| 84 | + cat > apps/agent/tests/.env.testing.testnet.local << EOF |
| 85 | + PORT=9200 |
| 86 | + EXPO_PUBLIC_MCP_URL=http://localhost:9200 |
| 87 | + EXPO_PUBLIC_APP_URL=http://localhost:9200 |
| 88 | + DATABASE_URL=${GITHUB_WORKSPACE}/apps/agent/test.db |
| 89 | + OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} |
| 90 | + DKG_PUBLISH_WALLET=${{ secrets.DKG_Node_Private_key }} |
| 91 | + DKG_BLOCKCHAIN=otp:20430 |
| 92 | + DKG_OTNODE_URL=https://v6-pegasus-node-02.origin-trail.network |
| 93 | + EOF |
| 94 | +
|
| 95 | + # Create mainnet environment file |
| 96 | + cat > apps/agent/tests/.env.testing.mainnet.local << EOF |
| 97 | + PORT=9200 |
| 98 | + EXPO_PUBLIC_MCP_URL=http://localhost:9200 |
| 99 | + EXPO_PUBLIC_APP_URL=http://localhost:9200 |
| 100 | + DATABASE_URL=${GITHUB_WORKSPACE}/apps/agent/test.db |
| 101 | + OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} |
| 102 | + DKG_PUBLISH_WALLET=${{ secrets.DKG_Node_Private_key }} |
| 103 | + DKG_BLOCKCHAIN=otp:2043 |
| 104 | + DKG_OTNODE_URL=https://positron.origin-trail.network |
| 105 | + EOF |
| 106 | +
|
| 107 | + echo "Environment files created successfully!" |
| 108 | +
|
| 109 | + - name: Install Playwright browsers |
| 110 | + run: npx playwright install --with-deps chromium |
| 111 | + |
| 112 | + - name: Check code quality |
| 113 | + run: npm run check || echo "⚠️ Code quality checks completed with warnings (non-blocking)" |
| 114 | + |
| 115 | + - name: Build packages and apps |
| 116 | + run: npm run build |
| 117 | + |
| 118 | + - name: Create admin user for tests |
| 119 | + run: | |
| 120 | + cd apps/agent |
| 121 | + rm -f test.db test.db-* *.db-journal |
| 122 | + # Create admin user: email password scope firstName lastName |
| 123 | + npm run script:createUser admin@gmail.com admin123 mcp,llm,blob,scope123 Admin User |
| 124 | +
|
| 125 | + - name: Run tests from all packages |
| 126 | + run: npm run test |
| 127 | + env: |
| 128 | + CI: true |
| 129 | + |
| 130 | + - name: Upload test videos and screenshots |
| 131 | + if: failure() |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: test-artifacts-node-${{ matrix.node-version }} |
| 135 | + path: | |
| 136 | + apps/agent/test-results/ |
| 137 | + apps/agent/playwright-report/ |
| 138 | + retention-days: 7 |
| 139 | + if-no-files-found: warn |
0 commit comments