Skip to content

Commit

Permalink
Adding CsvSerializer. More comments and general refactoring. (#16)
Browse files Browse the repository at this point in the history
* Update packages. Added missing infra files.

* Adding Azure Pipeline.

* Adding CsvSerializer. Adding comments.

* Fix the pipeline.

* Fix the pipeline.
  • Loading branch information
offbeatful committed Jun 6, 2020
1 parent b64c08a commit 9bb0e38
Show file tree
Hide file tree
Showing 40 changed files with 796 additions and 354 deletions.
183 changes: 183 additions & 0 deletions .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

# name: $(majorVersion).$(minorVersion).$(patchVersion)$(channelVersion)$(buildVersion)$(Rev:.r)

trigger:
branches:
include:
- master
tags:
include:
- v*

pool:
vmImage: "ubuntu-18.04"

variables:
buildConfiguration: "Release"
projectName: "Mocoding.EasyDocDb"
solutionFile: "easy-doc-db.sln"
easyDocDb: $(projectName)
easyDocDbAzureStorage: $(projectName).AzureStorage
easyDocDbFileSystem: $(projectName).FileSystem
easyDocDbJson: $(projectName).Json
easyDocDbXml: $(projectName).Xml
easyDocDbYaml: $(projectName).Yaml
easyDocDbCsv: $(projectName).Csv


stages:
- stage: Build
pool:
vmImage: "ubuntu-18.04"
jobs:
- job: Package
steps:
- task: UseGitVersion@5
displayName: "Git Version"
inputs:
versionSpec: "5.0.0"
useConfigFile: true
configFilePath: "GitVersion.yml"

- task: UseDotNet@2
displayName: 'Install .NET Core sdk'
inputs:
packageType: sdk
version: 2.0.0
installationPath: $(Agent.ToolsDirectory)/dotnet

- task: UseDotNet@2
displayName: 'Install .NET Core sdk'
inputs:
packageType: sdk
version: 3.1.300
installationPath: $(Agent.ToolsDirectory)/dotnet

- task: DotNetCoreCLI@2
displayName: "dotnet restore"
inputs:
command: restore
projects: $(solutionFile)

- task: SonarCloudPrepare@1
displayName: "Sonarcloud - Prepare"
inputs:
SonarCloud: 'sonarcloud'
organization: 'mocoding'
scannerMode: 'MSBuild'
projectKey: 'mocoding-software_easy-doc-db'
extraProperties: 'sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/coverage.opencover.xml'

- task: DotNetCoreCLI@2
displayName: "dotnet build"
inputs:
command: build
projects: $(solutionFile)

- task: DotNetCoreCLI@2
displayName: "dotnet test"
inputs:
command: test
projects: 'test/**/*.Tests.csproj'
arguments: "--no-build /p:SkipCodeCoverageReport=true /p:Threshold=80 /p:CoverletOutput=$(Agent.TempDirectory)/"

- task: SonarCloudAnalyze@1
displayName: "Sonarcloud Analyze"

- task: SonarCloudPublish@1
displayName: "Sonarcloud Publish"
inputs:
pollingTimeoutSec: '300'

- task: PublishCodeCoverageResults@1
displayName: "Public Code Coverage"
inputs:
codeCoverageTool: "Cobertura"
summaryFileLocation: "$(Agent.TempDirectory)/coverage.cobertura.xml"
condition: succeededOrFailed()

- template: pack-template.yml
parameters:
project: $(easyDocDb)

- template: pack-template.yml
parameters:
project: $(easyDocDbAzureStorage)

- template: pack-template.yml
parameters:
project: $(easyDocDbFileSystem)

- template: pack-template.yml
parameters:
project: $(easyDocDbJson)

- template: pack-template.yml
parameters:
project: $(easyDocDbXml)

- template: pack-template.yml
parameters:
project: $(easyDocDbYaml)

- template: pack-template.yml
parameters:
project: $(easyDocDbCsv)

- task: PublishBuildArtifacts@1
displayName: "Publish Artifact: nupkg"
inputs:
PathtoPublish: "$(Build.StagingDirectory)"
ArtifactName: nupkg
- stage: Deploy
dependsOn: Build
condition: and(succeeded(), contains(variables['Build.Reason'], 'PullRequest'))
pool:
vmImage: "ubuntu-18.04"
jobs:
- deployment: DevBuild
environment: "dev-builds"
strategy:
runOnce:
deploy:
steps:
- task: NuGetCommand@2
displayName: "Publish to nuget (dev-builds)"
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg;'
nuGetFeedType: 'internal'
publishVstsFeed: 'da7703d4-fb22-4933-b869-83f4264b7b84/e1336e71-3540-4a0c-830c-639112685b07'
allowPackageConflicts: true
- stage: Release
dependsOn: Build
condition: and(succeeded(), contains(variables['Build.SourceBranch'], 'tags/v'))
pool:
vmImage: "ubuntu-18.04"
jobs:
- deployment: Public
environment: "public"
strategy:
runOnce:
deploy:
steps:
- task: NuGetCommand@2
displayName: "Publish"
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg;'
nuGetFeedType: 'external'
publishFeedCredentials: 'public-nuget'
- task: GitHubRelease@1
displayName: 'Update GitHub release'
inputs:
gitHubConnection: 'mocoding-software'
repositoryName: 'mocoding-software/easy-doc-db'
action: edit
tag: 'v$(Build.BuildNumber)'
assets: '$(Pipeline.Workspace)/**/*.nupkg'
assetUploadMode: replace
13 changes: 13 additions & 0 deletions .azure-pipelines/pack-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
- name: project
type: string
default: ""
steps:
- task: DotNetCoreCLI@2
displayName: "dotnet pack ${{ parameters.project }}"
inputs:
command: pack
packagesToPack: "src/${{ parameters.project }}/${{ parameters.project }}.csproj"
configuration: $(buildConfiguration)
packDirectory: "$(Build.StagingDirectory)/${{ parameters.project }}"
buildProperties: "Version=$(Build.BuildNumber)"
50 changes: 50 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
{
"name": "Existing Docker Compose (Extend)",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"docker-compose.yml"
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "devbox",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspace",

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
// This will ignore your local shell user setting for Linux since shells like zsh are typically
// not in base container images. You can also update this to an specific shell to ensure VS Code
// uses the right one for terminals and tasks. For example, /bin/bash (or /bin/ash for Alpine).
"terminal.integrated.shell.linux": null
},

// Uncomment the next line to have VS Code connect as an existing non-root user in the container. See
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
// "remoteUser": "vscode",

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created - for example installing git.
"postCreateCommand": "apt-get update && apt-get install -y git",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"ms-vscode.csharp",
"fudge.auto-using",
"formulahendry.dotnet-test-explorer",
"tintoy.msbuild-project-tools",
"eamodio.gitlens",
"christian-kohler.path-intellisense"
]
}
43 changes: 43 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

version: '2.4'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
devbox:
image: mcr.microsoft.com/dotnet/core/sdk:3.1.300
# You may want to add a non-root user to your Dockerfile and uncomment the line below
# to cause all processes to run as this user. Once present, you can also simply
# use the "remoteUser" property in devcontainer.json if you just want VS Code and
# its sub-processes (terminals, tasks, debugging) to execute as the user. On Linux,
# you may need to ensure the UID and GID of the container user you create matches your
# local user. See https://aka.ms/vscode-remote/containers/non-root for details.
# user: vscode

# Uncomment if you want to add a different Dockerfile in the .devcontainer folder
# build:
# context: .
# dockerfile: Dockerfile

# Uncomment if you want to expose any additional ports. The snippet below exposes port 3000.
ports:
- 5000:5000

volumes:
# Update this to wherever you want VS Code to mount the folder of your project
- ..:/workspace

# Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker-compose for details.
# - /var/run/docker.sock:/var/run/docker.sock

# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
# cap_add:
# - SYS_PTRACE
# security_opt:
# - seccomp:unconfined

# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"

7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
bin
obj
.vs
test/Mocoding.EasyDocDb.Tests/test_data

node_modules
samples/Mocoding.EasyDocDb.CrudSample/wwwroot/lib
samples/Mocoding.EasyDocDb.AuthSample/wwwroot/lib
.codecov
coverage.*.xml
10 changes: 10 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<PropertyGroup>
<SkipCodeCoverageReport Condition="$(SkipCodeCoverageReport) == ''">false</SkipCodeCoverageReport>
<CoverletOutputFormat>cobertura,opencover</CoverletOutputFormat>
<CollectCoverage>true</CollectCoverage>
<ThresholdType>line</ThresholdType>
<ThresholdStat>total</ThresholdStat>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<PackageReference Include="ReportGenerator" Version="4.6.1" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<Target Name="GenerateCoverageReport" AfterTargets="GenerateCoverageResult" Condition="!$(SkipCodeCoverageReport)">
<ItemGroup>
<CoverageFiles Include="coverage.cobertura.xml" />
</ItemGroup>
<ReportGenerator ReportFiles="@(CoverageFiles)" TargetDirectory="../../.codecov" ReportTypes="Html" />
</Target>
</Project>
30 changes: 30 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
assembly-versioning-scheme: Major
mode: ContinuousDeployment
next-version: 2.3.0
increment: Patch
legacy-semver-padding: 1
build-metadata-padding: 1
commits-since-version-source-padding: 1
continuous-delivery-fallback-tag: 'ci'
branches:
master:
regex: master
mode: ContinuousDeployment
tag: ''
increment: inherit
prevent-increment-of-merged-branch-version: true
tag-number-pattern: '[/-](?<number>\d+)[-/]'
pull-request:
regex: (pull|pull\-requests|pr)[/-]
mode: ContinuousDeployment
tag: "dev"
increment: Patch
tag-number-pattern: '[/-](?<number>\d+)[-/]'
develop:
regex: (!master)?
mode: ContinuousDeployment
tag: useBranchName
increment: Patch
ignore:
sha: []
merge-message-formats: {}
File renamed without changes.
Loading

0 comments on commit 9bb0e38

Please sign in to comment.