Skip to content
Open
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The image is assembled from the linux distribution directories only.
*
!dist/wso2-workflow-runtime-*-linux-*/
18 changes: 16 additions & 2 deletions .github/workflows/ballerina-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
required: true
default: sqlite
type: choice
options: [sqlite, postgresql, mysql]
options: [sqlite, postgresql, mysql, dev]

permissions:
contents: read
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
database: >-
${{ fromJSON(
github.event_name == 'workflow_dispatch' && format('["{0}"]', inputs.database) ||
'["sqlite", "postgresql", "mysql"]') }}
'["sqlite", "postgresql", "mysql", "dev"]') }}
services:
postgres:
image: postgres:16
Expand Down Expand Up @@ -83,6 +83,11 @@ jobs:
tools/go.sum
- name: Build the engine
run: make engine && ./build/workflow-engine version
# Both service databases run in every job; one job covers the schema test for both.
- name: Test schema preparation on PostgreSQL and MySQL
if: matrix.database == 'postgresql' && matrix.suite == 'smoke'
working-directory: engine
run: go test -count=1 -v ./internal/sqlschema
# 2201.14.2 bundles a ballerina/workflow 1.0.4 BIR it cannot load; return to latest once that is fixed.
- name: Set up Ballerina (2201.14.1)
uses: ballerina-platform/setup-ballerina@585120e3f0e540bf127376ee6e75d39e8ce6aaa4 # v1.1.5
Expand Down Expand Up @@ -111,6 +116,14 @@ jobs:
run: >-
go run ./tools/cmd/balsuite ${{ matrix.suite }} --database ${{ matrix.database }}
--engine build/workflow-engine
# A workflow started on the previous Temporal release, with its older schema, finishes on this engine.
- name: Upgrade from Temporal 1.30.9 on ${{ matrix.database }}
if: matrix.suite == 'smoke' && (matrix.database == 'postgresql' || matrix.database == 'mysql')
env:
ENGINE_LOG_DIR: build/logs
run: >-
go run ./tools/cmd/balsuite upgrade --database ${{ matrix.database }}
--engine build/workflow-engine --old-temporal 1.30.9
- name: Upload engine and test logs
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand All @@ -119,4 +132,5 @@ jobs:
path: |
build/logs/
tests/ballerina/${{ matrix.suite }}/target/report/
tests/ballerina/upgrade/target/report/
if-no-files-found: ignore
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,18 @@ jobs:
cache-dependency-path: engine/go.sum
- run: make engine GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }}

# The launcher starts the engine as a child process on Windows (exec elsewhere); run its process tests there.
windows-tests:
name: Launcher tests on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: engine/go.mod
cache-dependency-path: engine/go.sum
- name: Launcher tests
working-directory: engine
run: go test -count=1 -v ./internal/launcher/...
38 changes: 38 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,41 @@ jobs:
with:
version: ${{ needs.version.outputs.version }}
ref: ${{ needs.version.outputs.ref }}

# Test images go to GitHub's registry; releases go to WSO2's (release.yml).
image:
name: Publish a test image
needs: [version, build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
IMAGE: ghcr.io/${{ github.repository }}
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.version.outputs.ref }}
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: wso2-workflow-runtime-linux-*
path: dist
merge-multiple: true
- name: Unpack the linux distributions
run: cd dist && for z in *-linux-*.zip; do unzip -q "$z"; done
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
env:
REF: ${{ needs.version.outputs.ref }}
run: |
tags="--tag $IMAGE:$VERSION"
if [[ "$REF" == "refs/heads/main" || "$REF" == "main" ]]; then tags="$tags --tag $IMAGE:nightly"; fi
docker buildx build --platform linux/amd64,linux/arm64 --build-arg VERSION="$VERSION" \
-f distribution/docker/Dockerfile $tags --push .
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,45 @@ jobs:
dist/*.sigstore.json
generate_release_notes: true
prerelease: ${{ needs.version.outputs.is_prerelease }}

# Off until the repository variable WORKFLOW_RUNTIME_IMAGE names the image in WSO2's registry (for example
# docker.wso2.com/wso2-workflow-runtime) and the secrets IMAGE_REGISTRY_USERNAME and IMAGE_REGISTRY_PASSWORD exist.
image:
name: Publish the container image
needs: [version, build]
if: vars.WORKFLOW_RUNTIME_IMAGE != ''
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # keyless signing with Sigstore
env:
IMAGE: ${{ vars.WORKFLOW_RUNTIME_IMAGE }}
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: wso2-workflow-runtime-linux-*
path: dist
merge-multiple: true
- name: Unpack the linux distributions
run: cd dist && for z in *-linux-*.zip; do unzip -q "$z"; done
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to the registry
env:
REGISTRY_USERNAME: ${{ secrets.IMAGE_REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.IMAGE_REGISTRY_PASSWORD }}
run: echo "$REGISTRY_PASSWORD" | docker login "${IMAGE%%/*}" --username "$REGISTRY_USERNAME" --password-stdin
- name: Build and push
id: push
run: |
tags="--tag $IMAGE:$VERSION"
if [[ "${{ needs.version.outputs.is_prerelease }}" == "false" ]]; then tags="$tags --tag $IMAGE:latest"; fi
docker buildx build --platform linux/amd64,linux/arm64 --build-arg VERSION="$VERSION" \
-f distribution/docker/Dockerfile $tags --push --metadata-file metadata.json .
echo "digest=$(jq -r '."containerimage.digest"' metadata.json)" >> "$GITHUB_OUTPUT"
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Sign the image
run: cosign sign --yes "$IMAGE@${{ steps.push.outputs.digest }}"
37 changes: 37 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,49 @@ version: "2"
linters:
default: standard
enable:
- depguard
- gosec
- misspell
- unparam
- usetesting
- wastedassign
settings:
depguard:
rules:
# Our own SQL lives in internal/sqlschema; see AGENTS.md. Registering Temporal's plugins stays allowed.
sql-boundary:
files:
- $all
- "!$test"
- "!**/internal/sqlschema/*.go"
- "!**/cmd/workflow-engine-sql/*.go"
deny:
- pkg: database/sql
desc: run SQL from internal/sqlschema
- pkg: github.com/jmoiron/sqlx
desc: run SQL from internal/sqlschema
- pkg: github.com/lib/pq
desc: run SQL from internal/sqlschema
- pkg: github.com/jackc/pgx
desc: run SQL from internal/sqlschema
- pkg: github.com/go-sql-driver/mysql
desc: run SQL from internal/sqlschema
- pkg: modernc.org/sqlite
desc: run SQL from internal/sqlschema
- pkg: go.temporal.io/server/tools/sql
desc: run SQL from internal/sqlschema
- pkg: go.temporal.io/server/tools/common/schema
desc: manage Temporal's schema from internal/sqlschema
- pkg: go.temporal.io/server/common/persistence/sql$
desc: run SQL from internal/sqlschema
- pkg: go.temporal.io/server/common/persistence/sql/sqlplugin$
desc: run SQL from internal/sqlschema
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
- pkg: go.temporal.io/server/common/persistence/sql/sqlplugin/mysql/session
desc: run SQL from internal/sqlschema
- pkg: go.temporal.io/server/common/persistence/sql/sqlplugin/postgresql/session
desc: run SQL from internal/sqlschema
- pkg: go.temporal.io/server/common/persistence/sql/sqlplugin/postgresql/driver
desc: run SQL from internal/sqlschema
usetesting:
os-temp-dir: true
staticcheck:
Expand Down
18 changes: 13 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Read [docs/guides/ARCHITECTURE.md](docs/guides/ARCHITECTURE.md) before changing
|---|---|---|
| Engine | `engine/` | Our Go binary that embeds Temporal's server (frontend, history, matching, worker) as a library, pinned in `engine/go.mod` |
| Engine endpoint | `engine/` (planned) | The integrations' one port (7233): gRPC to Temporal's frontend, `/runtime/...` HTTPS to the Manager |
| Launcher | `launcher/` (planned) | Starts components per profile, writes Temporal's configuration from `conf/runtime.toml`, enforces one-minor upgrades |
| Launcher | `engine/internal/launcher` | `bin/workflow-runtime`, the command customers run: finds the runtime home, works from there and hands the command to `workflow-engine` (`dev` for development mode). It does not supervise or restart |
| Manager | `manager/` (planned) | Go service: engine administration, Workflow Management API, SSO sign-in, roles; serves both portals |
| Portals | `portals/` (planned) | Admin Portal and User Portal, static TypeScript apps served by the Manager |
| Distribution | `distribution/` | Zip and Docker layout, `conf/runtime.toml` |
Expand All @@ -38,6 +38,7 @@ Decision records live in `docs/decisions/`; feature documentation in `docs/featu
| `make test-docker` | The CI gates and both suites in Docker, PostgreSQL and MySQL included (`DOCKER_TARGET`, `DATABASES`) |
| `make license-check` / `make vulncheck` | License gate and `govulncheck`, which fails on any called vulnerability not listed with its reason in `third-party/vulnerability-exceptions.txt` |
| `make sbom` | CycloneDX SBOM per binary in `build/sbom/` (included by `make dist`) |
| `make dist` / `make image` | A distribution zip for `GOOS`/`GOARCH`; the container image from the linux zips (`IMAGE_PLATFORMS`, `IMAGE_ARGS=--load` or `--push`) |
| `make check` | Every gate CI runs, except the Ballerina suites |
| `make dist` | Zip for one `GOOS`/`GOARCH` in `dist/` |
| `make install-hooks` | Install the commit hook (subject format, license headers, gofmt, build, lint) |
Expand Down Expand Up @@ -100,6 +101,10 @@ These are requirements, not suggestions. A change that misses one is not done.
`go run ./tools/cmd/<tool>`); no Python or JavaScript scripts. A shell script with logic gets its tests in
`tools/internal/scripts/`, which runs the script for real.
- Binary and product names never use "Temporal" (`workflow-engine`, not `temporal-server`).
- SQL stays in `engine/internal/sqlschema`: it alone opens database connections and runs statements, to create the
databases and manage Temporal's schema. Everything else delegates: Temporal's persistence plugins (the blank
`sqlplugin/...` imports), the DBA tool `cmd/workflow-engine-sql`, and test fixtures. The `depguard` rule in
`.golangci.yml` enforces this; widen it only with a reason in the PR.

## Tests

Expand All @@ -111,10 +116,13 @@ These are requirements, not suggestions. A change that misses one is not done.

### Ballerina suites

- `go run ./tools/cmd/balsuite <smoke|full> --engine build/workflow-engine [--database sqlite|postgresql|mysql]`
starts the engine from `tests/engine/runtime-<database>.toml` (ports 17xxx, `--allow-no-auth`), creating the SQL
schemas first for PostgreSQL and MySQL; then it creates the `default` namespace and the `WorkflowKind` search
attribute, runs `bal test` in the suite, and stops the engine.
- `go run ./tools/cmd/balsuite <smoke|full> --engine build/workflow-engine [--database sqlite|postgresql|mysql|dev]`
starts the engine from `tests/engine/runtime-<database>.toml` (ports 17xxx, `--allow-no-auth`); on PostgreSQL and
MySQL the engine creates both databases and their schemas on start. The runner then creates the `default` namespace
and the `WorkflowKind` search attribute; with `--database dev` it runs `start-dev --port 17233` instead and creates nothing, since development
mode does that itself. It then runs `bal test` in the suite and stops the engine.
- `balsuite upgrade --database postgresql|mysql` runs `tests/ballerina/upgrade` across an upgrade: its `before` group
on Temporal 1.30.9 in Docker, its `after` group on the engine started on the same databases.
- Each suite is a Ballerina package: workflows and activities in `workflows.bal`, tests in `tests/*_test.bal`
(one file per feature area), connection settings in `tests/Config.toml`.
- Tests use the public `ballerina/workflow` API only (`workflow:run`, `workflow:sendData`,
Expand Down
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ EXE := $(if $(filter windows,$(GOOS)),.exe,)
OUT := build
DIST_NAME := wso2-workflow-runtime-$(VERSION)-$(GOOS)-$(GOARCH)
MIN_COVERAGE ?= 75
BINARIES := workflow-engine workflow-engine-sql
BINARIES := workflow-runtime workflow-engine workflow-engine-sql
# Container image: name, platforms, and extra buildx arguments (--push to publish, --load for a local single platform).
IMAGE ?= wso2-workflow-runtime
IMAGE_PLATFORMS ?= linux/amd64,linux/arm64
IMAGE_ARGS ?=
comma := ,
# The platforms build-dist.yml releases; keep the two lists in step.
RELEASE_PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64

Expand Down Expand Up @@ -55,7 +60,7 @@ GOOS= GOARCH= GOBIN="$$tmp" go install "$(2)@$(3)"; mv -f "$$tmp/$$(basename "$$
ln -s "$(notdir $(1))" "$$tmp/link"; mv -f "$$tmp/link" "$$link"
endef

.PHONY: build engine dist sbom tools vet lint fmt-check test test-coverage test-race licenses license-check \
.PHONY: build engine dist image sbom tools vet lint fmt-check test test-coverage test-race licenses license-check \
vulncheck check test-smoke test-full test-docker install-hooks release clean

build: engine
Expand All @@ -65,16 +70,28 @@ engine:
-ldflags "-s -w -X main.version=$(VERSION)" -o ../$(OUT)/workflow-engine$(EXE) ./cmd/workflow-engine
cd engine && CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath \
-ldflags "-s -w" -o ../$(OUT)/workflow-engine-sql$(EXE) ./cmd/workflow-engine-sql
cd engine && CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath \
-ldflags "-s -w -X main.version=$(VERSION)" -o ../$(OUT)/workflow-runtime$(EXE) ./cmd/workflow-runtime

# One distribution directory and zip for GOOS/GOARCH: the layout every release archive uses.
dist: engine sbom
rm -rf dist/$(DIST_NAME) && mkdir -p dist/$(DIST_NAME)/bin dist/$(DIST_NAME)/conf
cp $(OUT)/workflow-engine$(EXE) $(OUT)/workflow-engine-sql$(EXE) dist/$(DIST_NAME)/bin/
cp $(OUT)/workflow-runtime$(EXE) $(OUT)/workflow-engine$(EXE) $(OUT)/workflow-engine-sql$(EXE) dist/$(DIST_NAME)/bin/
cp distribution/conf/runtime.toml dist/$(DIST_NAME)/conf/
$(if $(filter linux,$(GOOS)),cp -R distribution/systemd dist/$(DIST_NAME)/,)
cp distribution/README.dist.md dist/$(DIST_NAME)/README.md
cp -R LICENSE NOTICE third-party dist/$(DIST_NAME)/
cp -R $(OUT)/sbom dist/$(DIST_NAME)/
cd dist && rm -f $(DIST_NAME).zip && zip -qr $(DIST_NAME).zip $(DIST_NAME)

# The image from the linux distributions of IMAGE_PLATFORMS; `make image IMAGE_PLATFORMS=linux/arm64 IMAGE_ARGS=--load`
# loads one platform into the local Docker. The release workflows run the same Dockerfile on the zips they built.
image:
@for p in $(subst $(comma), ,$(IMAGE_PLATFORMS)); do \
$(MAKE) dist GOOS=$${p%/*} GOARCH=$${p#*/} VERSION=$(VERSION) || exit 1; done
docker buildx build --platform $(IMAGE_PLATFORMS) --build-arg VERSION=$(VERSION) \
-f distribution/docker/Dockerfile -t $(IMAGE):$(VERSION) $(IMAGE_ARGS) .

# CycloneDX SBOM per binary for GOOS/GOARCH: the modules and standard library linked in, with their licenses.
sbom: $(CYCLONEDX_GOMOD)
@mkdir -p $(OUT)/sbom
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ The runtime is the engine that runs WSO2 Integrator's durable workflows. It is b
server, which runs inside it as an internal component: customers provide a database and an identity provider,
and never install or patch Temporal themselves.

Status: early development. The engine builds and runs; the launcher, Manager and portals are being built.
Status: early development. The engine, its security, schema management, development mode and packaging work; the
Manager (API server) and portals are being built.

## Layout

| Path | Component | Language |
|---|---|---|
| `engine/` | Temporal's services in our own binary (`workflow-engine`) and the schema tool (`workflow-engine-sql`) | Go |
| `launcher/` | Starts and supervises components per profile; writes Temporal's configuration from `runtime.toml`; enforces one-minor upgrades | Go |
| `engine/internal/launcher` | `workflow-runtime`: finds the runtime home and hands the command to `workflow-engine`, or starts development mode (notes in `launcher/`) | Go |
| `manager/` | The Manager: administration API, SSO sign-in, roles; serves the portals | Go |
| `portals/` | Admin Portal and User Portal, static web apps served by the Manager | TypeScript |
| `distribution/` | Zip and Docker assembly, configuration templates, start scripts | Shell, Docker |
| `distribution/` | Zip and Docker assembly, configuration templates, the systemd example | Docker |
| `tests/` | Ballerina smoke and full suites run against the engine binary | Ballerina |
| `tools/` | The repository's own tools: coverage gate, Ballerina suite runner, script tests | Go |
| `third-party/` | License inventory and notices for everything we ship | |
Expand All @@ -26,7 +27,11 @@ Status: early development. The engine builds and runs; the launcher, Manager and
Documentation: [architecture](docs/guides/ARCHITECTURE.md), [developing](docs/guides/DEVELOPING.md),
[testing](docs/guides/TESTING.md), [features](docs/features/README.md), [decisions](docs/decisions/).

Installing and running the runtime: the [user guide](docs/user-guide/README.md).
Installing and running the runtime: the [user guide](docs/user-guide/README.md). On PostgreSQL and MySQL the engine
creates and upgrades its databases on start, which needs the right to create databases and change their schema;
`[database] manageSchema = false` leaves that to a DBA. For a local engine with nothing to
configure, run `bin/workflow-runtime dev` from a distribution, or `build/workflow-engine start-dev` after `make build`
(see [DEVELOPING.md](docs/guides/DEVELOPING.md)).
Contributors and coding agents: read [AGENTS.md](AGENTS.md) first.

## Build
Expand Down
Loading
Loading