Skip to content

Commit

Permalink
Improve external developer experience (segmentio#81)
Browse files Browse the repository at this point in the history
* Support external dx

* Add external DX workflow

* Add --ignore-optional

* [core] Add jest moduleNameMapper

* Fix typo

* Add yarn link

* no ci

* [destinations] Add subscriptions to jest module map

* yarn exec install

* dash-dash

* ignore browser destinations when calling build:

* replicate manual test flow

* Switch to yarn install

* Move browser-destination jest config to file and conditionally run tests

* [ci] sleep after bootstrapping

* --no-ci bootstrap

* Add subscriptions path

* Update README.md

* Reformat jest.config.js with 4 spaces

* Add newline to jest.config.js
  • Loading branch information
gpsamson authored Aug 24, 2021
1 parent d7465d5 commit 792f1a8
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 18 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ext.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test External

on: [push]

jobs:
install-and-test:
runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'

- name: Install
run: yarn --ignore-engines --ignore-optional

- name: Bootstrap
run: yarn bootstrap --no-ci

- name: Test
run: yarn test

- name: Build
run: NODE_ENV=production yarn build --ignore @segment/browser-destinations
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ This project is a monorepo with multiple packages using Yarn Workspaces:
- `packages/cli` - a set of command line tools for interacting with the repo
- `packages/core` - the core runtime engine for actions, including mapping-kit transforms
- `packages/destinations-actions` - destination definitions and their actions
- `packages/destinations-subscriptions` - validates events against an action's subscription AST

```
$ yarn install
git clone https://github.com/segmentio/action-destinations.git
cd action-destinations
yarn --ignore-engines --ignore-optional
yarn bootstrap
yarn test
```

## Test Actions Locally
Expand Down
3 changes: 3 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"useWorkspaces": true,
"version": "independent",
"command": {
"bootstrap": {
"npmClientArgs": ["--ignore-engines", "--ignore-optional"]
},
"version": {
"allowBranch": "main"
}
Expand Down
27 changes: 27 additions & 0 deletions packages/browser-destinations/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = async () => {
const config = {
rootDir: './',
moduleNameMapper: {
'@segment/actions-core': '<rootDir>/../core/src/index.ts'
},
transform: {
'^.+\\.[t|j]sx?$': 'babel-jest'
},
transformIgnorePatterns: [
'/node_modules/(?!@segment/analytics-next).+\\.js$'
],
forceExit: true
}

try {
await import('@segment/analytics-next')
} catch (_) {
config.testPathIgnorePatterns = [
'/node_modules/',
'<rootDir>/src/'
]
console.warn('optional dependency @segment/analytics-next not found, ignoring all tests')
}

return config
}
14 changes: 1 addition & 13 deletions packages/browser-destinations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"clean": "tsc -b tsconfig.build.json --clean",
"postclean": "rm -rf dist",
"prepublishOnly": "yarn build",
"test": "jest",
"test": "jest --passWithNoTests",
"typecheck": "tsc --noEmit",
"dev": "concurrently \"webpack serve\" \"webpack -c webpack.config.js --watch\""
},
Expand Down Expand Up @@ -68,17 +68,5 @@
"singleQuote": true,
"trailingComma": "none",
"printWidth": 120
},
"jest": {
"moduleNameMapper": {
"@segment/actions-core": "<rootDir>/../core/src/index.ts"
},
"transform": {
"^.+\\.[t|j]sx?$": "babel-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?!@segment/analytics-next).+\\.js$"
],
"forceExit": true
}
}
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@oclif/errors": "^1",
"@oclif/plugin-help": "^3",
"@segment/action-destinations": "^3.6.1",
"@segment/browser-destinations": "^3.6.0",
"chalk": "^4.1.1",
"chokidar": "^3.5.1",
"execa": "^5.1.1",
Expand All @@ -79,6 +78,7 @@
},
"optionalDependencies": {
"@segment/actions-core": "^3.6.0",
"@segment/browser-destinations": "^3.6.0",
"@segment/control-plane-service-client": "github:segmentio/control-plane-service-js-client.git#master"
},
"oclif": {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
"testEnvironment": "node",
"modulePathIgnorePatterns": [
"<rootDir>/dist/"
]
],
"moduleNameMapper": {
"@segment/ajv-human-errors": "<rootDir>/../ajv-human-errors",
"@segment/destination-subscriptions": "<rootDir>/../destination-subscriptions/src"
}
}
}
3 changes: 2 additions & 1 deletion packages/destination-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"<rootDir>/dist/"
],
"moduleNameMapper": {
"@segment/actions-core": "<rootDir>/../core/src/index.ts"
"@segment/actions-core": "<rootDir>/../core/src/index.ts",
"@segment/destination-subscriptions": "<rootDir>/../destination-subscriptions/src"
},
"setupFilesAfterEnv": [
"<rootDir>/test/setup-after-env.ts"
Expand Down
3 changes: 2 additions & 1 deletion packages/destination-actions/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@segment/actions-core": ["../core/src"]
"@segment/actions-core": ["../core/src"],
"@segment/destination-subscriptions": ["../destination-subscriptions/src"]
}
},
"exclude": [],
Expand Down

0 comments on commit 792f1a8

Please sign in to comment.