|
6 | 6 | pull_request: |
7 | 7 | branches: [ main, 'release/**' ] |
8 | 8 |
|
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 12 | + |
9 | 13 | jobs: |
10 | 14 | build: |
11 | 15 | runs-on: ubuntu-latest |
12 | 16 |
|
13 | 17 | steps: |
14 | | - - uses: actions/checkout@v3 |
15 | | - |
16 | | - - name: Setup LCOV |
17 | | - uses: hrishikesh-kadam/setup-lcov@v1 |
| 18 | + - uses: actions/checkout@v4 |
18 | 19 |
|
19 | 20 | - name: Setup Node environment |
20 | | - uses: actions/setup-node@v3 |
| 21 | + uses: actions/setup-node@v4 |
21 | 22 | with: |
22 | 23 | node-version: 20 |
| 24 | + cache: 'yarn' |
23 | 25 |
|
24 | 26 | - name: Install Yarn |
25 | 27 | run: npm install -g yarn |
26 | 28 |
|
| 29 | + # Cache node_modules archive keyed on lockfile + os + arch + node version (keytar.node is arch-specific) |
| 30 | + - name: Restore node_modules cache |
| 31 | + id: node-modules-cache |
| 32 | + uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + path: .build/node_modules_cache |
| 35 | + key: node_modules-${{ runner.os }}-${{ runner.arch }}-node20-${{ hashFiles('yarn.lock', 'package.json') }} |
| 36 | + |
| 37 | + - name: Extract node_modules archive |
| 38 | + if: steps.node-modules-cache.outputs.cache-hit == 'true' |
| 39 | + shell: bash |
| 40 | + run: tar -xzf .build/node_modules_cache/cache.tgz |
| 41 | + |
27 | 42 | - name: Install dependencies |
28 | | - run: yarn install |
| 43 | + if: steps.node-modules-cache.outputs.cache-hit != 'true' |
| 44 | + run: yarn install --frozen-lockfile |
| 45 | + |
| 46 | + - name: Create node_modules archive |
| 47 | + if: steps.node-modules-cache.outputs.cache-hit != 'true' |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + mkdir -p .build/node_modules_cache |
| 51 | + tar -czf .build/node_modules_cache/cache.tgz node_modules |
29 | 52 |
|
30 | 53 | - name: Build the extension |
31 | | - run: yarn compile-production |
| 54 | + run: yarn compile-production-ci |
32 | 55 |
|
33 | 56 | - name: Lint |
34 | 57 | run: yarn lint |
35 | 58 |
|
36 | 59 | - name: Install CMake/Ninja |
37 | 60 | uses: lukka/get-cmake@latest |
38 | 61 | with: |
39 | | - cmakeVersion: 3.18.3 |
40 | | - ninjaVersion: 1.10.1 |
| 62 | + cmakeVersion: 3.18.3 |
| 63 | + ninjaVersion: 1.10.1 |
| 64 | + |
| 65 | + # Cache fakebin to skip rebuild when source unchanged |
| 66 | + - name: Restore fakebin cache |
| 67 | + id: fakebin-cache |
| 68 | + uses: actions/cache@v4 |
| 69 | + with: |
| 70 | + path: test/fakebin |
| 71 | + key: fakebin-${{ runner.os }}-${{ hashFiles('test/fakeOutputGenerator/CMakeLists.txt', 'test/fakeOutputGenerator/main.cpp', 'test/fakeOutputGenerator/configfiles/**') }} |
41 | 72 |
|
42 | 73 | - name: Build fake compilers for tests |
43 | | - uses: urkle/action-cmake-build@v1.0.0 |
| 74 | + if: steps.fakebin-cache.outputs.cache-hit != 'true' |
| 75 | + run: yarn pretest-buildfakebin |
| 76 | + |
| 77 | + # Ensure fakebin files are executable (cache may not preserve permissions) |
| 78 | + - name: Fix fakebin permissions |
| 79 | + run: chmod +x test/fakebin/* || true |
| 80 | + |
| 81 | + # Compile test TypeScript ONCE for all matrix jobs |
| 82 | + - name: Compile test sources |
| 83 | + run: yarn pretest |
| 84 | + |
| 85 | + # Package build outputs for the matrix test jobs. node_modules is reused via the cache above |
| 86 | + # (matrix jobs use the same cache key); only build/test artifacts are uploaded here. |
| 87 | + - name: Pack build outputs |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + tar -czf build-outputs.tgz \ |
| 91 | + out \ |
| 92 | + dist \ |
| 93 | + test/fakebin |
| 94 | +
|
| 95 | + - name: Upload build outputs |
| 96 | + uses: actions/upload-artifact@v4 |
44 | 97 | with: |
45 | | - source-dir: ${{ github.workspace }}/test/fakeOutputGenerator |
46 | | - configure-options: -DCMAKE_INSTALL_PREFIX:STRING=${{ github.workspace }}/test/fakebin |
47 | | - install-build: true |
| 98 | + name: build-outputs-${{ runner.os }} |
| 99 | + path: build-outputs.tgz |
| 100 | + retention-days: 1 |
| 101 | + if-no-files-found: error |
| 102 | + |
| 103 | + test: |
| 104 | + name: test (${{ matrix.suite.name }}) |
| 105 | + needs: build |
| 106 | + runs-on: ubuntu-latest |
48 | 107 |
|
49 | | - - name: Run backend tests |
50 | | - run: yarn backendTests |
| 108 | + strategy: |
| 109 | + fail-fast: false |
| 110 | + matrix: |
| 111 | + suite: |
| 112 | + - { name: backend, cmd: 'yarn backendTests', timeout: 5 } |
| 113 | + - { name: smoke, cmd: 'yarn smokeTests-only', timeout: 15 } |
| 114 | + - { name: unit, cmd: 'yarn unitTests-only', timeout: 20 } |
| 115 | + - { name: integration, cmd: 'yarn integrationTests-only', timeout: 15 } |
| 116 | + - { name: e2e-successful, cmd: 'yarn endToEndTestsSuccessfulBuild-only', timeout: 25 } |
| 117 | + - { name: e2e-single-root, cmd: 'yarn endToEndTestsSingleRoot-only', timeout: 25 } |
| 118 | + - { name: e2e-single-root-ctest, cmd: 'yarn endToEndTestsSingleRootCTest-only', timeout: 25 } |
| 119 | + - { name: e2e-multi-root, cmd: 'yarn endToEndTestsMultiRoot-only', timeout: 25 } |
51 | 120 |
|
52 | | - - name: Run smoke tests |
53 | | - uses: GabrielBB/xvfb-action@v1.6 |
54 | | - with: |
55 | | - run: yarn smokeTests |
| 121 | + steps: |
| 122 | + - uses: actions/checkout@v4 |
56 | 123 |
|
57 | | - - name: Run unit tests |
58 | | - uses: GabrielBB/xvfb-action@v1.6 |
| 124 | + - name: Setup Node environment |
| 125 | + uses: actions/setup-node@v4 |
59 | 126 | with: |
60 | | - run: yarn unitTests |
| 127 | + node-version: 20 |
| 128 | + cache: 'yarn' |
| 129 | + |
| 130 | + - name: Install Yarn |
| 131 | + run: npm install -g yarn |
61 | 132 |
|
62 | | - - name: Run integration tests |
63 | | - uses: GabrielBB/xvfb-action@v1.6 |
| 133 | + # Restore the SAME node_modules cache the build job populated (key must match). |
| 134 | + - name: Restore node_modules cache |
| 135 | + id: node-modules-cache |
| 136 | + uses: actions/cache@v4 |
64 | 137 | with: |
65 | | - run: yarn integrationTests |
| 138 | + path: .build/node_modules_cache |
| 139 | + key: node_modules-${{ runner.os }}-${{ runner.arch }}-node20-${{ hashFiles('yarn.lock', 'package.json') }} |
| 140 | + |
| 141 | + - name: Extract node_modules archive |
| 142 | + if: steps.node-modules-cache.outputs.cache-hit == 'true' |
| 143 | + shell: bash |
| 144 | + run: tar -xzf .build/node_modules_cache/cache.tgz |
66 | 145 |
|
67 | | - - name: Run successful-build test |
68 | | - uses: GabrielBB/xvfb-action@v1.6 |
| 146 | + # Fallback: install fresh if the build job's cache was evicted between jobs (rare). |
| 147 | + - name: Install dependencies (fallback) |
| 148 | + if: steps.node-modules-cache.outputs.cache-hit != 'true' |
| 149 | + run: yarn install --frozen-lockfile |
| 150 | + |
| 151 | + - name: Download build outputs |
| 152 | + uses: actions/download-artifact@v4 |
69 | 153 | with: |
70 | | - run: yarn endToEndTestsSuccessfulBuild |
| 154 | + name: build-outputs-${{ runner.os }} |
| 155 | + |
| 156 | + - name: Unpack build outputs |
| 157 | + shell: bash |
| 158 | + run: tar -xzf build-outputs.tgz |
71 | 159 |
|
72 | | - - name: Run single root test |
73 | | - uses: GabrielBB/xvfb-action@v1.6 |
| 160 | + - name: Install CMake/Ninja |
| 161 | + uses: lukka/get-cmake@latest |
74 | 162 | with: |
75 | | - run: yarn endToEndTestsSingleRoot |
| 163 | + cmakeVersion: 3.18.3 |
| 164 | + ninjaVersion: 1.10.1 |
| 165 | + |
| 166 | + # Ensure fakebin files are executable (artifact tar may preserve perms but be defensive) |
| 167 | + - name: Fix fakebin permissions |
| 168 | + run: chmod +x test/fakebin/* || true |
76 | 169 |
|
77 | | - - name: Run multi root test |
78 | | - uses: GabrielBB/xvfb-action@v1.6 |
| 170 | + # Cache VS Code download for E2E / smoke / unit / integration tests |
| 171 | + - name: Restore VS Code cache |
| 172 | + uses: actions/cache@v4 |
79 | 173 | with: |
80 | | - run: yarn endToEndTestsMultiRoot |
| 174 | + path: .vscode-test |
| 175 | + key: vscode-test-${{ runner.os }}-stable |
| 176 | + restore-keys: vscode-test-${{ runner.os }}- |
| 177 | + |
| 178 | + - name: Start Xvfb |
| 179 | + if: matrix.suite.name != 'backend' |
| 180 | + run: | |
| 181 | + # xvfb is not preinstalled on ubuntu-latest runners |
| 182 | + if ! command -v Xvfb >/dev/null 2>&1; then |
| 183 | + sudo apt-get update |
| 184 | + sudo apt-get install -y --no-install-recommends xvfb |
| 185 | + fi |
| 186 | + Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp & |
| 187 | + # Wait for the Xvfb socket to be ready (no extra packages needed) |
| 188 | + for i in $(seq 1 40); do |
| 189 | + if [ -S /tmp/.X11-unix/X99 ]; then |
| 190 | + break |
| 191 | + fi |
| 192 | + sleep 0.25 |
| 193 | + done |
| 194 | + if [ ! -S /tmp/.X11-unix/X99 ]; then |
| 195 | + echo "Xvfb failed to start" >&2 |
| 196 | + exit 1 |
| 197 | + fi |
| 198 | + echo "DISPLAY=:99" >> "$GITHUB_ENV" |
| 199 | +
|
| 200 | + - name: Run ${{ matrix.suite.name }} tests |
| 201 | + timeout-minutes: ${{ matrix.suite.timeout }} |
| 202 | + run: ${{ matrix.suite.cmd }} |
81 | 203 |
|
82 | 204 | - name: Upload test logs if tests failed |
83 | 205 | if: failure() |
84 | 206 | uses: actions/upload-artifact@v4 |
85 | 207 | with: |
86 | | - name: TestLogs |
| 208 | + name: TestLogs-${{ runner.os }}-${{ matrix.suite.name }} |
87 | 209 | path: test/**/log.txt |
88 | 210 | if-no-files-found: warn |
0 commit comments