|
| 1 | +name: Test Optimized v2 |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['*'] |
| 6 | + pull_request: |
| 7 | + branches: ['*'] |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + # Build once, use in parallel jobs |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v5 |
| 21 | + |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: 22.x |
| 26 | + |
| 27 | + - name: Setup pnpm |
| 28 | + uses: pnpm/action-setup@v4 |
| 29 | + with: |
| 30 | + version: 10.10.0 |
| 31 | + run_install: false |
| 32 | + |
| 33 | + - name: Get pnpm store directory |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 37 | + |
| 38 | + # Create necessary directories for postinstall scripts |
| 39 | + - name: Prepare directories |
| 40 | + run: | |
| 41 | + mkdir -p agents-docs/.source |
| 42 | + touch agents-docs/.source/index.ts |
| 43 | + |
| 44 | + - name: Setup pnpm cache |
| 45 | + uses: actions/cache@v4 |
| 46 | + with: |
| 47 | + path: ${{ env.STORE_PATH }} |
| 48 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-pnpm-store- |
| 51 | + |
| 52 | + # Cache build outputs |
| 53 | + - name: Setup build cache |
| 54 | + id: build-cache |
| 55 | + uses: actions/cache@v4 |
| 56 | + with: |
| 57 | + path: | |
| 58 | + **/dist |
| 59 | + **/.next |
| 60 | + **/build |
| 61 | + **/.turbo |
| 62 | + **/node_modules/.vite |
| 63 | + **/node_modules/.cache |
| 64 | + key: ${{ runner.os }}-build-${{ github.sha }} |
| 65 | + restore-keys: | |
| 66 | + ${{ runner.os }}-build- |
| 67 | + |
| 68 | + - name: Install dependencies |
| 69 | + run: pnpm install --frozen-lockfile |
| 70 | + |
| 71 | + # Build only if not cached |
| 72 | + - name: Build packages |
| 73 | + if: steps.build-cache.outputs.cache-hit != 'true' |
| 74 | + run: pnpm build --concurrency=200% |
| 75 | + env: |
| 76 | + TURBO_TELEMETRY_DISABLED: 1 |
| 77 | + TURBO_CACHE_DIR: .turbo |
| 78 | + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} |
| 79 | + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} |
| 80 | + NODE_OPTIONS: --max-old-space-size=4096 |
| 81 | + |
| 82 | + # Run tests in parallel with typecheck |
| 83 | + test: |
| 84 | + needs: build |
| 85 | + runs-on: ubuntu-latest |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: Checkout code |
| 89 | + uses: actions/checkout@v5 |
| 90 | + |
| 91 | + - name: Setup Node.js |
| 92 | + uses: actions/setup-node@v4 |
| 93 | + with: |
| 94 | + node-version: 22.x |
| 95 | + |
| 96 | + - name: Setup pnpm |
| 97 | + uses: pnpm/action-setup@v4 |
| 98 | + with: |
| 99 | + version: 10.10.0 |
| 100 | + run_install: false |
| 101 | + |
| 102 | + - name: Get pnpm store directory |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 106 | + |
| 107 | + - name: Prepare directories |
| 108 | + run: | |
| 109 | + mkdir -p agents-docs/.source |
| 110 | + touch agents-docs/.source/index.ts |
| 111 | + |
| 112 | + - name: Restore pnpm cache |
| 113 | + uses: actions/cache@v4 |
| 114 | + with: |
| 115 | + path: ${{ env.STORE_PATH }} |
| 116 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 117 | + restore-keys: | |
| 118 | + ${{ runner.os }}-pnpm-store- |
| 119 | + |
| 120 | + - name: Restore build cache |
| 121 | + uses: actions/cache@v4 |
| 122 | + with: |
| 123 | + path: | |
| 124 | + **/dist |
| 125 | + **/.next |
| 126 | + **/build |
| 127 | + **/.turbo |
| 128 | + **/node_modules/.vite |
| 129 | + **/node_modules/.cache |
| 130 | + key: ${{ runner.os }}-build-${{ github.sha }} |
| 131 | + restore-keys: | |
| 132 | + ${{ runner.os }}-build- |
| 133 | + |
| 134 | + - name: Install dependencies |
| 135 | + run: pnpm install --frozen-lockfile |
| 136 | + |
| 137 | + - name: Run tests |
| 138 | + run: pnpm test |
| 139 | + env: |
| 140 | + TURBO_TELEMETRY_DISABLED: 1 |
| 141 | + TURBO_CACHE_DIR: .turbo |
| 142 | + ENVIRONMENT: test |
| 143 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'sk-test-key-for-ci-testing' }} |
| 144 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'sk-ant-test-key-for-ci-testing' }} |
| 145 | + DB_FILE_NAME: test.db |
| 146 | + NODE_OPTIONS: --max-old-space-size=4096 |
| 147 | + |
| 148 | + typecheck: |
| 149 | + needs: build |
| 150 | + runs-on: ubuntu-latest |
| 151 | + |
| 152 | + steps: |
| 153 | + - name: Checkout code |
| 154 | + uses: actions/checkout@v5 |
| 155 | + |
| 156 | + - name: Setup Node.js |
| 157 | + uses: actions/setup-node@v4 |
| 158 | + with: |
| 159 | + node-version: 22.x |
| 160 | + |
| 161 | + - name: Setup pnpm |
| 162 | + uses: pnpm/action-setup@v4 |
| 163 | + with: |
| 164 | + version: 10.10.0 |
| 165 | + run_install: false |
| 166 | + |
| 167 | + - name: Get pnpm store directory |
| 168 | + shell: bash |
| 169 | + run: | |
| 170 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 171 | + |
| 172 | + - name: Prepare directories |
| 173 | + run: | |
| 174 | + mkdir -p agents-docs/.source |
| 175 | + touch agents-docs/.source/index.ts |
| 176 | + |
| 177 | + - name: Restore pnpm cache |
| 178 | + uses: actions/cache@v4 |
| 179 | + with: |
| 180 | + path: ${{ env.STORE_PATH }} |
| 181 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 182 | + restore-keys: | |
| 183 | + ${{ runner.os }}-pnpm-store- |
| 184 | + |
| 185 | + - name: Restore build cache |
| 186 | + uses: actions/cache@v4 |
| 187 | + with: |
| 188 | + path: | |
| 189 | + **/dist |
| 190 | + **/.next |
| 191 | + **/build |
| 192 | + **/.turbo |
| 193 | + **/node_modules/.vite |
| 194 | + **/node_modules/.cache |
| 195 | + key: ${{ runner.os }}-build-${{ github.sha }} |
| 196 | + restore-keys: | |
| 197 | + ${{ runner.os }}-build- |
| 198 | + |
| 199 | + - name: Install dependencies |
| 200 | + run: pnpm install --frozen-lockfile |
| 201 | + |
| 202 | + - name: Run typecheck |
| 203 | + run: pnpm typecheck |
| 204 | + env: |
| 205 | + TURBO_TELEMETRY_DISABLED: 1 |
| 206 | + TURBO_CACHE_DIR: .turbo |
| 207 | + NODE_OPTIONS: --max-old-space-size=4096 |
0 commit comments