Skip to content

Commit

Permalink
Added Unit Tests and CI pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
bellons91 authored Jan 16, 2024
1 parent e27f96e commit beb3da9
Show file tree
Hide file tree
Showing 15 changed files with 294 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/new-cli-command-request.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: New CLI command request
about: Suggest an idea for this project
title: 'New command: '
title: '[Command] '
labels: enhancement
assignees: bellons91

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/technical-improvement.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Technical improvement
about: Suggest an idea for this project
title: 'Improvement: '
title: '[TECH] '
labels: enhancement
assignees: bellons91

Expand Down
143 changes: 78 additions & 65 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ env:
OUTPUT_PATH: ${{ github.workspace }}/artifact
ASSEMBLY_VERSION: 1.0.0.${{ github.run_number }}
ADR_PROJECT_FILE: "adr-power-cli.csproj"
# ADR_TESTPROJECT_FILE: "tests.csproj"
ADR_TESTPROJECT_CORE_FILE: "adr-core-tests.csproj"
ADR_TESTPROJECT_CLI_FILE: "adr-cli-tests.csproj"
ADR_PROJECT_FILE_PATH: "./src/cli/adr-power-cli.csproj"
# ADR_TESTPROJECT_FILE_PATH: "./src/adr.tests/tests.csproj"
WINDOWS_RUNTIME: "win-x64"
UBUNTU_RUNTIME: "linux-x64"
CONFIGURATION: "Release"
ADR_SOLUTION_FILE: "adr-power-cli.sln"

on:
workflow_dispatch:
Expand All @@ -28,69 +29,81 @@ jobs:

- name: Fetch all history for all tags and branches
run: git fetch --unshallow || true

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: "5.x"

- name: Use GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/[email protected]

- run: |
echo "Major: ${{ steps.gitversion.outputs.major }}"
echo "Minor: ${{ steps.gitversion.outputs.minor }}"
echo "Patch: ${{ steps.gitversion.outputs.patch }}"
echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}"
echo "Sha: ${{ steps.gitversion.outputs.sha }}"
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}"
echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Display dotnet version
run: dotnet --version

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build ${{ env.ADR_PROJECT_FILE}} --runtime ${{ env.WINDOWS_RUNTIME }} --configuration ${{ env.CONFIGURATION }} -p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
working-directory: ./src/cli

# - name: Test
# run: dotnet test ${{ env.ADR_TESTPROJECT_FILE }} --runtime ${{ env.WINDOWS_RUNTIME}} --verbosity normal
# working-directory: ./src
# working-directory: ${{ env.ADR_TESTPROJECT_FILE }}
#
# - name: Install GitVersion
# uses: gittools/actions/gitversion/[email protected]
# with:
# versionSpec: "5.x"
#
# - name: Use GitVersion
# id: gitversion # step id used as reference for output values
# uses: gittools/actions/gitversion/[email protected]
#
# - run: |
# echo "Major: ${{ steps.gitversion.outputs.major }}"
# echo "Minor: ${{ steps.gitversion.outputs.minor }}"
# echo "Patch: ${{ steps.gitversion.outputs.patch }}"
# echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTag }}"
# echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}"
# echo "PreReleaseLabel: ${{ steps.gitversion.outputs.preReleaseLabel }}"
# echo "PreReleaseNumber: ${{ steps.gitversion.outputs.preReleaseNumber }}"
# echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.weightedPreReleaseNumber }}"
# echo "BuildMetaData: ${{ steps.gitversion.outputs.buildMetaData }}"
# echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.buildMetaDataPadded }}"
# echo "FullBuildMetaData: ${{ steps.gitversion.outputs.fullBuildMetaData }}"
# echo "MajorMinorPatch: ${{ steps.gitversion.outputs.majorMinorPatch }}"
# echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
# echo "LegacySemVer: ${{ steps.gitversion.outputs.legacySemVer }}"
# echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.legacySemVerPadded }}"
# echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
# echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.assemblySemFileVer }}"
# echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
# echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"
# echo "BranchName: ${{ steps.gitversion.outputs.branchName }}"
# echo "EscapedBranchName: ${{ steps.gitversion.outputs.escapedBranchName }}"
# echo "Sha: ${{ steps.gitversion.outputs.sha }}"
# echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}"
# echo "NuGetVersionV2: ${{ steps.gitversion.outputs.nuGetVersionV2 }}"
# echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
# echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.nuGetPreReleaseTagV2 }}"
# echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.nuGetPreReleaseTag }}"
# echo "VersionSourceSha: ${{ steps.gitversion.outputs.versionSourceSha }}"
# echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}"
# echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}"
# echo "UncommittedChanges: ${{ steps.gitversion.outputs.uncommittedChanges }}"
# echo "CommitDate: ${{ steps.gitversion.outputs.commitDate }}"
#
# - name: Setup .NET
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: ${{ env.DOTNET_VERSION }}
#
# - name: Display dotnet version
# run: dotnet --version
#
# - name: Install dependencies
# run: dotnet restore
#
# - name: Build
# run: dotnet build ${{ env.ADR_PROJECT_FILE}} --runtime ${{ env.WINDOWS_RUNTIME }} --configuration ${{ env.CONFIGURATION }} -p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
# working-directory: ./src/cli
#
# run-tests:
# name: Run tests
# needs: build
# runs-on: ubuntu-latest
# steps:
#
# - name: Execute unit testsss
# run: dotnet test ./adr-power-cli.sln
#
# # Execute all unit tests in the solution
# - name: Execute unit tests
# run: dotnet test adr-power-cli.sln
#
# - name: Test Core
# run: dotnet test tests/adr-core-tests/adr-core-tests.csproj --verbosity normal
# working-directory: tests

# publish_windows:
# name: Publish Windows package
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/dotnet-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET build and test

env:
DOTNET_VERSION: "8.x"
OUTPUT_PATH: ${{ github.workspace }}/artifact
ASSEMBLY_VERSION: 1.0.0.${{ github.run_number }}
ADR_PROJECT_FILE: "adr-power-cli.csproj"
ADR_TESTPROJECT_CORE_FILE: "adr-core-tests.csproj"
ADR_TESTPROJECT_CLI_FILE: "adr-cli-tests.csproj"
ADR_PROJECT_FILE_PATH: "./src/cli/adr-power-cli.csproj"
WINDOWS_RUNTIME: "win-x64"
UBUNTU_RUNTIME: "linux-x64"
CONFIGURATION: "Release"
ADR_SOLUTION_FILE: "adr-power-cli.sln"


on:
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration ${{ env.CONFIGURATION }}
- name: Test
run: dotnet test --no-build --verbosity normal
41 changes: 41 additions & 0 deletions .github/workflows/dotnet-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET build and release

env:
DOTNET_VERSION: "8.x"
OUTPUT_PATH: ${{ github.workspace }}/artifact
ASSEMBLY_VERSION: 1.0.0.${{ github.run_number }}
ADR_PROJECT_FILE: "adr-power-cli.csproj"
ADR_TESTPROJECT_CORE_FILE: "adr-core-tests.csproj"
ADR_TESTPROJECT_CLI_FILE: "adr-cli-tests.csproj"
ADR_PROJECT_FILE_PATH: "./src/cli/adr-power-cli.csproj"
WINDOWS_RUNTIME: "win-x64"
UBUNTU_RUNTIME: "linux-x64"
CONFIGURATION: "Release"
ADR_SOLUTION_FILE: "adr-power-cli.sln"


on:
push:
branches: [ "main" ]


jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,23 @@
/src/core/obj
/src/cli/bin
/src/core/bin/Release/net8.0
/tests/adr-cli-tests/bin/Release/net8.0
/tests/adr-cli-tests/obj
/tests/adr-core-tests/obj
/tests/adr-core-tests/bin/Debug/net8.0
/tests/adr-cli-tests/bin/Debug/net8.0/cs
/tests/adr-cli-tests/bin/Debug/net8.0/de
/tests/adr-cli-tests/bin/Debug/net8.0/es
/tests/adr-cli-tests/bin/Debug/net8.0/fr
/tests/adr-cli-tests/bin/Debug/net8.0/it
/tests/adr-cli-tests/bin/Debug/net8.0/ja
/tests/adr-cli-tests/bin/Debug/net8.0/ko
/tests/adr-cli-tests/bin/Debug/net8.0/pl
/tests/adr-cli-tests/bin/Debug/net8.0/pt-BR
/tests/adr-cli-tests/bin/Debug/net8.0/ru
/tests/adr-cli-tests/bin/Debug/net8.0/runtimes/win/lib/net8.0
/tests/adr-cli-tests/bin/Debug/net8.0/tr
/tests/adr-cli-tests/bin/Debug/net8.0/zh-Hans
/tests/adr-cli-tests/bin/Debug/net8.0/zh-Hant
/tests/adr-cli-tests/bin/Debug/net8.0
/tests/adr-core-tests/bin/Release/net8.0/CoverletSourceRootsMapping_adr-core-tests
18 changes: 18 additions & 0 deletions adr-power-cli.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adr-power-core", "src\core\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adr-power-cli", "src\cli\adr-power-cli.csproj", "{2F804F29-2275-4A06-A788-1A8716B93011}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{07DBE925-DED5-4594-83E9-FBD648283B98}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "adr-core-tests", "tests\adr-core-tests\adr-core-tests.csproj", "{6C792AC5-E8F6-41D8-AB71-65AC52DB238F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "adr-cli-tests", "tests\adr-cli-tests\adr-cli-tests.csproj", "{DF10E0A1-FCBE-4C0B-9779-6D7C2EDF2C60}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,10 +27,22 @@ Global
{2F804F29-2275-4A06-A788-1A8716B93011}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F804F29-2275-4A06-A788-1A8716B93011}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F804F29-2275-4A06-A788-1A8716B93011}.Release|Any CPU.Build.0 = Release|Any CPU
{6C792AC5-E8F6-41D8-AB71-65AC52DB238F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C792AC5-E8F6-41D8-AB71-65AC52DB238F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C792AC5-E8F6-41D8-AB71-65AC52DB238F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C792AC5-E8F6-41D8-AB71-65AC52DB238F}.Release|Any CPU.Build.0 = Release|Any CPU
{DF10E0A1-FCBE-4C0B-9779-6D7C2EDF2C60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF10E0A1-FCBE-4C0B-9779-6D7C2EDF2C60}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF10E0A1-FCBE-4C0B-9779-6D7C2EDF2C60}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF10E0A1-FCBE-4C0B-9779-6D7C2EDF2C60}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6C792AC5-E8F6-41D8-AB71-65AC52DB238F} = {07DBE925-DED5-4594-83E9-FBD648283B98}
{DF10E0A1-FCBE-4C0B-9779-6D7C2EDF2C60} = {07DBE925-DED5-4594-83E9-FBD648283B98}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E498D567-4BCF-4FBB-83DE-91EA8891B3EF}
EndGlobalSection
Expand Down
1 change: 1 addition & 0 deletions tests/adr-cli-tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using NUnit.Framework;
16 changes: 16 additions & 0 deletions tests/adr-cli-tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace adr_cli_tests
{
public class Tests
{
[SetUp]
public void Setup()
{
}

[Test]
public void Test1()
{
Assert.Pass();
}
}
}
25 changes: 25 additions & 0 deletions tests/adr-cli-tests/adr-cli-tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>adr_cli_tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\cli\adr-power-cli.csproj" />
</ItemGroup>

</Project>
Binary file not shown.
1 change: 1 addition & 0 deletions tests/adr-core-tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using NUnit.Framework;
Loading

0 comments on commit beb3da9

Please sign in to comment.