-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add test function to DotnetSdk module (#25)
* ci: add test function to DotnetSdk module Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * ci: enable test output Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * ci: introduce dev module Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * docs: add README.md Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * ci: add github workflow Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * chore: remove unneccesery files Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * Apply suggestions from code review * ci: wrap dotnet test with sh Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * ci: try another attempts Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * ci: try remove blame hang Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> * ci: rename workflow name Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com> --------- Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com>
- Loading branch information
Showing
12 changed files
with
166 additions
and
37 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,16 @@ | ||
name: dotnet sdk | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Test | ||
uses: dagger/dagger-for-github@v5 | ||
with: | ||
verb: call | ||
module: ./dev | ||
args: test --source=. | ||
cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }} |
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,23 @@ | ||
# Dagger SDK for DotNet | ||
|
||
This is the place for DotNet Dagger SDK. | ||
|
||
## Development | ||
|
||
This project provides `dev` module to uses for developing the SDK. | ||
|
||
### Introspection | ||
|
||
Uses for fetching introspection by using the command: | ||
|
||
``` | ||
$ dagger -m dev introspect export --path=./sdk/Dagger.SDK/introspection.json | ||
``` | ||
|
||
### Test | ||
|
||
You can running all tests by: | ||
|
||
``` | ||
$ dagger -m dev test --source=. | ||
``` |
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 |
---|---|---|
@@ -1,12 +1,7 @@ | ||
{ | ||
"name": "dotnet-sdk", | ||
"sdk": "go", | ||
"dependencies": [ | ||
{ | ||
"name": "docker", | ||
"source": "github.com/shykes/daggerverse/docker@c9a80c9eac0675a53a7e052da3594207f4235988" | ||
} | ||
], | ||
"dependencies": [], | ||
"source": ".", | ||
"engineVersion": "v0.11.6" | ||
} |
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,4 @@ | ||
/dagger.gen.go linguist-generated | ||
/internal/dagger/** linguist-generated | ||
/internal/querybuilder/** linguist-generated | ||
/internal/telemetry/** linguist-generated |
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,4 @@ | ||
/dagger.gen.go | ||
/internal/dagger | ||
/internal/querybuilder | ||
/internal/telemetry |
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,4 @@ | ||
# Dev module for DotNet SDK | ||
|
||
A temporary module for developing DotNet SDK. In the future, this module will be | ||
written by DotNet SDK itself. |
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,12 @@ | ||
// Functions for managing Dagger. | ||
package main | ||
|
||
const daggerVersion = "0.11.9" | ||
|
||
func installDaggerCli(ctr *Container) *Container { | ||
return ctr. | ||
WithEnvVariable("BIN_DIR", "/usr/local/bin"). | ||
WithEnvVariable("DAGGER_VERSION", daggerVersion). | ||
WithExec([]string{"apk", "add", "--no-cache", "curl"}). | ||
WithExec([]string{"sh", "-c", "curl -L https://dl.dagger.io/dagger/install.sh | sh"}) | ||
} |
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,6 @@ | ||
{ | ||
"name": "dev", | ||
"sdk": "go", | ||
"source": ".", | ||
"engineVersion": "dev-a89a76d23b5dd8e8efeda2d0f313631ffb656402" | ||
} |
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,41 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
const dockerEngineVersion = "27" | ||
|
||
func dockerEngine() *Service { | ||
// Copied some if it from https://github.com/shykes/daggerverse/blob/main/docker/main.go. | ||
return dag.Container(). | ||
From(fmt.Sprintf("docker:%s-dind", dockerEngineVersion)). | ||
WithoutEntrypoint(). | ||
WithExec([]string{ | ||
"dockerd", | ||
"--host=tcp://0.0.0.0:2375", | ||
"--host=unix:///var/run/docker.sock", | ||
"--tls=false", | ||
}, ContainerWithExecOpts{ | ||
InsecureRootCapabilities: true, | ||
ExperimentalPrivilegedNesting: true, | ||
}). | ||
WithExposedPort(2375). | ||
AsService() | ||
} | ||
|
||
func dockerCli() *Container { | ||
return dag.Container(). | ||
From(fmt.Sprintf("docker:%s-cli", dockerEngineVersion)) | ||
|
||
} | ||
|
||
func installDockerCli(ctr *Container) *Container { | ||
return ctr.WithFile( | ||
"/usr/local/bin/docker", | ||
dockerCli().File("/usr/local/bin/docker"), | ||
) | ||
} | ||
|
||
func dockerd(ctr *Container) *Container { | ||
return ctr.WithServiceBinding("dockerd", dockerEngine()). | ||
WithEnvVariable("DOCKER_HOST", "tcp://dockerd:2375") | ||
} |
File renamed without changes.
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,54 @@ | ||
// A dev module for dagger-dotnet-sdk. | ||
// | ||
// This module contains functions for developing the SDK such as, running tests, | ||
// generate introspection, etc. | ||
package main | ||
|
||
import ( | ||
"context" | ||
_ "embed" | ||
) | ||
|
||
//go:embed introspection.graphql | ||
var introspectionGraphql string | ||
|
||
const introspectionJsonPath = "/introspection.json" | ||
|
||
type Dev struct { | ||
} | ||
|
||
// Fetch introspection json from the Engine. | ||
// | ||
// This function forked from https://github.com/helderco/daggerverse/blob/main/codegen/main.go but | ||
// didn't modify anything in the data. | ||
// | ||
// It's uses for test for the codegen only. | ||
func (m *Dev) Introspect() *File { | ||
return dag.Container(). | ||
From("alpine:3.20"). | ||
With(installDaggerCli). | ||
WithNewFile("/introspection.graphql", ContainerWithNewFileOpts{Contents: introspectionGraphql}). | ||
WithExec([]string{"sh", "-c", "dagger query < /introspection.graphql > " + introspectionJsonPath}, ContainerWithExecOpts{ | ||
ExperimentalPrivilegedNesting: true, | ||
}). | ||
File(introspectionJsonPath) | ||
} | ||
|
||
func (m *Dev) Test( | ||
ctx context.Context, | ||
// SDK Source directory. | ||
source *Directory, | ||
) error { | ||
_, err := dag.Container(). | ||
From("mcr.microsoft.com/dotnet/sdk:8.0-alpine3.20"). | ||
WithMountedDirectory("/src", source). | ||
WithWorkdir("/src/sdk"). | ||
WithFile("Dagger.SDK/introspection.json", m.Introspect()). | ||
WithExec([]string{"dotnet", "restore"}). | ||
WithExec([]string{"dotnet", "build", "--no-restore"}). | ||
WithExec([]string{"dotnet", "test", "--no-build"}, ContainerWithExecOpts{ | ||
ExperimentalPrivilegedNesting: true, | ||
}). | ||
Sync(ctx) | ||
return err | ||
} |
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 |
---|---|---|
@@ -1,35 +1,5 @@ | ||
// The DotNet SDK and runtime. | ||
package main | ||
|
||
import ( | ||
_ "embed" | ||
) | ||
|
||
//go:embed introspection.graphql | ||
var introspectionGraphql string | ||
|
||
const introspectionJsonPath = "/introspection.json" | ||
|
||
type DotnetSdk struct{} | ||
|
||
// Fetch introspection json from the Engine. | ||
// | ||
// This function forked from https://github.com/helderco/daggerverse/blob/main/codegen/main.go but | ||
// didn't modify anything in the data. | ||
// | ||
// It's uses for test for the codegen only. | ||
func (m *DotnetSdk) Introspect() *File { | ||
return dag.Docker(). | ||
Cli(DockerCliOpts{ | ||
Version: "26", | ||
Engine: dag.Docker().Engine(DockerEngineOpts{Version: "26"}), | ||
}). | ||
Container(). | ||
WithExec([]string{"apk", "add", "--no-cache", "curl"}). | ||
WithExec([]string{"sh", "-c", "curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=/usr/local/bin sh"}). | ||
WithNewFile("/introspection.graphql", ContainerWithNewFileOpts{Contents: introspectionGraphql}). | ||
WithExec([]string{"sh", "-c", "dagger query < /introspection.graphql > " + introspectionJsonPath}, ContainerWithExecOpts{ | ||
ExperimentalPrivilegedNesting: true, | ||
}). | ||
File(introspectionJsonPath) | ||
type DotnetSdk struct { | ||
} |