Skip to content

Commit

Permalink
(GH-514) ArgumentNullException when running on Ubuntu (#515)
Browse files Browse the repository at this point in the history
* (GH-402) Add integration tests for Cake.Issues.MsBuild

* Run unit tests on GitHub actions

* Ensure strings are initialized
  • Loading branch information
pascalberger authored Apr 20, 2024
1 parent 755a9a4 commit 2bb7fda
Show file tree
Hide file tree
Showing 14 changed files with 710 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and tests
name: Integration tests

# Workflow Trigger
on:
Expand Down Expand Up @@ -36,6 +36,35 @@ jobs:
with:
name: NuGet Package
path: ./BuildArtifacts/Packages/NuGet/
# Integration Tests Cake.Issues.MsBuild Cake Scripting
IntegrationTestsMsBuildCakeScripting:
name: Integration Tests Cake.Issues.MsBuild Cake Scripting
needs: Build
strategy:
fail-fast: false
matrix:
os: [
windows-2019, windows-2022,
ubuntu-20.04, ubuntu-22.04,
macos-11, macos-14]
dotnet: [6.x, 7.x, 8.x]
runs-on: ${{ matrix.os }}
steps:
- name: Get the sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Download build artifact
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4
with:
name: NuGet Package
path: ./BuildArtifacts/Packages/NuGet
- name: Install .NET
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Run integration tests
run: ./build.sh --verbosity=diagnostic
working-directory: ./tests/Cake.Issues.MsBuild/script-runner/
shell: bash
# Integration Tests Cake.Issues.PullRequests.GitHubActions Cake Scripting
IntegrationTestsPullRequestsGitHubActionsCakeScripting:
name: Integration Tests Cake.Issues.PullRequests.GitHubActions Cake Scripting
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Unit tests

# Workflow Trigger
on:
# Trigger the workflow on a pull request to any branch
pull_request:
# Triggers the workflow in the event there is a push to master
push:
branches:
- master

jobs:
Test:
name: Run unit tests
strategy:
fail-fast: false
matrix:
os: [
windows-2019, windows-2022,
ubuntu-20.04, ubuntu-22.04,
# Cake.Recipe currently does not support macOS 14 (M1)
macos-11, macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: Get the sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Fetch all tags and branches
run: git fetch --prune --unshallow
- name: Install .NET
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4
with:
# .NET 5 required for GitVersion
dotnet-version: |
5.x
6.x
7.x
8.x
- name: Test
run: ./build.sh --target=Test
shell: bash
29 changes: 29 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,35 @@ stages:
artifact: Integration Tests Cake.Issues.Markdownlint $(System.JobName)
displayName: 'Publish generated reports as build artifact'

- stage: IntegrationTestsMsBuildStage
displayName: Integration Tests Cake.Issues.MsBuild
dependsOn: BuildStage
jobs:
- job: TestMsBuildJob
displayName: Test
strategy:
matrix:
Windows_Server_2019:
imageName: 'windows-2019'
Windows_Server_2022:
imageName: 'windows-2022'
macOS_11:
imageName: 'macOS-11'
macOS_13:
imageName: 'macOS-13'
Ubuntu_20_04:
imageName: 'ubuntu-20.04'
Ubuntu_22_04:
imageName: 'ubuntu-22.04'
pool:
vmImage: $(imageName)
steps:
- template: .azuredevops/pipelines/templates/steps/install-net6.yml
- template: .azuredevops/pipelines/templates/steps/provide-nuget-packages.yml
- powershell: ./build.ps1 --verbosity=diagnostic
workingDirectory: ./tests/Cake.Issues.MsBuild/script-runner
displayName: 'Run integration tests'

- stage: IntegrationTestsReportingConsoleStage
displayName: Integration Tests Cake.Issues.Reporting.Console
dependsOn: BuildStage
Expand Down
8 changes: 8 additions & 0 deletions src/Cake.Issues.MsBuild/LogFileFormat/BinaryLogFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Cake.Core.Diagnostics;
using Microsoft.Build.Framework;
using Microsoft.Build.Logging.StructuredLogger;
Expand All @@ -23,6 +24,13 @@ public override IEnumerable<IIssue> ReadIssues(
repositorySettings.NotNull(nameof(repositorySettings));
issueProviderSettings.NotNull(nameof(issueProviderSettings));

// Ensure that strings for MsBuild.StructuredLogger are initialized.
// See https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/736
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Strings.Initialize();
}

var result = new List<IIssue>();

var binLogReader = new BinLogReader();
Expand Down
12 changes: 12 additions & 0 deletions tests/Cake.Issues.MsBuild/script-runner/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "4.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
Loading

0 comments on commit 2bb7fda

Please sign in to comment.