diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f0570c6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + ci: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v7 + with: + # Tests run git log against this repository and need the full history. + fetch-depth: 0 + - uses: pnpm/action-setup@v6 + with: + version: 11 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: pnpm + # The plugin's git revert/cherry-pick spawn git without setting an + # identity (deliberate, see tests/smoke.spec.ts) and rely on ambient + # config; the runner has none by default. + - name: Configure git identity for tests + run: | + git config --global user.name "dsh-better-sidebar-ci" + git config --global user.email "ci@dsh.invalid" + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Typecheck + run: pnpm typecheck + - name: Test + run: pnpm test + - name: Build + run: pnpm build diff --git a/tests/unit.spec.ts b/tests/unit.spec.ts index 4b18516..1202387 100644 --- a/tests/unit.spec.ts +++ b/tests/unit.spec.ts @@ -861,19 +861,26 @@ describe('pty helpers', () => { }) it('restores the spawn-helper executable bit idempotently', () => { - // On non-Windows the helper must exist and be executable after the fix. - if (process.platform === 'win32') return + // node-pty's spawn-helper is a macOS-only artifact: binding.gyp builds + // the executable only for OS=="mac", and no other platform ships one to + // restore (linux uses forkpty directly). Skip elsewhere. + if (process.platform !== 'darwin') return ensureSpawnHelper() ensureSpawnHelper() - const { existsSync } = require('node:fs') as typeof import('node:fs') + const { existsSync, statSync } = require('node:fs') as typeof import('node:fs') const { dirname, join } = require('node:path') as typeof import('node:path') const { createRequire } = require('node:module') as typeof import('node:module') const entry = createRequire(import.meta.url).resolve('node-pty') const root = dirname(dirname(entry)) - const helper = join(root, 'prebuilds', `${process.platform}-${process.arch}`, 'spawn-helper') - expect(existsSync(helper)).toBe(true) - const { statSync } = require('node:fs') as typeof import('node:fs') - expect((statSync(helper).mode & 0o111) !== 0).toBe(true) + // Prebuilt (tarball) or node-gyp-compiled (build/Release): mirror + // ensureSpawnHelper's candidate list — either location is acceptable. + const candidates = [ + join(root, 'prebuilds', `${process.platform}-${process.arch}`, 'spawn-helper'), + join(root, 'build', 'Release', 'spawn-helper'), + ] + const helper = candidates.find(existsSync) + expect(helper).toBeTruthy() + expect((statSync(helper!).mode & 0o111) !== 0).toBe(true) }) })