Skip to content

Release/6.1.0 #166

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 14 commits into from
Dec 2, 2023
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
16 changes: 0 additions & 16 deletions .github/dependabot.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>cake-contrib/renovate-presets:cake-recipe"]
}
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ jobs:

steps:
- name: Checkout the repository
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Fetch all tags and branches
run: git fetch --prune --unshallow

# codecov and unittests need 2.1, gitversion needs 5.0
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
with:
dotnet-version: |
2.1
Expand All @@ -61,13 +61,13 @@ jobs:
8.0

- name: Cache Tools
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
with:
path: tools
key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }}

- name: Build project
uses: cake-build/cake-action@v1.4.1
uses: cake-build/cake-action@a6eb054329257c9e70a6c6bf01747ad6e1d9d52b # v1.4.1
with:
script-path: recipe.cake
target: CI
Expand All @@ -76,7 +76,7 @@ jobs:

# currently, Cake.Recipe does not upload artifacts when run on gh-actions
- name: Upload Issues
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
if-no-files-found: warn
name: ${{ matrix.os }} Issues
Expand All @@ -85,7 +85,7 @@ jobs:
BuildArtifacts/**/coverlet/*.xml

- name: Upload Packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
if: runner.os == 'Windows'
with:
if-no-files-found: warn
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0

- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
with:
dotnet-version: |
2.1
Expand All @@ -35,22 +35,22 @@ jobs:
8.0
- name: Cache Tools
uses: actions/cache@v3
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3
with:
path: tools
key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2
with:
languages: ${{ matrix.language }}

- name: Build project
uses: cake-build/cake-action@v1.4.1
uses: cake-build/cake-action@a6eb054329257c9e70a6c6bf01747ad6e1d9d52b # v1.4.1
with:
script-path: recipe.cake
target: DotNetCore-Build
cake-version: 1.3.0

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2
13 changes: 0 additions & 13 deletions .github/workflows/dependabot-cake.yml

This file was deleted.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Currently this module supports:

- Log folding for the Cake build and for individual tasks

### GitLab CI

- Add colored output for Cake log messages in the GitLab pipeline output window

## Usage

Each build system's functionality resides in its own module, with `Cake.Module.Shared` used for shared types. Each module will conditionally register itself, meaning they will only be loaded in their respective CI environments. This means all modules can be deployed with a single codebase without interference.
Expand Down Expand Up @@ -81,6 +85,7 @@ public static int Main(string[] args)
.UseModule<MyGetModule>()
.UseModule<TravisCIModule>()
.UseModule<TeamCityModule>()
.UseModule<GitLabCIModule>()
// continue with the "normal" setup of the CakeHost
.UseContext<BuildContext>()
.Run(args);
Expand Down
2 changes: 1 addition & 1 deletion demo/dsl/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "1.1.0",
"version": "4.0.0",
"commands": [
"dotnet-cake"
]
Expand Down
2 changes: 1 addition & 1 deletion demo/dsl/build.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#module nuget:?package=Cake.BuildSystems.Module&version=3.0.3
#module nuget://?package=Cake.Buildsystems.Module&prerelease

///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
Expand Down
9 changes: 9 additions & 0 deletions demo/dsl/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
$env:DOTNET_NOLOGO = '1'

# make sure we always get a fresh nuget-package and nothing from cache!
dotnet nuget locals all --clear

@("./tools", "./.cake") | % {
if(Test-Path $_) {
rm -Force -Recurse $_
}
}

dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

Expand Down
10 changes: 10 additions & 0 deletions demo/dsl/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
</config>
<packageSources>
<clear />
<add key="local pkg" value="../../BuildArtifacts/Packages/NuGet/" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
12 changes: 8 additions & 4 deletions demo/frosting/build/Build.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.BuildSystems.Module" Version="3.0.3" />
<PackageReference Include="Cake.Frosting" Version="1.1.0" />
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Cake.Frosting" Version="4.0.0" />
<ProjectReference Include="$(ProjectDir)../../../src/Cake.AzurePipelines.Module/Cake.AzurePipelines.Module.csproj" />
<ProjectReference Include="$(ProjectDir)../../../src/Cake.GitHubActions.Module/Cake.GitHubActions.Module.csproj" />
<ProjectReference Include="$(ProjectDir)../../../src/Cake.MyGet.Module/Cake.MyGet.Module.csproj" />
<ProjectReference Include="$(ProjectDir)../../../src/Cake.TeamCity.Module/Cake.TeamCity.Module.csproj" />
<ProjectReference Include="$(ProjectDir)../../../src/Cake.TravisCI.Module/Cake.TravisCI.Module.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion recipe.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#load nuget:?package=Cake.Recipe&version=3.0.1
#load nuget:?package=Cake.Recipe&version=3.1.1

Environment.SetVariableNames();

Expand Down
14 changes: 14 additions & 0 deletions src/Cake.BuildSystems.Module.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.BuildSystems.Module",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.GitHubActions.Module", "Cake.GitHubActions.Module\Cake.GitHubActions.Module.csproj", "{A6BAA454-179C-422C-A954-38852265722F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.GitLabCI.Module", "Cake.GitLabCI.Module\Cake.GitLabCI.Module.csproj", "{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -115,6 +117,18 @@ Global
{A6BAA454-179C-422C-A954-38852265722F}.Release|x64.Build.0 = Release|Any CPU
{A6BAA454-179C-422C-A954-38852265722F}.Release|x86.ActiveCfg = Release|Any CPU
{A6BAA454-179C-422C-A954-38852265722F}.Release|x86.Build.0 = Release|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Debug|x64.ActiveCfg = Debug|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Debug|x64.Build.0 = Debug|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Debug|x86.Build.0 = Debug|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Release|Any CPU.Build.0 = Release|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Release|x64.ActiveCfg = Release|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Release|x64.Build.0 = Release|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Release|x86.ActiveCfg = Release|Any CPU
{DA6236E5-E4B3-42B4-BB3D-69CE06DAB85B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 3 additions & 0 deletions src/Cake.BuildSystems.Module/Cake.BuildSystems.Module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<ProjectReference Include="..\Cake.GitHubActions.Module\Cake.GitHubActions.Module.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
<ProjectReference Include="..\Cake.GitLabCI.Module\Cake.GitLabCI.Module.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions src/Cake.GitLabCI.Module/AnsiEscapeCodes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Cake.AzurePipelines.Module
{
internal static class AnsiEscapeCodes
{
public static readonly string Reset = string.Format(FORMAT, 0);
public static readonly string ForegroundWhite = string.Format(FORMAT, 97);
public static readonly string ForegroundYellow = string.Format(FORMAT, 33);
public static readonly string ForegroundLightGray = string.Format(FORMAT, 37);
public static readonly string ForegroundDarkGray = string.Format(FORMAT, 90);
public static readonly string BackgroundMagenta = string.Format(FORMAT, 45);
public static readonly string BackgroundRed = string.Format(FORMAT, 41);

private const string FORMAT = "\u001B[{0}m";
}
}
27 changes: 27 additions & 0 deletions src/Cake.GitLabCI.Module/Cake.GitLabCI.Module.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Cake.GitLabCI.Module</AssemblyName>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Cake.Module.Shared\Cake.Module.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="4.0.0" PrivateAssets="All" />
<PackageReference Include="Cake.Common" Version="4.0.0" PrivateAssets="All" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
83 changes: 83 additions & 0 deletions src/Cake.GitLabCI.Module/GitLabCILog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;

using Cake.Core;
using Cake.Core.Diagnostics;

using JetBrains.Annotations;

namespace Cake.AzurePipelines.Module
{
/// <summary>
/// <see cref="ICakeLog"/> implementation for GitLab CI.
/// </summary>
[UsedImplicitly]
public class GitLabCILog : ICakeLog
{
private readonly ICakeLog _cakeLogImplementation;
private readonly IConsole _console;

// Define the escape sequenes to make GitLab show colored messages
// For reference, see https://docs.gitlab.com/ee/ci/yaml/script.html#add-color-codes-to-script-output
// For the colors, match the colors used by Cake, see https://github.com/cake-build/cake/blob/ed612029b92f5da2b6cbdfe295c62e6b99a2963d/src/Cake.Core/Diagnostics/Console/ConsolePalette.cs#L34C17-L34C17
private readonly Dictionary<LogLevel, string> _escapeSequences = new Dictionary<LogLevel, string>()
{
{ LogLevel.Fatal, $"{AnsiEscapeCodes.BackgroundMagenta}{AnsiEscapeCodes.ForegroundWhite}" },
{ LogLevel.Error, $"{AnsiEscapeCodes.BackgroundRed}{AnsiEscapeCodes.ForegroundWhite}" },
{ LogLevel.Warning, AnsiEscapeCodes.ForegroundYellow },
{ LogLevel.Verbose, AnsiEscapeCodes.ForegroundLightGray },
{ LogLevel.Debug, AnsiEscapeCodes.ForegroundDarkGray },
};

/// <summary>
/// Initializes a new instance of the <see cref="GitLabCILog"/> class.
/// </summary>
/// <param name="console">Implementation of <see cref="IConsole"/>.</param>
/// <param name="verbosity">Default <see cref="Verbosity"/>.</param>
public GitLabCILog(IConsole console, Verbosity verbosity = Verbosity.Normal)
{
_cakeLogImplementation = new CakeBuildLog(console, verbosity);
_console = console;
}

/// <inheritdoc />
public Verbosity Verbosity
{
get { return _cakeLogImplementation.Verbosity; }
set { _cakeLogImplementation.Verbosity = value; }
}

/// <inheritdoc />
public void Write(Verbosity verbosity, LogLevel level, string format, params object[] args)
{
if (!StringComparer.OrdinalIgnoreCase.Equals(Environment.GetEnvironmentVariable("CI_SERVER"), "yes"))
{
_cakeLogImplementation.Write(verbosity, level, format, args);
}

if (verbosity > Verbosity)
{
return;
}

string message;
if (_escapeSequences.TryGetValue(level, out var sequence))
{
message = $"{sequence}{level}: {string.Format(format, args)}{AnsiEscapeCodes.Reset}";
}
else
{
message = $"{level}: {string.Format(format, args)}";
}

if (level > LogLevel.Error)
{
_console.WriteLine(message);
}
else
{
_console.WriteErrorLine(message);
}
}
}
}
Loading