fix(test): create separate vitest config for integration tests #650
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 | |
| # Dependencies: | |
| # - SocketDev/socket-registry/.github/workflows/ci.yml | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['*'] | |
| paths: | |
| - 'packages/cli/**' | |
| - 'pnpm-lock.yaml' | |
| - 'package.json' | |
| - '.github/workflows/ci.yml' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'packages/cli/**' | |
| - 'pnpm-lock.yaml' | |
| - 'package.json' | |
| - '.github/workflows/ci.yml' | |
| workflow_dispatch: | |
| inputs: | |
| node-versions: | |
| description: 'Node.js versions to test (JSON array)' | |
| required: false | |
| type: string | |
| default: '["24.10.0"]' | |
| permissions: | |
| contents: read | |
| jobs: | |
| ci: | |
| name: Run CI Pipeline | |
| uses: SocketDev/socket-registry/.github/workflows/ci.yml@1a96ced97aaa85d61543351b90d6f463b983c46c # main | |
| with: | |
| test-setup-script: 'pnpm --filter @socketsecurity/cli run build' | |
| lint-script: 'pnpm --filter @socketsecurity/cli run check' | |
| type-check-script: 'pnpm --filter @socketsecurity/cli run type' | |
| test-script: 'echo "Tests run in sharded job below"' | |
| node-versions: ${{ inputs.node-versions || '["24.10.0"]' }} | |
| os-versions: '["ubuntu-latest"]' | |
| fail-fast: false | |
| max-parallel: 4 | |
| test-timeout-minutes: 15 | |
| # Sharded unit tests for faster CI. | |
| # Splits 2,819 tests across 3 shards (~16s per shard vs 48s monolithic). | |
| # Runs on Linux only to optimize CI runtime and build requirements. | |
| test-sharded: | |
| name: Unit Tests (Shard ${{ matrix.shard }}/3) | |
| needs: ci | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 4 | |
| matrix: | |
| node-version: ${{ fromJSON(inputs.node-versions || '["24.10.0"]') }} | |
| shard: [1, 2, 3] | |
| steps: | |
| - uses: SocketDev/socket-registry/.github/actions/setup-and-install@1a96ced97aaa85d61543351b90d6f463b983c46c # main | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Build CLI | |
| working-directory: packages/cli | |
| run: pnpm run build | |
| - name: Run unit tests (shard ${{ matrix.shard }}) | |
| working-directory: packages/cli | |
| run: pnpm test:unit --shard=${{ matrix.shard }}/3 | |
| # Binary distribution integration tests. | |
| # Tests the JS distribution and optionally SEA/smol if cached binaries are available. | |
| integration: | |
| name: Integration Tests (${{ matrix.distribution }}) | |
| needs: ci | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: ['24.10.0'] | |
| distribution: ['js'] | |
| steps: | |
| - uses: SocketDev/socket-registry/.github/actions/setup-and-install@1a96ced97aaa85d61543351b90d6f463b983c46c # main | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Build CLI | |
| working-directory: packages/cli | |
| run: pnpm run build | |
| - name: Run integration tests (${{ matrix.distribution }}) | |
| working-directory: packages/cli | |
| run: node scripts/integration.mjs --${{ matrix.distribution }} | |
| e2e: | |
| name: E2E Tests | |
| needs: ci | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 20 | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| node-version: ['24.10.0'] | |
| os: [ubuntu-latest] | |
| steps: | |
| - uses: SocketDev/socket-registry/.github/actions/setup-and-install@1a96ced97aaa85d61543351b90d6f463b983c46c # main | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Build CLI | |
| working-directory: packages/cli | |
| run: pnpm run build | |
| - name: Run e2e tests | |
| working-directory: packages/cli | |
| env: | |
| SOCKET_CLI_API_TOKEN: ${{ secrets.SOCKET_CLI_API_TOKEN }} | |
| run: pnpm run e2e-tests |