-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #226
- Loading branch information
Showing
18 changed files
with
883 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[*.cs] | ||
|
||
##### Temporal additions ###### | ||
|
||
# Please keep in alphabetical order by field. | ||
|
||
# Some calls we mark async, like signals, that may not doing anything async | ||
dotnet_diagnostic.CS1998.severity = none | ||
|
||
############################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
name: .NET Features Testing | ||
on: | ||
workflow_call: | ||
inputs: | ||
dotnet-repo-path: | ||
type: string | ||
default: 'temporalio/sdk-dotnet' | ||
version: | ||
required: true | ||
type: string | ||
# When true, the version refers to a repo tag/ref. When false, NPM package version. | ||
version-is-repo-ref: | ||
required: true | ||
type: boolean | ||
features-repo-path: | ||
type: string | ||
default: 'temporalio/features' | ||
features-repo-ref: | ||
type: string | ||
default: 'main' | ||
# If set, download the docker image for server from the provided artifact name | ||
docker-image-artifact-name: | ||
type: string | ||
required: false | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./features | ||
steps: | ||
- name: Print git info | ||
run: 'echo head_ref: "$GITHUB_HEAD_REF", ref: "$GITHUB_REF", ts version: ${{ inputs.version }}' | ||
working-directory: '.' | ||
|
||
- name: Download docker artifacts | ||
if: ${{ inputs.docker-image-artifact-name }} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ inputs.docker-image-artifact-name }} | ||
path: /tmp/server-docker | ||
|
||
- name: Load server Docker image | ||
if: ${{ inputs.docker-image-artifact-name }} | ||
run: docker load --input /tmp/server-docker/temporal-autosetup.tar | ||
working-directory: '.' | ||
|
||
- name: Checkout SDK features repo | ||
uses: actions/checkout@v3 | ||
with: | ||
path: features | ||
repository: ${{ inputs.features-repo-path }} | ||
ref: ${{ inputs.features-repo-ref }} | ||
- name: Checkout .NET SDK repo | ||
if: ${{ inputs.version-is-repo-ref }} | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: ${{ inputs.dotnet-repo-path }} | ||
submodules: recursive | ||
path: sdk-dotnet | ||
ref: ${{ inputs.version }} | ||
|
||
- uses: actions/setup-dotnet@v3 | ||
|
||
- name: Install protoc | ||
if: ${{ inputs.version-is-repo-ref }} | ||
uses: arduino/setup-protoc@v1 | ||
with: | ||
version: '3.x' | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '^1.19' | ||
|
||
- uses: Swatinem/rust-cache@v1 | ||
if: ${{ inputs.version-is-repo-ref }} | ||
with: | ||
working-directory: sdk-dotnet/src/Temporalio/Bridge | ||
|
||
# Build .NET SDK if using repo | ||
# Don't build during install phase since we're going to explicitly build | ||
- run: dotnet build | ||
if: ${{ inputs.version-is-repo-ref }} | ||
working-directory: ./sdk-dotnet | ||
|
||
- name: Start containerized server and dependencies | ||
if: inputs.docker-image-artifact-name | ||
run: | | ||
docker-compose \ | ||
-f /tmp/server-docker/docker-compose.yml \ | ||
-f ./dockerfiles/docker-compose.for-server-image.yaml \ | ||
up -d temporal-server cassandra elasticsearch | ||
- name: Run SDK-features tests directly | ||
if: inputs.docker-image-artifact-name == '' | ||
run: go run . run --lang cs ${{ inputs.docker-image-artifact-name && '--server localhost:7233 --namespace default' || ''}} --version "${{ inputs.version-is-repo-ref && '$(realpath ../sdk-dotnet)' || inputs.version }}" | ||
|
||
# Running the tests in their own step keeps the logs readable | ||
- name: Run containerized SDK-features tests | ||
if: inputs.docker-image-artifact-name | ||
run: | | ||
docker-compose \ | ||
-f /tmp/server-docker/docker-compose.yml \ | ||
-f ./dockerfiles/docker-compose.for-server-image.yaml \ | ||
up --no-log-prefix --exit-code-from features-tests-cs features-tests-cs | ||
- name: Tear down docker compose | ||
if: inputs.docker-image-artifact-name && (success() || failure()) | ||
run: docker-compose -f /tmp/server-docker/docker-compose.yml -f ./dockerfiles/docker-compose.for-server-image.yaml down -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ pyrightconfig.json | |
|
||
# Build stuff | ||
bin | ||
obj | ||
|
||
# VS Code config | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/temporalio/features/harness/go/cmd" | ||
"github.com/temporalio/features/sdkbuild" | ||
) | ||
|
||
// BuildDotNetProgram prepares a .NET run without running it. The preparer | ||
// config directory if present is expected to be a subdirectory name just | ||
// beneath the root directory. | ||
func (p *Preparer) BuildDotNetProgram(ctx context.Context) (sdkbuild.Program, error) { | ||
p.log.Info("Building .NET project", "DirName", p.config.DirName) | ||
|
||
// Get version from dotnet.csproj if not present | ||
version := p.config.Version | ||
if version == "" { | ||
csprojBytes, err := os.ReadFile("dotnet.csproj") | ||
if err != nil { | ||
return nil, fmt.Errorf("failed reading dotnet.csproj: %w", err) | ||
} | ||
const prefix = `<PackageReference Include="Temporalio" Version="` | ||
csproj := string(csprojBytes) | ||
beginIndex := strings.Index(csproj, prefix) | ||
if beginIndex == -1 { | ||
return nil, fmt.Errorf("cannot find Temporal dependency in csproj") | ||
} | ||
beginIndex += len(prefix) | ||
length := strings.Index(csproj[beginIndex:], `"`) | ||
version = csproj[beginIndex : beginIndex+length] | ||
} | ||
|
||
prog, err := sdkbuild.BuildDotNetProgram(ctx, sdkbuild.BuildDotNetProgramOptions{ | ||
BaseDir: p.rootDir, | ||
DirName: p.config.DirName, | ||
Version: version, | ||
ProgramContents: `await Temporalio.Features.Harness.App.RunAsync(args);`, | ||
CsprojContents: `<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\dotnet.csproj" /> | ||
</ItemGroup> | ||
</Project>`, | ||
}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed preparing: %w", err) | ||
} | ||
return prog, nil | ||
} | ||
|
||
func (r *Runner) RunDotNetExternal(ctx context.Context, run *cmd.Run) error { | ||
// If program not built, build it | ||
if r.program == nil { | ||
var err error | ||
if r.program, err = NewPreparer(r.config.PrepareConfig).BuildDotNetProgram(ctx); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
args := []string{"--server", r.config.Server, "--namespace", r.config.Namespace} | ||
if r.config.ClientCertPath != "" { | ||
args = append(args, "--client-cert-path", r.config.ClientCertPath, "--client-key-path", r.config.ClientKeyPath) | ||
} | ||
args = append(args, run.ToArgs()...) | ||
cmd, err := r.program.NewCommand(ctx, args...) | ||
if err == nil { | ||
r.log.Debug("Running Go separately", "Args", cmd.Args) | ||
err = cmd.Run() | ||
} | ||
if err != nil { | ||
return fmt.Errorf("failed running: %w", err) | ||
} | ||
return nil | ||
} |
Oops, something went wrong.