Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(node): Run Node CI tests on Windows #4616

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 70 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ env:
${{ github.workspace }}/packages/ember/*.d.ts
${{ github.workspace }}/packages/ember/instance-initializers
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip

BUILD_CACHE_KEY: ${{ github.sha }}
!**/node_modules/**

jobs:
job_install_deps:
Expand All @@ -44,12 +43,12 @@ jobs:
id: cache_dependencies
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}-linux
- 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 }}
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}-linux

job_build:
name: Build
Expand All @@ -66,24 +65,17 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
id: cache_built_packages
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: Build packages
# Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
# packages, and so `yarn build` should always run. This `if` check is therefore only there for testing CI issues
# where the built packages are beside the point. In that case, you can change `BUILD_CACHE_KEY` (at the top of
# this file) to a constant and skip rebuilding all of the packages each time CI runs.
if: steps.cache_built_packages.outputs.cache-hit == ''
run: yarn build
# We are performing a `prepublishOnly` step manually because build workflow is not responsible for publishing
# the actual release. It only creates artifacts which then are uploaded and used by another workflow.
# Because of that, any `prepublishOnly` script is skipped and files it produces are not included in the tarball.
# We also cannot use `prepare` script which would be more suited, because it's run only before `pack` is called,
# and it's done from a `release` workflow and not here.
- uses: actions/upload-artifact@v2
with:
name: build-output
path: ${{ env.CACHED_BUILD_PATHS }}
- name: Run prepublishOnly script
if: startsWith(github.ref, 'refs/heads/release/')
run: yarn prepublishOnly
Expand All @@ -109,11 +101,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Check bundle sizes
uses: getsentry/size-limit-action@v3
# Only run size check on master or pull requests
Expand All @@ -139,11 +130,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Run linter
run: yarn lint

Expand All @@ -162,16 +152,15 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Run madge
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 @@ -191,18 +180,46 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- 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_build
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
if: matrix.os == 'windows-latest'
uses: actions/cache@v2
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build_windows.outputs.dependency_cache_key }}
- uses: actions/download-artifact@v2
with:
name: build-output
path: ${{ github.workspace }}/packages
- name: Install dependencies
run: yarn install
- name: Run tests
run: node ./scripts/test.js

job_nextjs_integration_test:
name: Test @sentry/nextjs on (Node ${{ matrix.node }})
needs: job_build
Expand All @@ -224,11 +241,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Run tests
env:
NODE_VERSION: ${{ matrix.node }}
Expand Down Expand Up @@ -266,11 +282,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Run Ember tests
run: yarn test --scope=@sentry/ember
- name: Compute test coverage
Expand All @@ -290,11 +305,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Pack
run: yarn pack:changed
- name: Archive artifacts
Expand Down Expand Up @@ -341,11 +355,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Run Playwright tests
env:
PW_BUNDLE: ${{ matrix.bundle }}
Expand Down Expand Up @@ -377,11 +390,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Run integration tests
env:
KARMA_BROWSER: ${{ matrix.browser }}
Expand All @@ -406,11 +418,10 @@ jobs:
with:
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: Check build cache
uses: actions/cache@v2
- uses: actions/download-artifact@v2
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
name: build-output
path: ${{ github.workspace }}/packages
- name: Run build tests
run: |
cd packages/browser
Expand Down
45 changes: 45 additions & 0 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { spawnSync } = require('child_process');
const { join } = require('path');

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

function run(cmd) {
console.log(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 {
if (process.platform === 'win32') {
run('yarn test --ignore="@sentry/ember" --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.