Skip to content
Draft
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
56 changes: 56 additions & 0 deletions .github/workflows/dts-e2e-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 🧪 DTS Emulator E2E Tests

# This workflow runs E2E tests against the Durable Task Scheduler (DTS) emulator.
# It mirrors the Python testing setup at durabletask-python for Azure-managed tests.

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
dts-e2e-tests:
strategy:
fail-fast: false
matrix:
node-version: ["18.x", "20.x", "22.x"]
env:
EMULATOR_VERSION: "latest"
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: 🐳 Pull Docker image
run: docker pull mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION

- name: 🚀 Run Docker container
run: |
docker run --name dtsemulator -d -p 8080:8080 mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION

- name: ⏳ Wait for container to be ready
run: sleep 10 # Adjust if your service needs more time to start

- name: 🔧 Set environment variables
run: |
echo "TASKHUB=default" >> $GITHUB_ENV
echo "ENDPOINT=localhost:8080" >> $GITHUB_ENV

- name: ⚙️ NodeJS - Install
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"

- name: ⚙️ Install dependencies
run: npm install

- name: ✅ Run E2E tests against DTS emulator
run: npm run test:e2e:azuremanaged:internal
62 changes: 45 additions & 17 deletions .github/workflows/pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,66 @@ on:
branches:
- main

permissions:
contents: read

jobs:
build:
lint-and-unit-tests:
runs-on: ubuntu-latest

env:
NODE_VER: 16.14.0

services:
# docker run --name durabletask-sidecar -p 4001:4001 --env 'DURABLETASK_SIDECAR_LOGLEVEL=Debug' --rm cgillum/durabletask-sidecar:latest start --backend Emulator
durabletask-sidecar:
image: cgillum/durabletask-sidecar:latest
ports:
- 4001:4001
env:
DURABLETASK_SIDECAR_LOGLEVEL: Debug
DURABLETASK_STORAGE_PROVIDER: Emulator
NODE_VER: 18.x

steps:
- name: 📥 Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: ⚙️ NodeJS - Install
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VER }}
registry-url: "https://registry.npmjs.org"

- name: ⚙️ Install dependencies
run: npm install

- name: 🔍 Run linting
run: npm run lint

- name: ✅ Run unit tests
run: npm test test/unit
run: npm run test:unit

e2e-tests:
strategy:
fail-fast: false
matrix:
node-version: ["18.x", "20.x", "22.x"]
needs: lint-and-unit-tests
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout code
uses: actions/checkout@v4

- name: ⚙️ NodeJS - Install
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"

- name: ⚙️ Install dependencies
run: npm install

# Install Go SDK for durabletask-go sidecar
- name: 🔧 Install Go SDK
uses: actions/setup-go@v5
with:
go-version: "stable"

- name: ✅ Run e2e tests
run: ./scripts/test-e2e.sh
# Install and run the durabletask-go sidecar for running e2e tests
- name: ✅ Run E2E tests with durabletask-go sidecar
run: |
go install github.com/microsoft/durabletask-go@main
durabletask-go --port 4001 &
sleep 5 # Wait for sidecar to be ready
npm run test:e2e:internal
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"test:e2e:internal": "jest test/e2e --runInBand --detectOpenHandles",
"test:e2e": "./scripts/test-e2e.sh",
"test:e2e:one": "jest test/e2e --runInBand --detectOpenHandles --testNamePattern",
"test:e2e:azuremanaged:internal": "jest test/e2e-azuremanaged --runInBand --detectOpenHandles",
"test:e2e:azuremanaged": "./scripts/test-e2e-azuremanaged.sh",
"start": "ts-node --swc ./src/index.ts",
"example": "ts-node --swc",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
Expand Down
46 changes: 46 additions & 0 deletions scripts/test-e2e-azuremanaged.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Script to run E2E tests against the DTS (Durable Task Scheduler) emulator.
#
# This script mirrors the Python testing setup at durabletask-python for Azure-managed tests.
# It expects the DTS emulator to be running at the specified endpoint.
#
# Environment variables:
# - ENDPOINT: The endpoint for the DTS emulator (default: localhost:8080)
# - TASKHUB: The task hub name (default: default)

ENDPOINT="${ENDPOINT:-localhost:8080}"
TASKHUB="${TASKHUB:-default}"

# Start the DTS emulator if it is not running yet
if [ ! "$(docker ps -q -f name=dts-emulator)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=dts-emulator)" ]; then
# cleanup
docker rm dts-emulator
fi

# run your container
echo "Starting DTS emulator"
docker run \
--name dts-emulator -d --rm \
-p 8080:8080 \
mcr.microsoft.com/dts/dts-emulator:latest

# Wait for container to be ready
echo "Waiting for DTS emulator to be ready..."
sleep 10
fi

echo "Running E2E tests against DTS emulator"
echo "Endpoint: $ENDPOINT"
echo "TaskHub: $TASKHUB"

ENDPOINT="$ENDPOINT" TASKHUB="$TASKHUB" npm run test:e2e:azuremanaged:internal

# It should fail if the npm run fails
if [ $? -ne 0 ]; then
echo "E2E tests failed"
exit 1
fi

echo "Stopping DTS emulator"
docker stop dts-emulator
9 changes: 9 additions & 0 deletions scripts/test-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/bash
# Script to run E2E tests against the durabletask-sidecar.
#
# This script uses the cgillum/durabletask-sidecar Docker container for local testing.
# In CI/CD, we use durabletask-go sidecar instead (similar to Python SDK testing approach).
#
# NOTE: To run tests similar to the Python SDK setup:
# go install github.com/microsoft/durabletask-go@main
# durabletask-go --port 4001

# Start the sidecar if it is not running yet
if [ ! "$(docker ps -q -f name=durabletask-sidecar)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=durabletask-sidecar)" ]; then
Expand Down
Loading
Loading