Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: Continuous Integration
on: # rebuild any PRs and main branch changes
pull_request:
push:
Expand All @@ -24,8 +24,19 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm -g i npm@next-7
- run: npm -g i npm@next-7 # TODO: do we need this?
- run: npm ci
- run: npm run build
- run: npm run lint
- name: Get Temporal docker-compose.yml
run: wget https://raw.githubusercontent.com/temporalio/docker-compose/main/docker-compose.yml
if: ${{ startsWith(matrix.os, 'ubuntu') }}
- name: Start Temporal Server
run: docker-compose up -d
if: ${{ startsWith(matrix.os, 'ubuntu') }}
- name: Wait for Temporal Server
run: node scripts/wait-on-temporal.js
if: ${{ startsWith(matrix.os, 'ubuntu') }}
- run: npm test
env:
RUN_INTEGRATION_TESTS: ${{ startsWith(matrix.os, 'ubuntu') }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"typescript": "^4.2.2"
},
"scripts": {
"build": "lerna run build",
"build": "lerna run --stream build",
"build.watch": "lerna run --stream build.watch",
"test": "lerna run test",
"test": "lerna run --stream test",
"test.watch": "lerna run --stream test.watch",
"lint": "eslint packages/*/src --ext .ts && prettier --check .",
"format": "prettier --write .",
Expand Down
3 changes: 3 additions & 0 deletions packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"test": "ava ./lib/test-*.js",
"test.watch": "ava --watch ./lib/test-*.js"
},
"ava": {
"timeout": "60s"
},
"keywords": [
"temporal",
"workflow",
Expand Down
11 changes: 9 additions & 2 deletions packages/test/src/test-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ const {
EVENT_TYPE_TIMER_FIRED,
EVENT_TYPE_TIMER_CANCELED,
} = iface.temporal.api.enums.v1.EventType;

const timerEventTypes = new Set([EVENT_TYPE_TIMER_STARTED, EVENT_TYPE_TIMER_FIRED, EVENT_TYPE_TIMER_CANCELED]);

if (process.env.RUN_INTEGRATION_TESTS === '1') {
function isSet(env: string | undefined) {
if (env === undefined) return false;
env = env.toLocaleLowerCase();
return env === '1' || env === 't' || env === 'true';
}

if (isSet(process.env.RUN_INTEGRATION_TESTS)) {
test.before((t) => {
worker.run('test').catch((err) => {
t.fail(`Failed to run worker: ${err}`);
Expand Down Expand Up @@ -55,7 +62,7 @@ if (process.env.RUN_INTEGRATION_TESTS === '1') {
test('cancel-timer-immediately', async (t) => {
const client = new Connection();
const opts = compileWorkflowOptions(addDefaults({ taskQueue: 'test' }));
const runId = await client.startWorkflowExecution(opts, 'cancel-timer');
const runId = await client.startWorkflowExecution(opts, 'cancel-timer-immediately');
const res = await client.untilComplete(opts.workflowId, runId);
t.is(res, undefined);
const execution = await client.service.getWorkflowExecutionHistory({
Expand Down
41 changes: 41 additions & 0 deletions scripts/wait-on-temporal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const { Connection } = require('@temporalio/client');

class Timer {
constructor(ms) {
this.ms = ms;
}

then(resolve) {
setTimeout(resolve, this.ms);
}
}

async function main(maxAttempts = 100, retryIntervalSecs = 1) {
for (let attempt = 1; attempt <= maxAttempts; ++attempt) {
try {
const client = new Connection();
await client.service.describeNamespace({ namespace: 'default' });
// We wait an extra 3 seconds after a successful describe namespace because the namespace
// is not really ready after the call.
// See: https://github.com/temporalio/temporal/issues/1336
await new Timer(3000);
break;
} catch (err) {
if (attempt === maxAttempts) {
throw err;
}
await new Timer(retryIntervalSecs * 1000);
}
}
}

main().then(
() => {
console.log('Connected');
process.exit(0);
},
(err) => {
console.error('Failed to connect', err);
process.exit(1);
}
);