|
1 | 1 | name: ⚡ CI |
2 | 2 |
|
3 | | -# Optimized CI with: |
4 | | -# - Separate lint job (1x instead of 6x) |
5 | | -# - Separate build verification job |
6 | | -# - Parallel job execution |
7 | | -# - pnpm dependency caching via setup-node |
| 3 | +# Dependencies: |
| 4 | +# - SocketDev/socket-registry/.github/workflows/ci.yml |
8 | 5 |
|
9 | 6 | on: |
10 | 7 | push: |
|
13 | 10 | pull_request: |
14 | 11 | branches: [main] |
15 | 12 | workflow_dispatch: |
| 13 | + inputs: |
| 14 | + node-versions: |
| 15 | + description: 'Node.js versions to test (JSON array)' |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + default: '["24.10.0"]' |
16 | 19 |
|
17 | 20 | permissions: |
18 | 21 | contents: read |
19 | 22 |
|
20 | 23 | jobs: |
21 | | - # Separate lint job - runs once instead of 6x in matrix |
22 | | - lint: |
23 | | - name: Lint |
24 | | - runs-on: ubuntu-latest |
25 | | - timeout-minutes: 10 |
26 | | - steps: |
27 | | - - name: Checkout code |
28 | | - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
29 | | - |
30 | | - - name: Setup pnpm |
31 | | - uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0 |
32 | | - # NOTE: Do not specify version - pnpm-action-setup automatically reads |
33 | | - # the version from the packageManager field in package.json. |
34 | | - |
35 | | - - name: Setup Node.js |
36 | | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
37 | | - with: |
38 | | - node-version: 22 |
39 | | - cache: 'pnpm' |
40 | | - |
41 | | - - name: Install dependencies |
42 | | - run: pnpm install --frozen-lockfile |
43 | | - |
44 | | - - name: Run lint |
45 | | - run: pnpm run lint --all |
46 | | - |
47 | | - # Build job - runs once and caches artifacts |
48 | | - build: |
49 | | - name: Build |
50 | | - runs-on: ubuntu-latest |
51 | | - timeout-minutes: 10 |
52 | | - steps: |
53 | | - - name: Checkout code |
54 | | - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
55 | | - |
56 | | - - name: Setup pnpm |
57 | | - uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0 |
58 | | - # NOTE: Do not specify version - pnpm-action-setup automatically reads |
59 | | - # the version from the packageManager field in package.json. |
60 | | - |
61 | | - - name: Setup Node.js |
62 | | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
63 | | - with: |
64 | | - node-version: 22 |
65 | | - cache: 'pnpm' |
66 | | - |
67 | | - - name: Install dependencies |
68 | | - run: pnpm install --frozen-lockfile |
69 | | - |
70 | | - - name: Build project |
71 | | - run: pnpm run build |
72 | | - |
73 | | - # Test matrix - reuses build artifacts (main test suite) |
74 | | - test: |
75 | | - name: Test |
76 | | - needs: [lint, build] |
77 | | - runs-on: ${{ matrix.os }} |
78 | | - timeout-minutes: 15 |
79 | | - strategy: |
| 24 | + ci: |
| 25 | + name: Run CI Pipeline |
| 26 | + uses: SocketDev/socket-registry/.github/workflows/ci.yml@63ad52562c1f2d007a1833b2b22cffc3001e1cc2 # main |
| 27 | + with: |
| 28 | + test-setup-script: 'pnpm run build' |
| 29 | + lint-script: 'pnpm run lint --all' |
| 30 | + type-check-script: 'pnpm run check' |
| 31 | + test-script: 'pnpm exec vitest --config .config/vitest.config.mts run' |
| 32 | + node-versions: ${{ inputs.node-versions || '["24.10.0"]' }} |
| 33 | + os-versions: '["ubuntu-latest", "windows-latest"]' |
80 | 34 | fail-fast: false |
81 | | - matrix: |
82 | | - node: ['24.10.0'] |
83 | | - os: [ubuntu-latest, windows-latest] |
84 | | - steps: |
85 | | - - name: Checkout code |
86 | | - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
87 | | - |
88 | | - - name: Setup pnpm |
89 | | - uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0 |
90 | | - # NOTE: Do not specify version - pnpm-action-setup automatically reads |
91 | | - # the version from the packageManager field in package.json. |
92 | | - |
93 | | - - name: Setup Node.js |
94 | | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
95 | | - with: |
96 | | - node-version: ${{ matrix.node }} |
97 | | - cache: 'pnpm' |
98 | | - |
99 | | - - name: Install dependencies |
100 | | - run: pnpm install --frozen-lockfile |
101 | | - |
102 | | - - name: Build project |
103 | | - run: pnpm run build |
104 | | - |
105 | | - - name: Run main tests |
106 | | - run: pnpm exec vitest --config .config/vitest.config.mts run |
| 35 | + max-parallel: 4 |
| 36 | + test-timeout-minutes: 15 |
107 | 37 |
|
108 | 38 | # Isolated test suite - runs separately with full isolation |
109 | 39 | test-isolated: |
110 | 40 | name: Test (Isolated) |
111 | | - needs: [lint, build] |
| 41 | + needs: ci |
112 | 42 | runs-on: ubuntu-latest |
113 | 43 | timeout-minutes: 10 |
114 | 44 | steps: |
115 | | - - name: Checkout code |
116 | | - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
117 | | - |
118 | | - - name: Setup pnpm |
119 | | - uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0 |
120 | | - # NOTE: Do not specify version - pnpm-action-setup automatically reads |
121 | | - # the version from the packageManager field in package.json. |
122 | | - |
123 | | - - name: Setup Node.js |
124 | | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 45 | + - uses: SocketDev/socket-registry/.github/actions/setup-and-install@63ad52562c1f2d007a1833b2b22cffc3001e1cc2 # main |
125 | 46 | with: |
126 | | - node-version: 22 |
127 | | - cache: 'pnpm' |
128 | | - |
129 | | - - name: Install dependencies |
130 | | - run: pnpm install --frozen-lockfile |
| 47 | + node-version: '22' |
131 | 48 |
|
132 | 49 | - name: Build project |
133 | 50 | run: pnpm run build |
134 | 51 |
|
135 | 52 | - name: Run isolated tests |
136 | 53 | run: pnpm exec vitest --config .config/vitest.config.isolated.mts run |
137 | | - |
138 | | - # Type check - reuses build artifacts |
139 | | - type-check: |
140 | | - name: Type Check |
141 | | - needs: build |
142 | | - runs-on: ubuntu-latest |
143 | | - timeout-minutes: 10 |
144 | | - steps: |
145 | | - - name: Checkout code |
146 | | - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
147 | | - |
148 | | - - name: Setup pnpm |
149 | | - uses: pnpm/action-setup@9fd676a19091d4595eefd76e4bd31c97133911f1 # v4.2.0 |
150 | | - # NOTE: Do not specify version - pnpm-action-setup automatically reads |
151 | | - # the version from the packageManager field in package.json. |
152 | | - |
153 | | - - name: Setup Node.js |
154 | | - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
155 | | - with: |
156 | | - node-version: 22 |
157 | | - cache: 'pnpm' |
158 | | - |
159 | | - - name: Install dependencies |
160 | | - run: pnpm install --frozen-lockfile |
161 | | - |
162 | | - - name: Run type check |
163 | | - run: pnpm run check |
164 | | - |
165 | | - # Status check job - used as required check in branch protection |
166 | | - ci-success: |
167 | | - name: CI Success |
168 | | - needs: [lint, build, test, test-isolated, type-check] |
169 | | - if: always() |
170 | | - runs-on: ubuntu-latest |
171 | | - steps: |
172 | | - - name: Check job results |
173 | | - run: | |
174 | | - if [ "${{ needs.lint.result }}" != "success" ] || \ |
175 | | - [ "${{ needs.build.result }}" != "success" ] || \ |
176 | | - [ "${{ needs.test.result }}" != "success" ] || \ |
177 | | - [ "${{ needs.test-isolated.result }}" != "success" ] || \ |
178 | | - [ "${{ needs.type-check.result }}" != "success" ]; then |
179 | | - echo "One or more jobs failed" |
180 | | - exit 1 |
181 | | - fi |
182 | | - echo "All CI jobs passed successfully!" |
0 commit comments