Skip to content

Commit

Permalink
Restructure project (#7)
Browse files Browse the repository at this point in the history
* Restructure project

* Add github actions

* wip

* Lerna link

* Add internal packages as root deps

* Commit package-lock

* Make tests pass in ci

* Disable npm cache

* Add lint step

* Fix c++ compilation

* Cleanup github WF

* Use npm 7

* Skip lerna bootstrap

* Fix format

* Final changes?

* Build only node 12
  • Loading branch information
bergundy authored Feb 24, 2021
1 parent 3acbc84 commit cd18816
Show file tree
Hide file tree
Showing 133 changed files with 16,580 additions and 3,563 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
lib
es2020
commonjs
18 changes: 13 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-unused-vars": [
1,
{
"argsIgnorePattern": "^_"
}
]
}
}
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ci
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
build-lint-test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [12]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm -g i npm@next-7
- run: npm ci
- run: npm run build
- run: npm run lint
- run: npm test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
lib/
proto/
workflow-lib/commonjs/
*.tsbuildinfo
build/
commonjs/
es2020/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "sdk-core"]
path = sdk-core
url = [email protected]:temporalio/sdk-core.git
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
build
native
sdk-core
lib
es2020
commonjs
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"singleQuote": true
}
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
# sdk-node
Temporal NodeJS SDK
# Temporal NodeJS SDK

## This is a work in progress, not ready for use yet

For more information see the [proposal](https://github.com/temporalio/proposals/blob/master/node/node-sdk.md).

### Development

#### Environment set up
* Clone [sdk-core](https://github.com/temporalio/sdk-core) as a sibling directory of this repository root

```
npm install
npm run compile-proto
git submodule init
git submodule update
npm ci
```

#### Building

```
npm run clean
npm run build
```
-- OR --

#### Building with watch

```
npm run clean
npm run build # Must be run once before build.watch
npm run build.watch
```

#### Testing

```
npm run test
```

-- OR --

```
npm run test.watch
```
8 changes: 5 additions & 3 deletions docs/workflow-scopes-and-cancellation.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
### Scopes and Cancellation

Temporal workflows have different types that can be cancelled:
* A timer or an activity
* An entire workflow
* A workflow scope

- A timer or an activity
- An entire workflow
- A workflow scope

Workflows are represented internally by a tree of scopes where the `main` function runs in the root scope.
Cancellation propagates from outer scopes to inner ones and is handled by catching `CancellationError`s when `await`ing on `Promise`s.
Expand Down Expand Up @@ -53,6 +54,7 @@ export async function main() {
In order to have fine-grained control over cancellation, the workflow library exports 2 methods for explicitly creating scopes.

The first is `cancellationScope` which when cancelled will propagate cancellation to all child scopes such as timers, activities and other scopes.

```ts
import { CancellationError, cancellationScope, cancel, sleep } from '@temporal-sdk/workflow';
import { httpGetJSON } from '@activities';
Expand Down
15 changes: 15 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "3.22.1",
"npmClient": "npm",
"command": {
"publish": {
"ignoreChanges": ["ignored-file", "*.md"],
"message": "chore(release): publish",
"registry": "https://npm.pkg.github.com"
},
"bootstrap": {
"npmClientArgs": ["--no-package-lock"]
}
},
"packages": ["packages/*"]
}
Loading

0 comments on commit cd18816

Please sign in to comment.