Skip to content

Commit e54df6f

Browse files
CopilotYunchuWang
andcommitted
Testing pipeline setup
Co-Authored-By: YunchuWang <12449837+YunchuWang@users.noreply.github.com>
1 parent bcac4ed commit e54df6f

File tree

7 files changed

+443
-17
lines changed

7 files changed

+443
-17
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 🧪 DTS Emulator E2E Tests
2+
3+
# This workflow runs E2E tests against the Durable Task Scheduler (DTS) emulator.
4+
# It mirrors the Python testing setup at durabletask-python for Azure-managed tests.
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
dts-e2e-tests:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
node-version: ["18.x", "20.x", "22.x"]
23+
env:
24+
EMULATOR_VERSION: "latest"
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: 📥 Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: 🐳 Pull Docker image
32+
run: docker pull mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION
33+
34+
- name: 🚀 Run Docker container
35+
run: |
36+
docker run --name dtsemulator -d -p 8080:8080 mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION
37+
38+
- name: ⏳ Wait for container to be ready
39+
run: sleep 10 # Adjust if your service needs more time to start
40+
41+
- name: 🔧 Set environment variables
42+
run: |
43+
echo "TASKHUB=default" >> $GITHUB_ENV
44+
echo "ENDPOINT=localhost:8080" >> $GITHUB_ENV
45+
46+
- name: ⚙️ NodeJS - Install
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: ${{ matrix.node-version }}
50+
registry-url: "https://registry.npmjs.org"
51+
52+
- name: ⚙️ Install dependencies
53+
run: npm install
54+
55+
- name: ✅ Run E2E tests against DTS emulator
56+
run: npm run test:e2e:azuremanaged:internal

.github/workflows/pr-validation.yaml

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,66 @@ on:
88
branches:
99
- main
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
12-
build:
15+
lint-and-unit-tests:
1316
runs-on: ubuntu-latest
1417

1518
env:
16-
NODE_VER: 16.14.0
17-
18-
services:
19-
# docker run --name durabletask-sidecar -p 4001:4001 --env 'DURABLETASK_SIDECAR_LOGLEVEL=Debug' --rm cgillum/durabletask-sidecar:latest start --backend Emulator
20-
durabletask-sidecar:
21-
image: cgillum/durabletask-sidecar:latest
22-
ports:
23-
- 4001:4001
24-
env:
25-
DURABLETASK_SIDECAR_LOGLEVEL: Debug
26-
DURABLETASK_STORAGE_PROVIDER: Emulator
19+
NODE_VER: 18.x
2720

2821
steps:
2922
- name: 📥 Checkout code
30-
uses: actions/checkout@v2
23+
uses: actions/checkout@v4
3124

3225
- name: ⚙️ NodeJS - Install
33-
uses: actions/setup-node@v2
26+
uses: actions/setup-node@v4
3427
with:
3528
node-version: ${{ env.NODE_VER }}
3629
registry-url: "https://registry.npmjs.org"
3730

3831
- name: ⚙️ Install dependencies
3932
run: npm install
4033

34+
- name: 🔍 Run linting
35+
run: npm run lint
36+
4137
- name: ✅ Run unit tests
42-
run: npm test test/unit
38+
run: npm run test:unit
39+
40+
e2e-tests:
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
node-version: ["18.x", "20.x", "22.x"]
45+
needs: lint-and-unit-tests
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: 📥 Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: ⚙️ NodeJS - Install
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: ${{ matrix.node-version }}
56+
registry-url: "https://registry.npmjs.org"
57+
58+
- name: ⚙️ Install dependencies
59+
run: npm install
60+
61+
# Install Go SDK for durabletask-go sidecar
62+
- name: 🔧 Install Go SDK
63+
uses: actions/setup-go@v5
64+
with:
65+
go-version: "stable"
4366

44-
- name: ✅ Run e2e tests
45-
run: ./scripts/test-e2e.sh
67+
# Install and run the durabletask-go sidecar for running e2e tests
68+
- name: ✅ Run E2E tests with durabletask-go sidecar
69+
run: |
70+
go install github.com/microsoft/durabletask-go@main
71+
durabletask-go --port 4001 &
72+
sleep 5 # Wait for sidecar to be ready
73+
npm run test:e2e:internal

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"test:e2e:internal": "jest test/e2e --runInBand --detectOpenHandles",
1111
"test:e2e": "./scripts/test-e2e.sh",
1212
"test:e2e:one": "jest test/e2e --runInBand --detectOpenHandles --testNamePattern",
13+
"test:e2e:azuremanaged:internal": "jest test/e2e-azuremanaged --runInBand --detectOpenHandles",
14+
"test:e2e:azuremanaged": "./scripts/test-e2e-azuremanaged.sh",
1315
"start": "ts-node --swc ./src/index.ts",
1416
"example": "ts-node --swc",
1517
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",

scripts/test-e2e-azuremanaged.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# Script to run E2E tests against the DTS (Durable Task Scheduler) emulator.
3+
#
4+
# This script mirrors the Python testing setup at durabletask-python for Azure-managed tests.
5+
# It expects the DTS emulator to be running at the specified endpoint.
6+
#
7+
# Environment variables:
8+
# - ENDPOINT: The endpoint for the DTS emulator (default: localhost:8080)
9+
# - TASKHUB: The task hub name (default: default)
10+
11+
ENDPOINT="${ENDPOINT:-localhost:8080}"
12+
TASKHUB="${TASKHUB:-default}"
13+
14+
# Start the DTS emulator if it is not running yet
15+
if [ ! "$(docker ps -q -f name=dts-emulator)" ]; then
16+
if [ "$(docker ps -aq -f status=exited -f name=dts-emulator)" ]; then
17+
# cleanup
18+
docker rm dts-emulator
19+
fi
20+
21+
# run your container
22+
echo "Starting DTS emulator"
23+
docker run \
24+
--name dts-emulator -d --rm \
25+
-p 8080:8080 \
26+
mcr.microsoft.com/dts/dts-emulator:latest
27+
28+
# Wait for container to be ready
29+
echo "Waiting for DTS emulator to be ready..."
30+
sleep 10
31+
fi
32+
33+
echo "Running E2E tests against DTS emulator"
34+
echo "Endpoint: $ENDPOINT"
35+
echo "TaskHub: $TASKHUB"
36+
37+
ENDPOINT="$ENDPOINT" TASKHUB="$TASKHUB" npm run test:e2e:azuremanaged:internal
38+
39+
# It should fail if the npm run fails
40+
if [ $? -ne 0 ]; then
41+
echo "E2E tests failed"
42+
exit 1
43+
fi
44+
45+
echo "Stopping DTS emulator"
46+
docker stop dts-emulator

scripts/test-e2e.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/bash
2+
# Script to run E2E tests against the durabletask-sidecar.
3+
#
4+
# This script uses the cgillum/durabletask-sidecar Docker container for local testing.
5+
# In CI/CD, we use durabletask-go sidecar instead (similar to Python SDK testing approach).
6+
#
7+
# NOTE: To run tests similar to the Python SDK setup:
8+
# go install github.com/microsoft/durabletask-go@main
9+
# durabletask-go --port 4001
10+
211
# Start the sidecar if it is not running yet
312
if [ ! "$(docker ps -q -f name=durabletask-sidecar)" ]; then
413
if [ "$(docker ps -aq -f status=exited -f name=durabletask-sidecar)" ]; then

0 commit comments

Comments
 (0)