Skip to content
Open

ci #2

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
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
39 changes: 39 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/bin/Debug/net6.0/NorthwindStore.Tests.UnitTests.dll",
"args": [],
"cwd": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
},
{
"name": "Docker .NET Launch",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: debug",
"netCore": {
"appProject": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj"
}
},
{
"name": "Docker .NET Launch release",
"type": "docker",
"request": "launch",
"preLaunchTask": "docker-run: release",
"netCore": {
"appProject": "${workspaceFolder}/NorthwindStore.App/NorthwindStore.App.csproj"
}
}
]
}
112 changes: 112 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/NorthwindStore.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/NorthwindStore.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/src/NorthwindStore.sln"
],
"problemMatcher": "$msCompile"
},
{
"type": "docker-build",
"label": "docker-build: debug",
"dependsOn": [
"build"
],
"dockerBuild": {
"tag": "robotdreamskubernetesprivatevt:dev",
"target": "base",
"dockerfile": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/Dockerfile",
"context": "${workspaceFolder}",
"pull": true
},
"netCore": {
"appProject": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj"
}
},
{
"type": "docker-build",
"label": "docker-build: release",
"dependsOn": [
"build"
],
"dockerBuild": {
"tag": "robotdreamskubernetesprivatevt:latest",
"dockerfile": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/Dockerfile",
"context": "${workspaceFolder}",
"platform": {
"os": "linux",
"architecture": "amd64"
},
"pull": true
},
"netCore": {
"appProject": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj"
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build: debug"
],
"dockerRun": {
"env": {
"ConnectionStrings__DB": "Data Source=tcp:northwind-db,1433; Initial Catalog=Northwind; User ID=sa; Password=DevPass_1"
},
"network": "northwind-network"
},
"netCore": {
"appProject": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj",
"enableDebugging": true,
"configureSsl": false
}
},
{
"type": "docker-run",
"label": "docker-run: release",
"dependsOn": [
"docker-build: release"
],
"dockerRun": {
"env": {
"ConnectionStrings__DB": "Data Source=tcp:northwind-db,1433; Initial Catalog=Northwind; User ID=sa; Password=DevPass_1"
},
"network": "northwind-network"
},
"netCore": {
"appProject": "${workspaceFolder}/src/NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj"
}
}
]
}
19 changes: 19 additions & 0 deletions ci/docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3.4'

services:
northwindstore.app:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80
- ConnectionStrings__DB=Data Source=tcp:northwindstore.db,1433; Initial Catalog=Northwind; User ID=sa; Password=DevPass_1
ports:
- "80"
networks:
- northwindstore-dev
northwindstore.db:
networks:
- northwindstore-dev

networks:
northwindstore-dev:
name: northwindstore-dev
48 changes: 48 additions & 0 deletions ci/pipelines/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
- main

pool:
vmImage: ubuntu-latest

steps:
- task: DockerCompose@1
inputs:
containerregistrytype: "Azure Container Registry"
dockerComposeFile: src/docker-compose.yml
additionalDockerComposeFiles: ../ci/docker-compose.ci.yml
projectName: "northwindstore"
action: "Run a Docker Compose command"
dockerComposeCommand: "up"
arguments: --build --force-recreate -d
- task: Docker@2
displayName: Build Unit tests
inputs:
repository: 'northwindstoretestsunittests'
command: 'build'
Dockerfile: 'src/NorthwindStore.Tests.UnitTests/Dockerfile'
buildContext: 'src'
- task: Docker@2
displayName: Run Unit tests
inputs:
command: 'run'
arguments: '--rm northwindstoretestsunittests:$(Build.BuildId)'
- task: Docker@2
displayName: Build Integration tests
inputs:
repository: 'northwindstoretestsintegrationtest'
command: 'build'
Dockerfile: 'src/NorthwindStore.Tests.IntegrationTests/Dockerfile'
buildContext: 'src'
- task: Docker@2
displayName: Run Integration tests
inputs:
command: 'run'
arguments: '--rm -e "ConnectionStrings__DB=Data Source=tcp:northwindstore.db,1433; Initial Catalog=Northwind; User ID=sa; Password=DevPass_1" --network northwindstore-dev northwindstoretestsintegrationtests'



17 changes: 16 additions & 1 deletion src/NorthwindStore.Tests.IntegrationTests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
main
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
=======
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
main

WORKDIR /src
COPY ["packages/", "packages/"]
COPY ["nuget.config", "."]
COPY ["NorthwindStore.Tests.IntegrationTests/NorthwindStore.Tests.IntegrationTests.csproj", "NorthwindStore.Tests.IntegrationTests/"]
main
COPY ["NorthwindStore.DAL/NorthwindStore.DAL.csproj", "NorthwindStore.DAL/"]
COPY ["NorthwindStore.BL/NorthwindStore.BL.csproj", "NorthwindStore.BL/"]
RUN dotnet restore "NorthwindStore.Tests.IntegrationTests/NorthwindStore.Tests.IntegrationTests.csproj"
COPY . .
WORKDIR "/src/NorthwindStore.Tests.IntegrationTests"
RUN dotnet build "NorthwindStore.Tests.IntegrationTests.csproj"

ENTRYPOINT ["dotnet", "test", "NorthwindStore.Tests.IntegrationTests.csproj"]
=======
COPY ["NorthwindStore.App/NorthwindStore.App.csproj", "NorthwindStore.App/"]
COPY ["NorthwindStore.BL/NorthwindStore.BL.csproj", "NorthwindStore.BL/"]
COPY ["NorthwindStore.DAL/NorthwindStore.DAL.csproj", "NorthwindStore.DAL/"]
Expand All @@ -15,4 +29,5 @@ COPY . .
WORKDIR "/src/NorthwindStore.Tests.IntegrationTests"
RUN dotnet build "./NorthwindStore.Tests.IntegrationTests.csproj"

ENTRYPOINT ["dotnet", "test", "NorthwindStore.Tests.IntegrationTests.csproj"]
ENTRYPOINT ["dotnet", "test", "NorthwindStore.Tests.IntegrationTests.csproj"]
main
18 changes: 17 additions & 1 deletion src/NorthwindStore.Tests.UnitTests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
main
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG configuration=Release
=======
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
main
WORKDIR /src
COPY ["packages/", "packages/"]
COPY ["nuget.config", "."]
COPY ["NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj", "NorthwindStore.Tests.UnitTests/"]
main
COPY ["NorthwindStore.DAL/NorthwindStore.DAL.csproj", "NorthwindStore.DAL/"]
COPY ["NorthwindStore.BL/NorthwindStore.BL.csproj", "NorthwindStore.BL/"]
RUN dotnet restore "NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj"
COPY . .
WORKDIR "/src/NorthwindStore.Tests.UnitTests"
RUN dotnet build "NorthwindStore.Tests.UnitTests.csproj"

ENTRYPOINT ["dotnet", "test", "NorthwindStore.Tests.UnitTests.csproj"]
=======
COPY ["NorthwindStore.BL/NorthwindStore.BL.csproj", "NorthwindStore.BL/"]
COPY ["NorthwindStore.DAL/NorthwindStore.DAL.csproj", "NorthwindStore.DAL/"]
RUN dotnet restore "./NorthwindStore.Tests.UnitTests/NorthwindStore.Tests.UnitTests.csproj"
Expand All @@ -14,4 +29,5 @@ WORKDIR "/src/NorthwindStore.Tests.UnitTests"

RUN dotnet build "./NorthwindStore.Tests.UnitTests.csproj"

ENTRYPOINT ["dotnet", "test", "NorthwindStore.Tests.UnitTests.csproj"]
ENTRYPOINT ["dotnet", "test", "NorthwindStore.Tests.UnitTests.csproj"]
main