Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
ref: prep repo for move to @sentry-javascript (#227)
Browse files Browse the repository at this point in the history
* esm is unused

* tsconfig port

* ref: output to build

* ref: build ts

* ref: fix linter errors

* cleanup output

* fix lint error when deleting property

* copy binary to correct outdir

* use yarn

* swap npm run for yarn

* install and use yarn in CI workflows

* install prod deps only

* drop node 14

* build with node 20

* downgrade ts to match sentry repo

* install dev dep for test

* test python latest

* test python latest

* install devdeps when building

* remove node 14 from expected precompile binaries

* output to lib because node-gyp doesnt allow configurable outdir

* fix jsdoc comments

* fix binary dir

* revert optional chaining

* bundle test should import from lib

* remove another nullish coalescing

* fix

* build w/o typescript

* drop modules after install

* install prod deps to run

* rename demo app build file

* fix dep install
  • Loading branch information
JonasBa authored Jan 10, 2024
1 parent 229b585 commit 7076bb1
Show file tree
Hide file tree
Showing 54 changed files with 6,337 additions and 8,943 deletions.
14 changes: 0 additions & 14 deletions .eslintrc

This file was deleted.

68 changes: 68 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module.exports = {
root: true,
env: {
es6: true,
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
'@sentry-internal/sdk/no-optional-chaining': 'off',
'@sentry-internal/sdk/no-nullish-coalescing': 'off',
'@sentry-internal/sdk/no-unsupported-es6-methods': 'off',
'@sentry-internal/sdk/no-class-field-initializers': 'off',
},
extends: ['@sentry-internal/sdk/src/base'],
ignorePatterns: [
'coverage/**',
'build/**',
'lib/**',
'dist/**',
'cjs/**',
'esm/**',
'examples/**',
'test/manual/**',
'benchmarks/**',
'playground/**',
'demo_app/**',
'test-binaries.entry.js',
'jest.config.ts'
],
overrides: [
{
files: ['*.ts', '*.tsx', '*.d.ts'],
parserOptions: {
project: ['tsconfig.json'],
},
},
{
files: ['test/**/*.ts', 'test/**/*.tsx'],
parserOptions: {
project: ['tsconfig.test.json'],
},
},
{
files: ['jest/**/*.ts', 'scripts/**/*.ts'],
parserOptions: {
project: ['tsconfig.dev.json'],
},
},
{
files: ['*.tsx'],
rules: {
// Turn off jsdoc on tsx files until jsdoc is fixed for tsx files
// See: https://github.com/getsentry/sentry-javascript/issues/3871
'jsdoc/require-jsdoc': 'off',
},
},
{
files: ['scenarios/**', 'dev-packages/rollup-utils/**'],
parserOptions: {
sourceType: 'module',
},
rules: {
'no-console': 'off',
},
},
],
};
80 changes: 27 additions & 53 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
# distributions and container images.

# linux x64 glibc
- os: ubuntu-20.04
node: 14
- os: ubuntu-20.04
node: 16
- os: ubuntu-20.04
Expand All @@ -35,9 +33,6 @@ jobs:
node: 20

# linux x64 musl
- os: ubuntu-20.04
container: node:14-alpine3.16
node: 14
- os: ubuntu-20.04
container: node:16-alpine3.16
node: 16
Expand All @@ -49,9 +44,6 @@ jobs:
node: 20

# linux arm64 glibc
- os: ubuntu-20.04
arch: arm64
node: 14
- os: ubuntu-20.04
arch: arm64
node: 16
Expand All @@ -63,10 +55,6 @@ jobs:
node: 20

# linux arm64 musl
- os: ubuntu-20.04
container: node:14-alpine3.16
arch: arm64
node: 14
- os: ubuntu-20.04
container: node:16-alpine3.16
arch: arm64
Expand All @@ -81,9 +69,6 @@ jobs:
node: 20

# macos x64
- os: macos-11
node: 14
arch: x64
- os: macos-11
node: 16
arch: x64
Expand Down Expand Up @@ -147,32 +132,23 @@ jobs:
node-version: ${{ matrix.node }}

- uses: actions/setup-python@v4
name: Setup python macos 14
if: contains(matrix.os, 'macos-11') && matrix.node == '14'
with:
python-version: "3.10"

- uses: actions/setup-python@v4
name: Setup python latest
if: contains(matrix.os, 'macos-11') && matrix.node != '14'
with:
python-version: "3.11"
name: Setup python

- name: Install dependencies
run: npm install --ignore-scripts
run: yarn install --ignore-scripts --frozen-lockfile

# configure build test copy x64
- name: Configure gyp
if: matrix.arch != 'arm64'
run: npm run build:configure
run: yarn build:configure

- name: Build bindings
if: matrix.arch != 'arm64'
run: npm run build:bindings
run: yarn build:bindings

- name: Test
if: matrix.arch != 'arm64'
run: npm run test --silent
run: yarn test --silent

# configure build test copy arm64
- name: setup (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})
Expand All @@ -184,7 +160,7 @@ jobs:
# linux arm64
- name: "Configure gyp (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && matrix.target_platform != 'darwin'
run: npm run build:configure:arm64
run: yarn build:configure:arm64

- name: Setup musl cross compiler
if: contains(matrix.container, 'alpine')
Expand All @@ -198,24 +174,24 @@ jobs:
run: |
CC=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
CXX=$(pwd)/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ \
BUILD_ARCH=arm64 npm run build:bindings
BUILD_ARCH=arm64 yarn build:bindings
- name: "Build bindings (arm64, ${{ contains(matrix.container, 'alpine') && 'musl' || 'glibc' }})"
if: matrix.arch == 'arm64' && !contains(matrix.container, 'alpine') && matrix.target_platform != 'darwin'
run: |
CC=aarch64-linux-gnu-gcc \
CXX=aarch64-linux-gnu-g++ \
BUILD_ARCH=arm64 npm run build:bindings:arm64
BUILD_ARCH=arm64 yarn build:bindings:arm64
# linux arm64 target darwin
- name: "Configure gyp (arm64, darwin)"
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
run: npm run build:configure:arm64
run: yarn build:configure:arm64

- name: "Build bindings (arm64, darwin)"
if: matrix.arch == 'arm64' && matrix.target_platform == 'darwin'
run: |
BUILD_PLATFORM=darwin BUILD_ARCH=arm64 npm run build:bindings:arm64
BUILD_PLATFORM=darwin BUILD_ARCH=arm64 yarn build:bindings:arm64
# continue with common steps
- name: Log binary
Expand All @@ -235,15 +211,14 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm run build:lib
node-version: 20
- run: yarn install --frozen-lockfile
- run: yarn build:lib
- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: ls -l lib/
- run: npm run test:bundle
- run: yarn test:bundle

build-and-pack:
runs-on: ubuntu-latest
Expand All @@ -254,17 +229,16 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- run: npm ci
- run: npm run build:lib
- run: yarn install --frozen-lockfile
- run: yarn build:lib

- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: ls -l lib/
- run: npm pack
- run: yarn pack

- name: Archive artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -302,27 +276,27 @@ jobs:

# The general workflow for testing a bundler workflow
# is to build our library, download the generated binaries and
# use npm link to link the what will be our final published library
# use yarn link to link the what will be our final published library
# into the demo_app folder. From there, we run the different bundler
# build commands and attempt to run the demo app.
bundler: ["esbuild"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- run: npm install --ignore-scripts
- run: npm run build:lib
- run: yarn install --frozen-lockfile
- run: yarn build:lib

- uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
path: lib/
- run: ls -l lib/

- run: npm link
- run: npm run test:setup:bundle
- run: npm run test:${{matrix.bundler}}:build
- run: npm run test:${{matrix.bundler}}:run
- run: rm -rf ./node_modules/ && npm install --omit=dev && node scripts/check-build.mjs
- run: yarn link
- run: yarn test:setup:bundle
- run: yarn test:${{matrix.bundler}}:build
- run: yarn test:${{matrix.bundler}}:run
- run: rm -rf ./node_modules/ && yarn install && node scripts/check-build.mjs
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm ci
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: yarn install --frozen-lockfile
- run: |
git config clangFormat.binary node_modules/.bin/clang-format
git config clangFormat.style file
npm run lint
yarn lint
build-test-matrix:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-2019, ubuntu-latest]
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -33,13 +33,13 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: npm run clean
- run: yarn clean

- name: Setup windows build tools
uses: microsoft/[email protected]
if: ${{ runner.os == 'Windows' }}

- run: npm install
- run: npm run build:configure
- run: npm run build
- run: npm run test --silent
- run: yarn install --frozen-lockfile
- run: yarn build:configure
- run: yarn build
- run: yarn test --silent
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
release:
runs-on: ubuntu-latest
name: 'Release a new version'
name: "Release a new version"
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

coverage/
lib/
build/
build-test/
demo_app/dist/
demo_app/package-lock.json

node_modules/
memory_db
build/
benchmarks/format/output/
benchmarks/format/results/

Expand Down
Binary file added .yarn/install-state.gz
Binary file not shown.
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ Because the repository requires you to compile the c++ bindings via node-gyp, we

Since we are using [`TypeScript`](https://www.typescriptlang.org/) and native node addons, you need to transpile the code to JavaScript and compile the c++ bindings in order to be able to run the addon.

- `npm run build` will compile the c++ bindings and ts files.
- `npm run build:lib` will compile only the ts files
- `npm run build:bindings` will compile the c++ bindings
- `yarn build` will compile the c++ bindings and ts files.
- `yarn build:lib` will compile ts files
- `yarn build:bindings` will compile c++ bindings

## Tests

Tests are colocated with source files and should have a .test.ts suffix. The entire test suite can be ran using the `npm run test` command.
Tests are colocated with source files and should have a .test.ts suffix. The entire test suite can be ran using the `yarn test` command.

## Linting

Similar to building and testing, linting can be done via `npm run lint` command.
Similar to building and testing, linting can be done via `yarn lint` command.

## Considerations Before Sending Your First PR

Expand All @@ -42,7 +42,7 @@ When contributing to the codebase, please note:

## Benchmarks

The repository contains micro benchmarks. You can find all benchmarks at the benchmarks folder in project root directory. The benchmarks can either be ran directly through node via `node benchmarks/cpu/benchmark.profiler.js` or via `npm run benchmark` command. There are also individual npm run benchmark commands like `npm run benchmark:server` or `npm run benchmark:methods` which will only run individual benchmarks.
The repository contains micro benchmarks. You can find all benchmarks at the benchmarks folder in project root directory. The benchmarks can either be ran directly through node via `node benchmarks/cpu/benchmark.profiler.js` or via `yarn benchmark` command. There are also individual yarn benchmark commands like `yarn benchmark:server` or `yarn benchmark:methods` which will only run individual benchmarks.

Remember that these are micro benchmarks and that results will vary across different OS and architectures.

Expand Down
Loading

0 comments on commit 7076bb1

Please sign in to comment.