Skip to content

Commit

Permalink
Node CI tests on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Feb 22, 2022
1 parent 1bf9883 commit fa27a25
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 55 deletions.
85 changes: 69 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ env:

jobs:
job_install_deps:
name: Install Dependencies
name: Install Dependencies - Linux
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand All @@ -43,14 +43,40 @@ jobs:
uses: actions/cache@v2
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit == ''
run: yarn install --ignore-engines
outputs:
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}

job_install_deps_windows:
name: Install Dependencies - Windows
runs-on: windows-latest
timeout-minutes: 15
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v1
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
# so no need to reinstall them
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "::set-output name=hash::${{ hashFiles('yarn.lock') }}"
- name: Check dependency cache
uses: actions/cache@v2
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-windows
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit == ''
run: yarn install --ignore-engines
outputs:
dependency_cache_key_windows: ${{ steps.compute_lockfile_hash.outputs.hash }}

job_build:
name: Build
needs: job_install_deps
Expand All @@ -64,7 +90,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand Down Expand Up @@ -107,7 +133,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand Down Expand Up @@ -137,7 +163,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand All @@ -160,7 +186,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand All @@ -171,7 +197,7 @@ jobs:
run: yarn circularDepCheck

job_unit_test:
name: Test (Node ${{ matrix.node }})
name: Test (Node ${{ matrix.node }} - Linux)
needs: job_build
continue-on-error: true
timeout-minutes: 30
Expand All @@ -189,20 +215,47 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Run tests
env:
NODE_VERSION: ${{ matrix.node }}
run: ./scripts/test.sh
run: node ./scripts/test.js
- name: Compute test coverage
uses: codecov/codecov-action@v1

job_unit_test_windows:
name: Test (Node ${{ matrix.node }} - Windows)
needs: job_install_deps_windows
continue-on-error: true
timeout-minutes: 30
runs-on: windows-latest
strategy:
matrix:
node: [6, 8, 10, 12, 14, 16]
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-windows
key: ${{ needs.job_build.outputs.dependency_cache_key_windows }}
# - name: Check build cache
# uses: actions/cache@v2
# with:
# path: ${{ env.CACHED_BUILD_PATHS }}
# key: ${{ env.BUILD_CACHE_KEY }}
- name: Run tests
run: node ./scripts/test.js

# Ember tests are separate from the rest because they are the slowest part of the test suite, and making them a
# separate job allows them to run in parallel with the other tests.
job_ember_tests:
Expand Down Expand Up @@ -231,7 +284,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand All @@ -255,7 +308,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand Down Expand Up @@ -289,7 +342,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand Down Expand Up @@ -322,7 +375,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand Down Expand Up @@ -351,7 +404,7 @@ jobs:
- name: Check dependency cache
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
path: ${{ env.CACHED_DEPENDENCY_PATHS }}-linux
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
Expand Down
40 changes: 40 additions & 0 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { spawnSync } = require('child_process');
const { join } = require('path');

const nodeVersion = parseInt(process.version.split('.')[0].replace('v', ''), 10);

function run(cmd) {
const result = spawnSync(cmd, { shell: true, stdio: 'inherit', cwd: join(__dirname, '..') });

if (result.status !== 0) {
process.exit(result.status);
}
}

// control which packages we test on each version of node
if (nodeVersion <= 6) {
// install legacy versions of packages whose current versions don't support node 6
// ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing
run('cd packages/node && yarn add --dev --ignore-engines --ignore-scripts [email protected]');
run('cd packages/tracing && yarn add --dev --ignore-engines --ignore-scripts [email protected]');
run('cd packages/utils && yarn add --dev --ignore-engines --ignore-scripts [email protected]');

// only test against @sentry/node and its dependencies - node 6 is too old for anything else to work
run(
'yarn test --scope="@sentry/core" --scope="@sentry/hub" --scope="@sentry/minimal" --scope="@sentry/node" --scope="@sentry/utils" --scope="@sentry/tracing"'
);
} else if (nodeVersion <= 8) {
// install legacy versions of packages whose current versions don't support node 8
// ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing
run('cd packages/tracing && yarn add --dev --ignore-engines --ignore-scripts [email protected]');
run('cd packages/utils && yarn add --dev --ignore-engines --ignore-scripts [email protected]');

// ember tests happen separately, and the rest fail on node 8 for various syntax or dependency reasons
run(
'yarn test --ignore="@sentry/ember" --ignore="@sentry-internal/eslint-plugin-sdk" --ignore="@sentry/react" --ignore="@sentry/wasm" --ignore="@sentry/gatsby" --ignore="@sentry/serverless" --ignore="@sentry/nextjs"'
);
} else {
run('yarn test --ignore="@sentry/ember"');
}

process.exit(0);
39 changes: 0 additions & 39 deletions scripts/test.sh

This file was deleted.

0 comments on commit fa27a25

Please sign in to comment.