diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..f0bc5b36 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + node-version: [10.x, 12.x, 14.x] + platform: + - os: ubuntu-latest + shell: bash + - os: macos-latest + shell: bash + - os: windows-latest + shell: powershell + + fail-fast: false + + runs-on: ${{ matrix.platform.os }} + defaults: + run: + shell: ${{ matrix.platform.shell }} + + steps: + # there are files here that make windows unhappy by default + - name: Support longpaths + run: git config --global core.longpaths true + + - name: Checkout Repository + uses: actions/checkout@v1.1.0 + + - name: Use Nodejs ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: use latest npm + run: npm i -g npm@latest + + - name: Install dependencies + run: npm install + + - name: Run Tap Tests + run: npm test -- -c -t0 diff --git a/package.json b/package.json index d7cb9054..8778ded3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "url": "https://github.com/npm/node-tar.git" }, "scripts": { - "test": "tap", + "test:posix": "tap", + "test:win32": "tap --lines=98 --branches=98 --statements=98 --functions=98", + "test": "node test/fixtures/test.js", "preversion": "npm test", "postversion": "npm publish", "postpublish": "git push origin --follow-tags", diff --git a/test/fixtures/test.js b/test/fixtures/test.js new file mode 100644 index 00000000..e1a34da7 --- /dev/null +++ b/test/fixtures/test.js @@ -0,0 +1,20 @@ +const platform = process.platform === 'win32' ? 'win32' : 'posix' +const {spawn} = require('child_process') +const c = spawn(process.execPath, [ + process.env.npm_execpath, + 'run', + `test:${platform}`, + '--', + ...process.argv.slice(2), +], { + stdio: 'inherit', +}) +c.on('close', (code, signal) => { + process.exitCode = code + if (signal) { + process.kill(process.pid, signal) + setTimeout(() => {}, 200) + } +}) +process.on('SIGTERM', () => c.kill('SIGTERM')) +process.on('SIGINT', () => c.kill('SIGINT'))