Skip to content

A few fixes for uploading new projects. #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from Aug 20, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<StartupObject />
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="autofixture" Version="4.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.2" />
Expand Down
15 changes: 12 additions & 3 deletions OctopusProjectBuilder.Uploader/ModelUploader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Octopus.Client;
using Octopus.Client.Model;
Expand Down Expand Up @@ -94,7 +95,9 @@ private async Task UploadProject(Project project)
{
var projectResource = await LoadResource(_repository.Projects, project.Identifier);
await projectResource.UpdateWith(project, _repository);
await Upsert(_repository.Projects, projectResource);
var response = await Upsert(_repository.Projects, projectResource);
projectResource.DeploymentProcessId = response.DeploymentProcessId;
projectResource.VariableSetId = response.VariableSetId;

var deploymentProcessResource = await _repository.DeploymentProcesses.Get(projectResource.DeploymentProcessId);
await deploymentProcessResource.UpdateWith(project.DeploymentProcess, _repository);
Expand All @@ -116,11 +119,17 @@ await Update(

private async Task UploadProjectTriggers(ProjectResource projectResource, IEnumerable<ProjectTrigger> triggers)
{
var triggerList = triggers.ToList();
if (!triggerList.Any())
{
return;
}

var projectTriggers = await _repository.Projects.GetTriggers(projectResource);
foreach (var resource in projectTriggers.Items)
await Delete(_repository.ProjectTriggers, resource, projectResource.Name);

foreach (var trigger in triggers)
foreach (var trigger in triggerList)
{
var resource = await LoadResource(name => _repository.ProjectTriggers.FindByName(projectResource, name), trigger.Identifier);
await resource.UpdateWith(trigger, projectResource.Id, _repository);
Expand Down Expand Up @@ -168,7 +177,7 @@ private async Task<TResource> Upsert<TRepository, TResource>(TRepository reposit
var result = string.IsNullOrWhiteSpace(resource.Id)
? await repository.Create(resource)
: await repository.Modify(resource);

_logger.LogDebug($"Upserted {typeof(TResource).Name}: {resource.Name}");
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
<StartupObject />
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="autofixture" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
Expand Down
2 changes: 1 addition & 1 deletion OctopusProjectBuilder.YamlReader/Model/YamlProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Project ToModel()
new ElementReference(ProjectGroupRef),
VersioningStrategy?.ToModel(),
Triggers.EnsureNotNull().Select(t => t.ToModel()),
(TenantedDeploymentMode)Enum.Parse(typeof(TenantedDeploymentMode), TenantedDeploymentMode));
(TenantedDeploymentMode)Enum.Parse(typeof(TenantedDeploymentMode), TenantedDeploymentMode ?? default(TenantedDeploymentMode).ToString()));
}

public static YamlProject FromModel(Project model)
Expand Down
24 changes: 19 additions & 5 deletions make/Makefile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,37 @@ Define-Step -Name 'Update Assembly Info' -Target 'build' -Body {

Define-Step -Name 'Build' -Target 'build' -Body {
call $Context.NugetExe restore OctopusProjectBuilder.sln
call "${env:ProgramFiles(x86)}\MSBuild\14.0\Bin\msbuild.exe" OctopusProjectBuilder.sln /t:"Clean,Build" /p:Configuration=Release /m /verbosity:m /nologo /p:TreatWarningsAsErrors=true
#call "${env:ProgramFiles(x86)}\MSBuild\14.0\Bin\msbuild.exe" OctopusProjectBuilder.sln /t:"Clean,Build" /p:Configuration=Release /m /verbosity:m /nologo /p:TreatWarningsAsErrors=true
call dotnet build --configuration Release /p:DebugType=Full
}

Define-Step -Name 'Tests' -Target 'build' -Body {
. (require 'psmake.mod.testing')

Write-ShortStatus "Preparing OpenCover"
$OpenCoverPath = Fetch-Package "OpenCover" "4.6.519"
$openCoverConsole = $OpenCoverPath + "\tools\OpenCover.Console.exe"

Write-ShortStatus "Running tests with OpenCover"
mkdir "reports"
$RunnerArgs = "test", "OctopusProjectBuilder.YamlReader.Tests", "--no-build", "-f netcoreapp2.0", "-c Release", "-l:trx;LogFileName=..\..\reports\unit-test-results1.xml"
call "$openCoverConsole" "-log:Error" "-showunvisited" "-oldStyle" "-register:user" "-target:dotnet.exe" "-targetargs:`"$RunnerArgs`"" "`"-filter:+[OctopusProjectBuilder*]*`"" "-coverbytest:*.Tests.dll" "-output:$PSScriptRoot\..\reports\opencover1.xml"

$RunnerArgs = "test", "OctopusProjectBuilder.Uploader.Tests", "--no-build", "-f netcoreapp2.0", "-c Release", "-l:trx;LogFileName=..\..\reports\unit-test-results2.xml"
call "$openCoverConsole" "-log:Error" "-showunvisited" "-oldStyle" "-register:user" "-target:dotnet.exe" "-targetargs:`"$RunnerArgs`"" "`"-filter:+[OctopusProjectBuilder*]*`"" "-coverbytest:*.Tests.dll" "-output:$PSScriptRoot\..\reports\opencover2.xml"

$tests = @()
$tests += Define-NUnit3Tests -GroupName 'Unit Tests' -TestAssembly "*.Tests\bin\Release\*.Tests.dll"
$tests += Create-Object @{CoverageReports = "reports\opencover1.xml", "reports\opencover2.xml";
ReportDirectory = $PSScriptRoot + "\..\reports"
TestResult = "..\..\reports\unit-test-results.xml"}

$tests `
| Run-Tests -EraseReportDirectory -Cover -CodeFilter '+[OctopusProjectBuilder*]* -[*.Tests*]*' -TestFilter '*.Tests.dll' `
| Generate-CoverageSummary `
| Check-AcceptableCoverage -AcceptableCoverage 89
| Check-AcceptableCoverage -AcceptableCoverage 75
}

Define-Step -Name 'Documentation generation' -Target 'build' -Body {
& OctopusProjectBuilder.DocGen\bin\Release\OctopusProjectBuilder.DocGen.exe | out-file Manual.md -Encoding utf8
& dotnet .\OctopusProjectBuilder.DocGen\bin\Release\netcoreapp2.0\OctopusProjectBuilder.DocGen.dll | out-file Manual.md -Encoding utf8
if ($LastExitCode -ne 0) { throw "A program execution was not successful (Exit code: $LASTEXITCODE)." }
}

Expand Down