From 1f325d2b825602cc874b75b6ff10017d7eefac25 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Sat, 9 May 2020 23:29:50 +0300 Subject: [PATCH] GH-2255 - implemented Commandline and Portable validation --- .azurepipelines/artifacts-test.yml | 20 ++++++++++ .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++- build/artifacts-test.cake | 48 +++++++++++++++++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) diff --git a/.azurepipelines/artifacts-test.yml b/.azurepipelines/artifacts-test.yml index ccd1d80785..d56d18430b 100644 --- a/.azurepipelines/artifacts-test.yml +++ b/.azurepipelines/artifacts-test.yml @@ -28,3 +28,23 @@ jobs: includeArtifacts: true - pwsh: ./build.ps1 -target Artifacts-MsBuildFull-Test displayName: '[MsBuild Test Artifacts]' +- job: Artifacts_Test_Commandline + displayName: Artifacts Test Commandline (Windows) + pool: + vmImage: windows-latest + steps: + - template: common-steps.yml + parameters: + includeArtifacts: true + - pwsh: ./build.ps1 -target Artifacts-Commandline-Test + displayName: '[Commandline Test Artifacts]' +- job: Artifacts_Test_Portable + displayName: Artifacts Test Portable (Windows) + pool: + vmImage: windows-latest + steps: + - template: common-steps.yml + parameters: + includeArtifacts: true + - pwsh: ./build.ps1 -target Artifacts-Portable-Test + displayName: '[Portable Test Artifacts]' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33e939a454..95b0933bfd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -163,9 +163,69 @@ jobs: shell: pwsh run: ./build.ps1 -target Artifacts-MsBuildFull-Test + artifact_commandline_test: + name: Artifacts Commandline Test + needs: [build, test] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Fetch all history for all tags and branches + run: | + git fetch --prune --unshallow + - name: Cache tools + id: cache-tools + uses: actions/cache@v1 + with: + path: tools + key: v1-${{ runner.os }}-tools-${{ hashFiles('build.cake') }} + - name: Cache dotnet + id: cache-dotnet + uses: actions/cache@v1 + with: + path: .dotnet + key: v1-${{ runner.os }}-dotnet-${{ hashFiles('build.config') }} + - uses: actions/download-artifact@v1 + name: Download artifacts folder + with: + name: storage + path: ${{ github.workspace }}/artifacts + - name: '[Commandline Test Artifacts]' + shell: pwsh + run: ./build.ps1 -target Artifacts-Commandline-Test + + artifact_portable_test: + name: Artifacts Portable Test + needs: [build, test] + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Fetch all history for all tags and branches + run: | + git fetch --prune --unshallow + - name: Cache tools + id: cache-tools + uses: actions/cache@v1 + with: + path: tools + key: v1-${{ runner.os }}-tools-${{ hashFiles('build.cake') }} + - name: Cache dotnet + id: cache-dotnet + uses: actions/cache@v1 + with: + path: .dotnet + key: v1-${{ runner.os }}-dotnet-${{ hashFiles('build.config') }} + - uses: actions/download-artifact@v1 + name: Download artifacts folder + with: + name: storage + path: ${{ github.workspace }}/artifacts + - name: '[Portable Test Artifacts]' + shell: pwsh + run: ./build.ps1 -target Artifacts-Portable-Test + docker: name: Docker - needs: [artifact_test, artifact_msbuild_test] + needs: [artifact_test, artifact_msbuild_test, artifact_commandline_test, artifact_portable_test] runs-on: ubuntu-latest env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} diff --git a/build/artifacts-test.cake b/build/artifacts-test.cake index 3b1279b0d5..1a2e554686 100644 --- a/build/artifacts-test.cake +++ b/build/artifacts-test.cake @@ -29,6 +29,54 @@ Task("Artifacts-DotnetTool-Test") } }); +Task("Artifacts-Commandline-Test") + .WithCriteria((context, parameters) => parameters.IsRunningOnWindows, "Artifacts-Commandline-Test can be tested only on Windows agents.") + .WithCriteria((context, parameters) => parameters.IsReleasingCI, "Artifacts-Commandline-Test works only on Releasing CI.") + .IsDependentOnWhen("Pack-Nuget", singleStageRun) + .Does((parameters) => +{ + NuGetInstall("GitVersion.Commandline", new NuGetInstallSettings { + Source = new string[] { MakeAbsolute(parameters.Paths.Directories.NugetRoot).FullPath }, + ExcludeVersion = true, + Prerelease = true, + OutputDirectory = parameters.Paths.Directories.ArtifactsRoot + }); + + var settings = new GitVersionSettings + { + OutputType = GitVersionOutput.Json, + ToolPath = parameters.Paths.Directories.ArtifactsRoot.Combine("GitVersion.Commandline/tools").CombineWithFilePath("gitversion.exe").FullPath + }; + var gitVersion = GitVersion(settings); + + Assert.Equal(parameters.Version.GitVersion.FullSemVer, gitVersion.FullSemVer); +}); + +Task("Artifacts-Portable-Test") + .WithCriteria((context, parameters) => parameters.IsRunningOnWindows, "Artifacts-Portable-Test can be tested only on Windows agents.") + .WithCriteria((context, parameters) => parameters.IsReleasingCI, "Artifacts-Portable-Test works only on Releasing CI.") + .IsDependentOnWhen("Pack-Chocolatey", singleStageRun) + .Does((parameters) => +{ + if (parameters.IsMainBranch && !parameters.IsPullRequest) { + NuGetInstall("GitVersion.Portable", new NuGetInstallSettings { + Source = new string[] { MakeAbsolute(parameters.Paths.Directories.NugetRoot).FullPath }, + ExcludeVersion = true, + Prerelease = true, + OutputDirectory = parameters.Paths.Directories.ArtifactsRoot + }); + + var settings = new GitVersionSettings + { + OutputType = GitVersionOutput.Json, + ToolPath = parameters.Paths.Directories.ArtifactsRoot.Combine("GitVersion.Portable/tools").CombineWithFilePath("gitversion.exe").FullPath + }; + var gitVersion = GitVersion(settings); + + Assert.Equal(parameters.Version.GitVersion.FullSemVer, gitVersion.FullSemVer); + } +}); + Task("Artifacts-Native-Test") .WithCriteria((context, parameters) => parameters.IsRunningOnLinux, "Artifacts-Native-Test can be tested only on Linux agents.") .WithCriteria((context, parameters) => parameters.IsReleasingCI, "Artifacts-Native-Test works only on Releasing CI.")