-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
- Loading branch information
Showing
15 changed files
with
304 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/container.cue
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,31 @@ | ||
// .NET operation | ||
package dotnet | ||
|
||
import ( | ||
"dagger.io/dagger" | ||
"universe.dagger.io/docker" | ||
) | ||
|
||
// A standalone dotnet environment to run dotnet command | ||
#Container: { | ||
// Container app name | ||
name: *"dotnet_publisher" | string | ||
|
||
// Source code | ||
source: dagger.#FS | ||
|
||
// Use dotnet image | ||
_image: #Image | ||
|
||
_sourcePath: "/src" | ||
|
||
docker.#Run & { | ||
input: *_image.output | docker.#Image | ||
workdir: "/src" | ||
command: name: "dotnet" | ||
mounts: "source": { | ||
dest: _sourcePath | ||
contents: source | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/image.cue
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,20 @@ | ||
package dotnet | ||
|
||
import ( | ||
"universe.dagger.io/docker" | ||
) | ||
|
||
// .NET image default version | ||
_#DefaultVersion: "6.0" | ||
|
||
// Pull a dotnet base image | ||
#Image: { | ||
version: *_#DefaultVersion | string | ||
docker.#Build & { | ||
steps: [ | ||
docker.#Pull & { | ||
source: "mcr.microsoft.com/dotnet/sdk:\(version)-alpine" | ||
}, | ||
] | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/publish.cue
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,31 @@ | ||
package dotnet | ||
|
||
import ( | ||
"dagger.io/dagger" | ||
) | ||
|
||
// Publish a dotnet binary | ||
#Publish: { | ||
// Source code | ||
source: dagger.#FS | ||
|
||
// Target package to publish | ||
package: *"." | string | ||
|
||
env: [string]: string | ||
|
||
container: #Container & { | ||
"source": source | ||
command: { | ||
args: [package] | ||
flags: { | ||
publish: true | ||
"-o": "/output/" | ||
} | ||
} | ||
export: directories: "/output": _ | ||
} | ||
|
||
// Directory containing the output of the publish | ||
output: container.export.directories."/output" | ||
} |
14 changes: 14 additions & 0 deletions
14
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test.cue
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,14 @@ | ||
package dotnet | ||
|
||
// Test a dotnet package | ||
#Test: { | ||
// Package to test | ||
package: *"." | string | ||
|
||
#Container & { | ||
command: { | ||
args: [package] | ||
flags: test: true | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...gger.io/x/olli.janatuinen@gmail.com/dotnet/test/data/Greeting.Tests/Greeting.Tests.csproj
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,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Greeting\Greeting.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
14 changes: 14 additions & 0 deletions
14
....dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/data/Greeting.Tests/Greeting_Should.cs
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,14 @@ | ||
using System; | ||
using Xunit; | ||
|
||
public class Greeting_Should | ||
{ | ||
[Fact] | ||
public void Greeting_PrintName() | ||
{ | ||
var name = "Dagger Test"; | ||
var expect = "Hi Dagger Test!"; | ||
var value = Greeting.GetMessage(name); | ||
Assert.Equal(expect, value); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/data/Greeting/Greeting.cs
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 @@ | ||
public class Greeting | ||
{ | ||
public static string GetMessage(string name) { | ||
return String.Format("Hi {0}!", name); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/data/Greeting/Greeting.csproj
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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
13 changes: 13 additions & 0 deletions
13
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/data/hello/Program.cs
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,13 @@ | ||
using System; | ||
|
||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
var name = Environment.GetEnvironmentVariable("NAME"); | ||
if (String.IsNullOrEmpty(name)) { | ||
name = "John Doe"; | ||
} | ||
Console.Write(Greeting.GetMessage(name)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/data/hello/hello.csproj
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<SelfContained>true</SelfContained> | ||
<RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Greeting\Greeting.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
39 changes: 39 additions & 0 deletions
39
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/image.cue
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,39 @@ | ||
package dotnet | ||
|
||
import ( | ||
"dagger.io/dagger" | ||
"universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet" | ||
"universe.dagger.io/docker" | ||
) | ||
|
||
dagger.#Plan & { | ||
actions: test: { | ||
_source: dagger.#Scratch & {} | ||
|
||
simple: { | ||
_image: dotnet.#Image & {} | ||
|
||
verify: docker.#Run & { | ||
input: _image.output | ||
command: { | ||
name: "/bin/sh" | ||
args: ["-c", "dotnet --list-sdks | grep '6.0'"] | ||
} | ||
} | ||
} | ||
|
||
custom: { | ||
_image: dotnet.#Image & { | ||
version: "5.0" | ||
} | ||
|
||
verify: docker.#Run & { | ||
input: _image.output | ||
command: { | ||
name: "/bin/sh" | ||
args: ["-c", "dotnet --list-sdks | grep '5.0'"] | ||
} | ||
} | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/publish.cue
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,58 @@ | ||
package dotnet | ||
|
||
import ( | ||
"dagger.io/dagger" | ||
"dagger.io/dagger/core" | ||
"universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet" | ||
"universe.dagger.io/docker" | ||
"universe.dagger.io/alpine" | ||
) | ||
|
||
dagger.#Plan & { | ||
client: filesystem: "./data": read: contents: dagger.#FS | ||
|
||
actions: test: { | ||
_baseImage: { | ||
build: alpine.#Build & { | ||
packages: { | ||
"ca-certificates": {} | ||
"krb5-libs": {} | ||
libgcc: {} | ||
libintl: {} | ||
"libssl1.1": {} | ||
"libstdc++": {} | ||
zlib: {} | ||
} | ||
} | ||
output: build.output | ||
} | ||
|
||
simple: { | ||
publish: dotnet.#Publish & { | ||
source: client.filesystem."./data".read.contents | ||
package: "hello" | ||
} | ||
|
||
exec: docker.#Run & { | ||
input: _baseImage.output | ||
command: { | ||
name: "/bin/sh" | ||
args: ["-c", "/app/hello >> /output.txt"] | ||
} | ||
env: NAME: "dagger" | ||
mounts: binary: { | ||
dest: "/app" | ||
contents: publish.output | ||
source: "/" | ||
} | ||
} | ||
|
||
verify: core.#ReadFile & { | ||
input: exec.output.rootfs | ||
path: "/output.txt" | ||
} & { | ||
contents: "Hi dagger!" | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/test.bats
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,11 @@ | ||
setup() { | ||
load '../../../../bats_helpers' | ||
|
||
common_setup | ||
} | ||
|
||
@test "dotnet" { | ||
dagger "do" -p ./publish.cue test | ||
dagger "do" -p ./image.cue test | ||
dagger "do" -p ./test.cue test | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet/test/test.cue
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,15 @@ | ||
package dotnet | ||
|
||
import ( | ||
"dagger.io/dagger" | ||
"universe.dagger.io/x/olli.janatuinen@gmail.com/dotnet" | ||
) | ||
|
||
dagger.#Plan & { | ||
client: filesystem: "./data": read: contents: dagger.#FS | ||
|
||
actions: test: dotnet.#Test & { | ||
source: client.filesystem."./data".read.contents | ||
package: "./Greeting.Tests" | ||
} | ||
} |