Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: backtrace-labs/backtrace-javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: react-native/0.1.1
Choose a base ref
...
head repository: backtrace-labs/backtrace-javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Jun 10, 2024

  1. Copy the full SHA
    312a3dc View commit details

Commits on Jun 17, 2024

  1. Copy the full SHA
    da813bc View commit details
  2. node: replace native-reg with call to reg query (#250)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jun 17, 2024
    Copy the full SHA
    b26514b View commit details
  3. Include windows in CICD pipeline. Use @v4 (#249)

    * Include windows in CICD pipeline. Use @v4
    
    * Remove strategy
    
    * Action name
    
    * declare prettierrc path
    
    * Correct path to the file
    
    * Update prettier and options
    
    * Set end of line to auto
    
    * Apply default formatting proposed by prettier latest (#252)
    
    * Apply default formatting proposed by prettier latest
    
    * Force to use prettierrc.json
    
    * Print file structure
    
    * Escape file name
    
    * Auto end of line
    
    * Use powershell
    
    * Correct YAML
    
    * Use win-node-env
    
    * Do not require powershell if not needed
    
    * Remove changes that dont belong to this pull request
    
    * use cross-env for setting NODE_ENV variables
    
    * cli: fix test errors on Windows
    
    * Apply formatting
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    konraddysput and perf2711 authored Jun 17, 2024
    Copy the full SHA
    e384367 View commit details
  4. node: version 0.3.2 (#251)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jun 17, 2024
    Copy the full SHA
    c2f0128 View commit details

Commits on Jun 18, 2024

  1. electron: version 0.3.1 (#255)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jun 18, 2024
    Copy the full SHA
    dce7fdc View commit details

Commits on Jun 24, 2024

  1. session-replay: update rrweb and implement fixes (#256)

    * session-replay: update rrweb
    
    * session-replay: send always max of maxEventCount events
    
    * session-replay: remove maxTime option
    
    * browser example: use packages from workspace
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jun 24, 2024
    Copy the full SHA
    6973281 View commit details
  2. session-replay: PII defaults (#257)

    * session-replay: pass privacy options and set defaults
    
    * browser example: add input to demonstrate session replay PII
    
    * session-replay: update default block/mask/ignore classes to bt-*
    
    * session-replay: add additional options to text masking
    
    * browser example: add example of unmasked text
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jun 24, 2024
    Copy the full SHA
    5d4fe6d View commit details
  3. session-replay: add README and update code docs (#258)

    * session-replay: add README and update code docs
    
    * session-replay: README PR suggestions
    
    * session-replay: update README with PII changes
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jun 24, 2024
    Copy the full SHA
    8e6fd3e View commit details

Commits on Jul 12, 2024

  1. cli: add retry to removing files after test (#259)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jul 12, 2024
    Copy the full SHA
    ca6217f View commit details
  2. Add support for error.type for electron crashes (#260)

    * Add support for error.type for electron crashes
    
    * Simplify default attribute
    
    * Remove redundant new line
    
    * Formatting
    konraddysput authored Jul 12, 2024
    Copy the full SHA
    d083c53 View commit details

Commits on Jul 26, 2024

  1. session-replay: version 0.1.0 (#261)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Jul 26, 2024
    Copy the full SHA
    b3941b8 View commit details

Commits on Aug 5, 2024

  1. sdk-core: fix missing instance when builder is used (#263)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Aug 5, 2024
    Copy the full SHA
    c453923 View commit details

Commits on Aug 7, 2024

  1. sdk-core: version 0.3.3 (#264)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Aug 7, 2024
    Copy the full SHA
    d3275b2 View commit details
  2. sdk-core: 0.3.2 changelog

    perf2711 committed Aug 7, 2024
    1
    Copy the full SHA
    5da9114 View commit details

Commits on Aug 28, 2024

  1. electron, node: upload attachments after native crashes (#262)

    * sdk-core: add AttachmentManager
    
    * sdk-core: add BacktraceAttachmentProvider
    
    * sdk-core: add getAttachmentProviders to BreadcrumbsStorage
    
    * fixup 7102a65
    
    * sdk-core: add submission of attachments to existing rxids
    
    * sdk-core: add attachment database record
    
    * sdk-core: remove report on Report skipped in database
    
    * sdk-core: do not return attachment record if file does not exist
    
    * sdk-core: expose database and fileSystem to modules
    
    * sdk-core: expose timestamp in SessionFiles
    
    * node: replace createFromSession with getSessionAttachments in FileBreacrumbsStorage, expose it from package
    
    * node: add FileAttachmentsManager, add attachments from previous sessions
    
    * node: expose file system from package
    
    * node: implement postAttachment in BacktraceNodeRequestHandler
    
    * electron: implement sendAttachment in IpcReportSubmission
    
    * electron: send attachments from previous crashes to Backtrace
    
    * sdk-core: fix database unit test
    
    * sdk-core: drop count from database record
    
    * sdk-core: limit records in database per type
    
    * sdk-core: extract Attachment- and ReportBacktraceDatabaseFileRecord classes to separate files
    
    * sdk-core: add descriptions to methods in AttachmentManager
    
    * electron: join attachments into single array from previous crashes
    
    * electron: make the rxid regex more strict
    
    * sdk-core: change default maximumNumberOfAttachmentRecords to 10
    
    * sdk-core: update param in doc in BacktraceDatabase
    
    * sdk-core: make sessionId in attachment mandatory
    
    * sdk-core: remove hash from database records
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Aug 28, 2024
    Copy the full SHA
    a4749a4 View commit details
  2. ci: build and test versions (#273)

    * ci: add build-version to workflows
    
    * ci: use separate job for node 14
    
    * ci: run npm install again in node 14
    
    * ci: remove checkout and npm ci from node 14
    
    * ci: rename build_pre_workspaces to test_linux_pre_workspaces
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Aug 28, 2024
    Copy the full SHA
    ccf4971 View commit details

Commits on Aug 29, 2024

  1. sdk-core: version 0.4.0 (#274)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Aug 29, 2024
    Copy the full SHA
    cc10de5 View commit details

Commits on Aug 30, 2024

  1. node: version 0.4.0 (#275)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Aug 30, 2024
    Copy the full SHA
    379bb63 View commit details
  2. electron: version 0.4.0 (#276)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Aug 30, 2024
    Copy the full SHA
    d51f3bf View commit details

Commits on Sep 2, 2024

  1. session-replay: use ESM modules (#272)

    * session-replay: change output to esm, bundle with rollup
    
    * session-replay: update tests to use esm
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    d39ec93 View commit details
  2. session-replay: version 0.1.1 (#278)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    38c0ce5 View commit details
  3. sdk-core: use ESM modules (#266)

    * sdk-core: change output to esm
    
    * sdk-core: update tests to use esm
    
    * update package-lock.json
    
    * browser: fix TimeHelper imports
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    4953027 View commit details
  4. browser: use ESM modules (#268)

    * browser: change output to esm, bundle with rollup
    
    * browser: update tests to use esm
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    d1b0881 View commit details
  5. react: use ESM modules (#269)

    * react: change output to esm, bundle with rollup
    
    * react: update tests to use esm
    
    * react: include tsx files in bundle
    
    * react: update BacktraceReport import
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    b3ee14c View commit details
  6. node: use ESM modules (#267)

    * node: change output to esm, bundle with rollup
    
    * node: update tests to use esm
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    92bb318 View commit details
  7. electron: change output to esm, bundle with rollup (#270)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    2b3f040 View commit details
  8. sdk-core, browser, react-native: fix abort event not being removed fr…

    …om signal (#265)
    
    * session-replay: add prepublish script
    
    * sdk-core: fix 'abort' event not being removed from signal
    
    * react-native: dispose signal in ReactNativeRequestHandler
    
    * browser: dispose signal in ReactNativeRequestHandler
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    63dc86e View commit details
  9. Copy the full SHA
    37932aa View commit details
  10. Copy the full SHA
    976fdb7 View commit details
  11. Copy the full SHA
    accf957 View commit details
  12. sdk packages: wrap up of ESM changes (#279)

    * gitignore: ignore .rollup.cache
    
    * base: remove composite and incremental from tsconfig
    
    * sdk-core: change output to NodeNext
    
    * node: change output to NodeNext, fix invalid imports
    
    * browser: change output to NodeNext, fix invalid imports
    
    * react: change output to NodeNext
    
    * session-replay: change output to NodeNext
    
    * electron: change output to NodeNext
    
    * base: remove tsconfig.packages.json
    
    * sdk-core: remove rollup-plugin-typescript2
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 2, 2024
    Copy the full SHA
    09159c4 View commit details

Commits on Sep 3, 2024

  1. ci: smoke tests (#277)

    * smoketests: add node app implementation
    
    * smoketests: add main runner with fake-coroner and node tests
    
    * smoketests: add running smoketests to github workflows
    
    * smoketests: fix lint issues
    
    * smoketests: use real coronerd, return rxid from node app
    
    * smoketests: add smoketests to node 14 and windows
    
    * smoketests: add node-esm target
    
    * chore: update package-lock.json
    
    * sdk-core: implement AbortSignal.any method
    
    * smoketests: ignore database and package-lock.json
    
    * chore: update package-lock.json
    
    * chore: fix prettier issues
    
    * chore: update package-lock.json
    
    * chore: fix prettier issues
    
    * smoketests: increase timeout to 60s
    
    * smoketests: fix npm command on Windows
    
    * smoketests: change node-esm package name
    
    * smoketests: assert smoketests URLs in a better way
    
    * smoketests: fix npm calls again on Windows
    
    * chore: fix prettier issues
    
    * smoketests: remove trust-ssl-cert scripts
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 3, 2024
    Copy the full SHA
    2991d6d View commit details

Commits on Sep 5, 2024

  1. nestjs: use ESM modules (#271)

    * nestjs: change output to esm, bundle with rollup
    
    * nestjs: update tests to use esm
    
    * nestjs: change output to NodeNext
    
    * nestjs: disable tests on node 14
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 5, 2024
    Copy the full SHA
    b284e4f View commit details

Commits on Sep 6, 2024

  1. sdk-core: version 0.5.0 (#280)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 6, 2024
    Copy the full SHA
    25fb791 View commit details
  2. browser: version 0.4.0 (#281)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 6, 2024
    Copy the full SHA
    9dcffb1 View commit details
  3. react: version 0.4.0 (#282)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 6, 2024
    Copy the full SHA
    94ece50 View commit details
  4. session-replay: version 0.2.0 (#284)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 6, 2024
    Copy the full SHA
    0f4aae4 View commit details
  5. node: version 0.5.0 (#285)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 6, 2024
    Copy the full SHA
    342c8aa View commit details
  6. electron: version 0.5.0 (#286)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 6, 2024
    Copy the full SHA
    9f5ca1f View commit details
  7. nestjs: version 0.4.0 (#287)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 6, 2024
    Copy the full SHA
    f92bb6d View commit details

Commits on Sep 9, 2024

  1. nestjs: include tslib in code instead of externalizing it (#288)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 9, 2024
    Copy the full SHA
    2b2fcd1 View commit details
  2. nestjs: version 0.4.1 (#289)

    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 9, 2024
    Copy the full SHA
    edb832c View commit details

Commits on Sep 23, 2024

  1. sdk-core: unref setinterval (#291)

    * Unref setinterval
    
    * Remove additional ;
    
    * Formatting once again
    konraddysput authored Sep 23, 2024
    Copy the full SHA
    07327b3 View commit details

Commits on Sep 26, 2024

  1. sdk-core: reduce breadcrumbs size (#228)

    * sdk-core: add limitObjectDepth
    
    * sdk-core: add breadcrumb limits options
    
    * sdk-core: limit breadcrumb attributes object depth
    
    * sdk-core: limit breadcrumb message length
    
    * sdk-core: add jsonSize
    
    * sdk-core: add breadcrumb size check and move limiting after intercept and level/type checks
    
    * sdk-core: add breadcrumb factories
    
    * sdk-core: add breadcrumb file size limiting in InMemoryBreadcrumbsStorage
    
    * sdk-core: update docs for breadcrumb limits
    
    * sdk-core: allow for unlimited breacrumbs in InMemoryBreadcrumbsStorage
    
    * sdk-core: PR suggestion changes
    
    * sdk-core: fix jsonSize returning invalid sizes for objects with toJSON
    
    * sdk-core: refactored OverwritingArray, added pop and shift
    
    * sdk-core: InMemoryBreadcrumbsStorage: shift breadcrumbs if larger than limit
    
    * sdk-core: clear items removed by pop and shift in OverwritingArray
    
    * sdk-core: reduce breadcrumb size PR changes
    
    * node, react-native: update defaults to compile
    
    * sdk-core: allow returning undefined from BreadcrumbsStorage.add
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 26, 2024
    Copy the full SHA
    8ec2804 View commit details
  2. node: reduce breadcrumb size (#230)

    * node: change NodeFileSystem types for streams, add createReadStream
    
    * node: use fileSystem in BacktraceFileAttachment
    
    * node: rewrite AlternatingFileWriter with react-native logic
    
    * node: use new AlternatingFileWriter with limits, add and use factory for FileBreadcrumbsStorage
    
    * node: allow for unlimited breadcrumbs in FileBreadcrumbsStorage
    
    * node: add stream chunkifier
    
    * sdk-core: allow returning zero, one, or more attachments from BacktraceAttachmentProvider
    
    * node: fix invalid imports
    
    * node: use chunkifier in FileBreadcrumbsStorage
    
    * node: remove AlternatingFileWriter
    
    * node: make fileSystem optional in FileBreadcrumbsStorage.getSessionAttachments
    
    * node: fix lint and test issues
    
    * node: update docs for lengthChunkSplitter
    
    * node: return undefined from FileBreadcrumbsStorage.add if size is too large
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 26, 2024
    Copy the full SHA
    2e5743b View commit details
  3. electron: reduce breadcrumb size (#231)

    * electron: use factory in IpcBreadcrumbsStorage
    
    * electron: pass fileSystem to FileBreadcrumbsStorage.getSessionAttachments
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Sep 26, 2024
    Copy the full SHA
    415c37c View commit details

Commits on Oct 1, 2024

  1. sdk-core: use core client as event emitter, send reports from databas…

    …e via client (#290)
    
    * sdk-core: use core client as event emitter
    
    * sdk-core: fix unit tests
    
    * sdk-core: emit events directly from database
    
    * sdk-core: extract BacktraceDatabaseEvents to separate file
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Oct 1, 2024
    Copy the full SHA
    c5ee428 View commit details

Commits on Oct 8, 2024

  1. ci: additional smoke tests (#283)

    * smoketests: add more node smoketests, streamline node tests
    
    * smoketests: move jest tests to separate directory
    
    * smoketests: make rxid test more strict in Node
    
    * smoketests: change smoketests to module, move installing and building to preparation
    
    * smoketests: add simple WDIO tests for React
    
    * smoketests: add session replay to React test
    
    * smoketests: add SAUCE_* credentials in workflows
    
    * workflows: split into all and rest
    
    * smoketests: fix node tests on windows
    
    * smoketests: wrap args in quotes on Windows in npm
    
    * smoketests: replace tsx with ts-node in prepare-packages
    
    * smoketests: fix invalid paths to sdk packages in test packages
    
    * smoketests: add more tests to react
    
    * smoketests: add more node smoketests with database
    
    * smoketests: use exceptions instead of messages in node tests
    
    * smoketests: listen on db events in node
    
    * smoketests: add --unhandled-rejections=throw to node test programs
    
    * smoketests: downgrade @wdio packages to 8.40.x
    
    * smoketests: add iOS simulator target to WDIO
    
    * smoketests: make cleaning optional
    
    * smoketests: add README
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Oct 8, 2024
    Copy the full SHA
    e096dcf View commit details
  2. sdk-core, node: attribute validation (#296)

    * sdk-core: add application and application.version validation on initialize
    
    * node: remove error from ApplicationInformationAttributeProvider on missing attributes
    
    * node: fix testing throw in ApplicationInformationAttributeProvider
    
    * sdk-core: simplify validateAttributes
    
    ---------
    
    Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
    perf2711 and perf2711 authored Oct 8, 2024
    Copy the full SHA
    d5fdd22 View commit details
Showing 525 changed files with 32,719 additions and 24,791 deletions.
55 changes: 55 additions & 0 deletions .github/actions/smoke-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Smoke test
description: 'Execute smoke tests'

inputs:
submit-url:
description: 'Submit layer url'
required: true
direct-submit-url:
description: 'Direct submission URL to Backtrace instance'
required: true
sauce-username:
description: 'Sauce labs user name'
required: true
sauce-access-key:
description: 'Sauce labs secret'
required: true
ignore-browser:
description: 'Ignore browser smoke-tests'
required: false
default: 'false'
ignore-node:
description: 'Ignore node smoke-tests'
required: false
default: 'false'

runs:
using: 'composite'
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
browser:
- 'packages/browser/**'
- 'packages/react/**'
- 'packages/sdk-core/**'
node:
- 'packages/sdk-core/**'
- 'packages/node/**'
- run: npm run smoketest:node
shell: bash
if: steps.filter.outputs.node == 'true' && inputs.ignore-node == 'false'
env:
SMOKETESTS_SUBMIT_LAYER_URL: ${{ inputs.submit-url }}
SMOKETESTS_DIRECT_SUBMIT_URL: ${{ inputs.direct-submit-url }}

- run: npm run smoketest:browser
shell: bash
if: steps.filter.outputs.browser == 'true' && inputs.ignore-browser == 'false'
env:
SMOKETESTS_SUBMIT_LAYER_URL: ${{ inputs.submit-url }}
SMOKETESTS_DIRECT_SUBMIT_URL: ${{ inputs.direct-submit-url }}
SMOKETESTS_SAUCE_USERNAME: ${{ inputs.sauce-username }}
SMOKETESTS_SAUCE_ACCESS_KEY: ${{ inputs.sauce-access-key }}
97 changes: 87 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -5,42 +5,119 @@ on:
branches: [main, dev]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build:
test_linux_all:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: npm run lint
- run: npm run format:check
- run: npm test
- name: smoke-test
uses: ./.github/actions/smoke-tests
with:
submit-url: ${{ secrets.SMOKETESTS_SUBMIT_LAYER_URL }}
direct-submit-url: ${{ secrets.SMOKETESTS_DIRECT_SUBMIT_URL }}
sauce-username: ${{ secrets.SMOKETESTS_SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SMOKETESTS_SAUCE_ACCESS_KEY }}

build_pre_workspaces:
test_linux:
runs-on: ubuntu-latest

strategy:
matrix:
build-version: [20.x]
node-version: [16.x, 18.x]

steps:
- uses: actions/checkout@v4
- name: Build using Node.js ${{ matrix.build-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.build-version }}
- run: npm ci
- run: npm run build
- name: Test using Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm test
- name: smoke-test
uses: ./.github/actions/smoke-tests
with:
submit-url: ${{ secrets.SMOKETESTS_SUBMIT_LAYER_URL }}
direct-submit-url: ${{ secrets.SMOKETESTS_DIRECT_SUBMIT_URL }}
sauce-username: ${{ secrets.SMOKETESTS_SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SMOKETESTS_SAUCE_ACCESS_KEY }}
ignore-browser: 'true'

test_linux_pre_workspaces:
runs-on: ubuntu-latest

strategy:
matrix:
build-version: [20.x]
node-version: [14.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- name: Build using Node.js ${{ matrix.build-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.build-version }}
- run: npm ci
- run: npm run build
- name: Test using Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g npm@8
- run: npm test
- name: smoke-test
uses: ./.github/actions/smoke-tests
with:
submit-url: ${{ secrets.SMOKETESTS_SUBMIT_LAYER_URL }}
direct-submit-url: ${{ secrets.SMOKETESTS_DIRECT_SUBMIT_URL }}
sauce-username: ${{ secrets.SMOKETESTS_SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SMOKETESTS_SAUCE_ACCESS_KEY }}
ignore-browser: 'true'

test_windows:
runs-on: windows-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: npm run lint
- run: npm run format:check
- run: npm test
- name: smoke-test
uses: ./.github/actions/smoke-tests
with:
submit-url: ${{ secrets.SMOKETESTS_SUBMIT_LAYER_URL }}
direct-submit-url: ${{ secrets.SMOKETESTS_DIRECT_SUBMIT_URL }}
sauce-username: ${{ secrets.SMOKETESTS_SAUCE_USERNAME }}
sauce-access-key: ${{ secrets.SMOKETESTS_SAUCE_ACCESS_KEY }}
ignore-browser: 'true'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -139,3 +139,4 @@ dist/
# VSCode settings
settings.json

.rollup.cache/
3 changes: 3 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
message="$(cat "$1")"
node .husky/scripts/commit-msg.js "$message"
13 changes: 13 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh

# Format modified files
prettier $(git diff --cached --name-only --diff-filter=ACMR | grep -e ".ts$" | sed 's| |\\ |g') --write --ignore-unknown

# Update index with modified files
git update-index --again

# Run lint on modified files
eslint $(git diff --cached --name-only --diff-filter=ACMR | grep -e ".ts$" | sed 's| |\\ |g')

# Update index with modified files
git update-index --again
173 changes: 173 additions & 0 deletions .husky/scripts/commit-msg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/**
* This script verifies if the commit message contains a valid prefix
* if files have been modified in the following directories:
* - packages/** - message must contain the package name prefix (e.g. "sdk-core"),
* - tools/** - message must contain the tool name prefix (e.g. "cli"),
* - scripts/** - message must contain the "scripts" prefix,
* - smoketests/** - message must contain the "smoketests" prefix.
*
* The list can be extended by modifying VALID_PREFIXES constant.
*/

const { execSync } = require('child_process');
const path = require('path');
const chalk = require('chalk');

/**
* Returns `true` if any function of `fns` returns `true`.
*/
const oneOf =
(...fns) =>
(...args) =>
fns.some((fn) => fn(...args));

const startsWith = (what) => (str) => str.startsWith(what);

/**
* Returns n-th part from left of path.
*
* @example
* console.log(nthPathPart(2)('a/b/c/d')) // 'c'
*/
const nthPathPart = (n) => (pathStr) => path.normalize(pathStr).split(path.sep)[n];

/**
* Returns array as comma-separated string.
*/
const csv = (array) => (array.length ? array.join(', ') : '<none>');

/**
* Case-insensitive string equality check.
*/
const ciEquals = (a, b) => a.localeCompare(b, undefined, { sensitivity: 'accent' }) === 0;

/**
* Expected change prefixes, in form of `[predicate, getPrefix]` functions:
* - `predicate`: `(modifiedFile: string) => boolean` - should return `true` if `modifiedFile` should have the prefix
* - `getPrefix`: `(modifiedFile: string) => string` - should return prefix value
*/
const VALID_PREFIXES = [
// packages/sdk-core/file.ts => sdk-core
// tools/cli/file.ts => cli
[oneOf(startsWith('packages/'), startsWith('tools/')), nthPathPart(1)],

// smoketests/dir/file.ts => smoketests
// scripts/dir/file.ts => scripts
[oneOf(startsWith('smoketests/'), startsWith('scripts/')), nthPathPart(0)],
];

/**
* Retrieves change prefix from file path, e.g. "sdk-core" for "packages/sdk-core/file.ts".
*/
function getChangePrefix(filePath) {
for (const [test, prefix] of VALID_PREFIXES) {
if (test(filePath)) {
return prefix(filePath);
}
}
}

/**
* Returns unique values of `values`.
*/
function unique(...values) {
return [...new Set(...values)];
}

/**
* Returns all expected prefixes for `modifiedFiles`.
*/
function getExpectedPrefixes(modifiedFiles) {
return unique(modifiedFiles.split('\n').map(getChangePrefix)).filter((f) => !!f);
}

/**
* Returns all used prefixes in `message`.
*/
function getActualPrefixes(message) {
if (!message.includes(':')) {
return [[], message];
}

const [prefix, rest] = message.split(':');
if (!prefix) {
return [[], message];
}

return [prefix.split(', '), (rest && rest.trim()) || ''];
}

/**
* Returns all prefixes that are in `expected`, but not in `actual`.
*/
function getMissingPrefixes(expected, actual) {
const missing = [];

for (const prefix of expected) {
if (!actual.includes(prefix)) {
missing.push(prefix);
}
}

return missing;
}

/**
* Returns normalized expected prefixes based on what is missing and what was provided.
* Normalization changes the case to match expected.
*/
function normalizeExpectedPrefixes(expected, missing, actual) {
const normalizedActual = actual.map((a) => expected.find((e) => ciEquals(a, e)) || a);
const missingFromNormalized = missing.filter((m) => !normalizedActual.includes(m));
return [...normalizedActual, ...missingFromNormalized];
}

/**
* Displays error banner in format of:
* ```
* ===============
* ==== error ====
* ===============
* ```
*/
function banner(str) {
const repeat = (n, what) => [...new Array(n)].map(() => what).join('');

console.error(chalk.red(repeat(str.length + 10, '=')));
console.error(chalk.red(`${repeat(4, '=')} ${str.toUpperCase()} ${repeat(4, '=')}`));
console.error(chalk.red(repeat(str.length + 10, '=')));
}

const message = process.argv[2];
const modifiedFiles = execSync('git diff --cached --name-only').toString('utf-8');
const expected = getExpectedPrefixes(modifiedFiles);
const [actual, rest] = getActualPrefixes(message);

if (!actual.length) {
banner('Commit message is invalid - missing prefix');

console.error('To better describe commit messages, we require including prefixes based on file changes:');
console.error('');
console.error(chalk.gray('>'), 'prefix1, prefix2: brief description of change');
console.error('');
console.error('Suggested message:');
console.error('');
console.error(chalk.red(`- ${message}`));
console.error(chalk.green(`+ ${expected.length ? csv(expected) : 'prefix'}: ${message}`));

process.exit(1);
}

const missing = getMissingPrefixes(expected, actual);
if (missing.length) {
banner('Commit message is invalid - invalid prefixes');

console.error('Some prefixes are missing based on changed files:');
console.error(chalk.red(`- ${csv(missing)}`));
console.error('');
console.error('Suggested message:');
console.error(chalk.red(`- ${csv(actual)}: ${rest}`));
console.error(chalk.green(`+ ${csv(normalizeExpectedPrefixes(expected, missing, actual))}: ${rest}`));

process.exit(1);
}
4 changes: 2 additions & 2 deletions .prettierrc → .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"printWidth": 120,
"proseWrap": "always",
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "always",
"tabWidth": 4
"tabWidth": 4,
"endOfLine": "auto"
}
Loading