Skip to content

Commit adac766

Browse files
committed
chore: Major CI Refactor
1 parent bc9e6cc commit adac766

21 files changed

+665
-326
lines changed

.github/workflows/ci.yml

Lines changed: 453 additions & 221 deletions
Large diffs are not rendered by default.

.github/workflows/stress.yml

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,66 +43,103 @@ env:
4343
TEMPORAL_TESTING_MEM_LOG_DIR: /tmp/worker-mem-logs
4444
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4545
REUSE_V8_CONTEXT: ${{ inputs.reuse-v8-context }}
46+
IS_MAIN_BRANCH: |
47+
${{
48+
github.repository == 'temporalio/sdk-typescript'
49+
&& (github.ref == 'refs/heads/main'
50+
|| startsWith(github.ref, 'refs/tags/')
51+
|| startsWith(github.ref, 'refs/heads/releases'))
52+
&& github.event_name != 'pull_request'
53+
}}
4654
4755
jobs:
4856
stress-test:
4957
runs-on: buildjet-4vcpu-ubuntu-2204
5058
steps:
5159
- name: Print build info
5260
run: 'echo test-type: ${{ inputs.test-type }}, test-timeout-minutes: ${{ inputs.test-timeout-minutes }}, reuse-v8-context: $REUSE_V8_CONTEXT'
53-
- uses: actions/checkout@v2
61+
62+
- uses: actions/checkout@v4
5463
with:
5564
submodules: recursive
56-
- uses: actions-rs/toolchain@v1
65+
66+
- name: Install Node
67+
uses: actions/setup-node@v4
5768
with:
58-
toolchain: stable
59-
- uses: actions/setup-node@v1
69+
node-version: 20
70+
71+
- name: Get NPM cache directory
72+
id: npm-cache-dir
73+
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
74+
75+
- name: Restore NPM cache
76+
uses: actions/cache/restore@v4
6077
with:
61-
node-version: ${{ matrix.node }}
78+
path: ${{ steps.npm-cache-dir.outputs.dir }}
79+
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
80+
restore-keys: |
81+
npm-main-linux-x64-
82+
83+
- name: Install Rust
84+
uses: dtolnay/rust-toolchain@stable
85+
with:
86+
target: x86_64-unknown-linux-gnu
87+
6288
- name: Install protoc
63-
uses: arduino/setup-protoc@v1
89+
uses: arduino/setup-protoc@v3
6490
with:
65-
version: '3.x'
91+
# TODO: Upgrade proto once https://github.com/arduino/setup-protoc/issues/99 is fixed
92+
version: '23.x'
6693
repo-token: ${{ secrets.GITHUB_TOKEN }}
67-
- uses: Swatinem/rust-cache@v1
94+
95+
- name: Rust Cargo and Build cache
96+
uses: Swatinem/rust-cache@v2
6897
with:
69-
working-directory: packages/core-bridge
70-
# Don't build during install phase since we're going to explicitly build
71-
- run: npm ci --ignore-scripts
72-
- run: npm run build
98+
workspaces: packages/core-bridge -> target
99+
prefix-key: corebridge-buildcache
100+
shared-key: linux-intel
101+
env-vars: ''
102+
save-if: ${{ env.IS_MAIN_BRANCH }}
103+
104+
- name: Download dependencies
105+
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors
106+
run: |
107+
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
108+
109+
- name: Compile code
110+
run: npm run build
73111
env:
74112
BUILD_CORE_RELEASE: true
75113

76-
# docker-compose
77-
- name: Checkout docker-compose repo
78-
uses: actions/checkout@v2
79-
with:
80-
repository: temporalio/docker-compose
81-
path: docker-compose
114+
- name: Install Temporal CLI
115+
uses: temporalio/setup-temporal@v0
82116

83-
- name: Start Temporal Server
84-
run: docker-compose up -d
85-
working-directory: docker-compose
117+
- name: Run Temporal CLI
118+
shell: bash
119+
run: |
120+
temporal server start-dev --headless &
86121
87-
- name: Wait for Temporal Server
88-
run: npm run wait-namespace
89-
# end:docker-compose
122+
- name: Run tests
123+
run: |
124+
mkdir -p $TEMPORAL_TESTING_LOG_DIR/tails
125+
mkdir -p $TEMPORAL_TESTING_MEM_LOG_DIR
126+
timeout ${{ inputs.test-timeout-minutes }}m npm run ${{ inputs.test-type }}
90127
91-
- run: mkdir -p $TEMPORAL_TESTING_LOG_DIR/tails
92-
- run: mkdir -p $TEMPORAL_TESTING_MEM_LOG_DIR
93-
- run: 'timeout ${{ inputs.test-timeout-minutes }}m npm run ${{ inputs.test-type }}'
94128
- run: for f in $TEMPORAL_TESTING_LOG_DIR/*.log; do tail -20000 $f > $TEMPORAL_TESTING_LOG_DIR/tails/$(basename $f); done
95129
if: ${{ always() }}
96-
- uses: actions/upload-artifact@v3
130+
131+
- uses: actions/upload-artifact@v4
97132
if: ${{ always() }}
98133
with:
99-
name: worker-logs
134+
name: worker-logs-${{ inputs.reuse-v8-context && 'reuse-v8' || 'no-reuse-v8' }}
100135
path: ${{ env.TEMPORAL_TESTING_LOG_DIR }}/tails
101-
- uses: actions/upload-artifact@v3
136+
137+
- uses: actions/upload-artifact@v4
102138
if: ${{ always() }}
103139
with:
104-
name: worker-mem-logs
140+
name: worker-mem-logs-${{ inputs.reuse-v8-context && 'reuse-v8' || 'no-reuse-v8' }}
105141
path: ${{ env.TEMPORAL_TESTING_MEM_LOG_DIR }}
106142

107143
# TODO: set up alerting
108144
# TODO: record test durations and other metrics like memory usage / cache utilization / CPU
145+
# TODO: uses prebuilt binaries from ci.yml

CONTRIBUTING.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,14 @@ See [sdk-structure.md](./docs/sdk-structure.md)
5050

5151
### Environment setup
5252

53-
- Install Node 18 and [Temporal Server](https://github.com/temporalio/docker-compose#temporal-server-docker-compose-files)
54-
- Install the [Rust toolchain](https://rustup.rs/)
55-
- Install [Protocol Buffers](https://github.com/protocolbuffers/protobuf/releases/)
53+
- The TS SDK can be executed on 16, 18 and 20. However, for SDK development, we recommend
54+
using Node 20. For easier testing, you may want to use a version manager, such as:
55+
[nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) or [volta](https://volta.sh/).
56+
57+
- To run tests, you will need access to a local Temporal server, e.g. using the
58+
[Temporal CLI's integrated dev server](https://github.com/temporalio/cli#start-the-server).
59+
- Install the [Rust toolchain](https://rustup.rs/).
60+
- Install [Protocol Buffers](https://github.com/protocolbuffers/protobuf/releases/).
5661
- Clone the [sdk-typescript](https://github.com/temporalio/sdk-typescript) repo:
5762
```sh
5863
git clone https://github.com/temporalio/sdk-typescript.git
@@ -62,7 +67,8 @@ See [sdk-structure.md](./docs/sdk-structure.md)
6267
```sh
6368
git submodule update --init --recursive
6469
```
65-
> If you get a `The authenticity of host 'github.com (192.30.252.123)' can't be established.` error, run `ssh-keyscan github.com >> ~/.ssh/known_hosts` and retry.
70+
> If you get a `The authenticity of host 'github.com (192.30.252.123)' can't be established.`
71+
> error, run `ssh-keyscan github.com >> ~/.ssh/known_hosts` and retry.
6672
- Install the dependencies:
6773
```sh
6874
npm ci
@@ -79,11 +85,13 @@ If building fails, resetting your environment may help:
7985
npx lerna clean -y && npm ci
8086
```
8187

82-
If `npm ci` fails in `@temporalio/core-bridge` on the command `node ./scripts/build.js`, you may need to do `rustup update`.
88+
If `npm ci` fails in `@temporalio/core-bridge` on the command `node ./scripts/build.js`, you may
89+
need to do `rustup update`.
8390

8491
To update to the latest version of the Core SDK, run `git submodule update` followed by `npm run build` to recompile.
8592

86-
> For cross compilation on MacOS follow [these instructions](https://github.com/temporalio/sdk-typescript/blob/main/docs/building.md) (only required for publishing packages).
93+
> For cross compilation on MacOS follow [these instructions](https://github.com/temporalio/sdk-typescript/blob/main/docs/building.md)
94+
> (only required for publishing packages).
8795
8896
## Development
8997

@@ -109,7 +117,7 @@ described [here](https://doc.rust-lang.org/cargo/reference/overriding-dependenci
109117

110118
In order to run integration tests:
111119

112-
1. Run the temporal server using [docker-compose](https://github.com/temporalio/docker-compose).
120+
1. Run the Temporal server, e.g. using the [Temporal CLI's integrated dev server](https://github.com/temporalio/cli#start-the-server)
113121
1. Export `RUN_INTEGRATION_TESTS=true`
114122

115123
#### test-npm-init

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/client/src/schedule-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export async function encodeScheduleAction(
267267
},
268268
input: { payloads: await encodeToPayloads(dataConverter, ...action.args) },
269269
taskQueue: {
270-
kind: temporal.api.enums.v1.TaskQueueKind.TASK_QUEUE_KIND_UNSPECIFIED,
270+
kind: temporal.api.enums.v1.TaskQueueKind.TASK_QUEUE_KIND_NORMAL,
271271
name: action.taskQueue,
272272
},
273273
workflowExecutionTimeout: msOptionalToTs(action.workflowExecutionTimeout),

packages/client/src/workflow-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ export class WorkflowClient extends BaseClient {
901901
signalName,
902902
signalInput: { payloads: await encodeToPayloads(this.dataConverter, ...signalArgs) },
903903
taskQueue: {
904-
kind: temporal.api.enums.v1.TaskQueueKind.TASK_QUEUE_KIND_UNSPECIFIED,
904+
kind: temporal.api.enums.v1.TaskQueueKind.TASK_QUEUE_KIND_NORMAL,
905905
name: options.taskQueue,
906906
},
907907
workflowExecutionTimeout: options.workflowExecutionTimeout,
@@ -949,7 +949,7 @@ export class WorkflowClient extends BaseClient {
949949
workflowType: { name: workflowType },
950950
input: { payloads: await encodeToPayloads(this.dataConverter, ...opts.args) },
951951
taskQueue: {
952-
kind: temporal.api.enums.v1.TaskQueueKind.TASK_QUEUE_KIND_UNSPECIFIED,
952+
kind: temporal.api.enums.v1.TaskQueueKind.TASK_QUEUE_KIND_NORMAL,
953953
name: opts.taskQueue,
954954
},
955955
workflowExecutionTimeout: opts.workflowExecutionTimeout,

packages/core-bridge/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build-rust-release": "npm run build-rust -- --release",
1111
"install": "node ./scripts/build.js",
1212
"format": "cargo fmt",
13-
"lint": "cargo clippy --fix",
13+
"lint": "cargo clippy --fix --allow-staged",
1414
"lint.check": "cargo clippy"
1515
},
1616
"keywords": [

packages/test/src/helpers-integration.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from '@temporalio/client';
99
import {
1010
LocalTestWorkflowEnvironmentOptions,
11-
TestWorkflowEnvironment,
1211
workflowInterceptorModules as defaultWorkflowInterceptorModules,
1312
} from '@temporalio/testing';
1413
import {
@@ -21,7 +20,13 @@ import {
2120
} from '@temporalio/worker';
2221
import * as workflow from '@temporalio/workflow';
2322
import { ConnectionInjectorInterceptor } from './activities/interceptors';
24-
import { Worker, test as anyTest, bundlerOptions, registerDefaultCustomSearchAttributes } from './helpers';
23+
import {
24+
Worker,
25+
TestWorkflowEnvironment,
26+
test as anyTest,
27+
bundlerOptions,
28+
registerDefaultCustomSearchAttributes,
29+
} from './helpers';
2530

2631
export interface Context {
2732
env: TestWorkflowEnvironment;

0 commit comments

Comments
 (0)