Skip to content
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

OSOE-110: Fix verify action that fails if the PR title has apostrophe in it #21

Merged
merged 38 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0eabe53
Make the title a step environment variable, so it doesn't need to be …
sarahelsaig Jun 30, 2022
8e2c989
Call Update-ManifestVersion
sarahelsaig Jun 30, 2022
58fa418
Merge remote-tracking branch 'origin/dev' into issue/OSOE-110
sarahelsaig Jul 2, 2022
9e6896f
Optional nuspec generation via pwsh script.
sarahelsaig Jul 2, 2022
9aedbb3
Rewrite to pack each of the solution's projects separately.
sarahelsaig Jul 2, 2022
a825d3a
Some random code cleanup.
sarahelsaig Jul 2, 2022
78e31cd
Refactor pack logic into script.
sarahelsaig Jul 2, 2022
ea6ecac
Revert "Some random code cleanup."
sarahelsaig Jul 2, 2022
abdc4cf
Update target branch.
sarahelsaig Jul 2, 2022
33db42d
Fix typo.
sarahelsaig Jul 2, 2022
d5179f8
Fix NuspecProperties
sarahelsaig Jul 2, 2022
afa9f86
Add before pack hook.
sarahelsaig Jul 2, 2022
4f62c5c
Fix "No newline at end of file".
sarahelsaig Jul 2, 2022
e3ff0b8
Whitelist NU5100.
sarahelsaig Jul 3, 2022
3c85210
Merge remote-tracking branch 'origin/dev' into issue/OSOE-110
sarahelsaig Jul 10, 2022
254c588
Merge remote-tracking branch 'origin/dev' into issue/OSOE-110
sarahelsaig Jul 12, 2022
9da1790
Merge remote-tracking branch 'origin/dev' into issue/OSOE-110
sarahelsaig Jul 15, 2022
8d898c0
Merge remote-tracking branch 'origin/dev' into issue/OSOE-110
sarahelsaig Jul 24, 2022
5801fad
Handle special case when no errors were displayed at all.
sarahelsaig Jul 24, 2022
352ac78
Test double building, just as a sanity check.
sarahelsaig Jul 24, 2022
560dff1
Select correct branch from workflow
sarahelsaig Jul 24, 2022
65f76ab
Revert "Test double building, just as a sanity check."
sarahelsaig Jul 24, 2022
d86196a
Merge remote-tracking branch 'origin/dev' into issue/OSOE-110
sarahelsaig Jul 28, 2022
7aa87ff
Add LombiqNetAnalyzers target execution.
sarahelsaig Jul 28, 2022
c30bcc4
Don't out-null just yet
sarahelsaig Jul 28, 2022
89118d3
Suppress again.
sarahelsaig Jul 28, 2022
7690a86
Restore as well.
sarahelsaig Jul 28, 2022
173e727
Merge remote-tracking branch 'origin/dev' into issue/OSOE-110
sarahelsaig Aug 1, 2022
ff5b373
Rename script as per PSUseSingularNouns.
sarahelsaig Aug 1, 2022
2f882a1
Code cleanup
sarahelsaig Aug 1, 2022
8bae04a
dismiss => discard
sarahelsaig Aug 2, 2022
73d3413
Various cleanup.
sarahelsaig Aug 2, 2022
8775245
Comment on NuspecFile.
sarahelsaig Aug 2, 2022
fd47198
Move "We go through the projects individually..." into the `comment-h…
sarahelsaig Aug 3, 2022
7c91ad8
Trying to fix NU5104
Aug 4, 2022
e86529e
Revert "Trying to fix NU5104"
Aug 4, 2022
2cb188f
Trying to fix NU5100 and remove it altogether
Aug 4, 2022
c6c0bcd
Add parameter to disable symbol package creation during publish
Aug 4, 2022
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
18 changes: 15 additions & 3 deletions .github/actions/build-dotnet/Build-DotNetSolution.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

function ConvertTo-Array([string] $rawInput)
{
$rawInput.Replace("`r", "").Split("`n") |
% { $_.Trim() } |
? { -not [string]::IsNullOrEmpty($_) }
$rawInput.Replace("`r", "").Split("`n") | % { $_.Trim() } | ? { $_ }
}

Write-Output ".NET version number: $Version"
Expand Down Expand Up @@ -50,6 +48,11 @@ if (Test-Path src/Utilities/Lombiq.Gulp.Extensions/Lombiq.Gulp.Extensions.csproj
Write-Output "::endgroup::"
}

# This prepares the solution with the Lombiq.Analyzers files. The output and exit code are discarded because they will
# be in error if there is a project without the LombiqNetAnalyzers target. Then there is nothing to do, and the target
# will still run on the projects that have it.
dotnet msbuild '-target:Restore;LombiqNetAnalyzers' $Solution | Out-Null || bash -c 'true'
0liver marked this conversation as resolved.
Show resolved Hide resolved

Write-Output "Building solution with ``dotnet build $Solution $($buildSwitches -join " ")``."

$errorLines = New-Object "System.Collections.Generic.List[string]"
Expand All @@ -72,6 +75,15 @@ if ($expectedErrorCodes)
$fail = 0
$report = New-Object "System.Text.StringBuilder" "`n"

if ($null -eq $errorCodes -or -not $errorCodes.Count)
{
$expectedCount = $expectedErrorCodes.Count
$expectedCodesJoined = $expectedErrorCodes -join ', '

Write-Output "::error::Expected $expectedCount error codes ($expectedCodesJoined), but none were displayed."
exit 1
}

$length = [System.Math]::Max($errorCodes.Count, $expectedErrorCodes.Count)
foreach ($index in 0..($length - 1))
{
Expand Down
34 changes: 34 additions & 0 deletions .github/actions/publish-nuget/New-NuGetPackage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<#
.SYNOPSIS
Creates a NuGet package from each project in the sln file in the current directory.
.DESCRIPTION
Uses "dotnet sln list" to get all projects in the current directory. This means the current directory must have
exactly one sln file in it. Then calls "dotnet pack" for each csproj file with the provided arguments. If there is
a nuspec file in the project's directory too, then it is used to generate the package description instead of the
regular auto-generation.
.NOTES
We go through the projects individually in a foreach loop, because the "-p:NuspecFile=" parameter can't be passed
to a solution.
.EXAMPLE
New-NugetPackage @("--configuration:Release", "--warnaserror")
Calls "dotnet pack project.csproj --configuration:Release --warnaserror" on each project.
#>

param([array] $Arguments)

foreach ($project in (dotnet sln list | Select-Object -Skip 2 | Get-Item))
{
Push-Location $project.Directory

$nuspecFile = (Get-ChildItem *.nuspec).Name
if ($nuspecFile.Count -eq 1)
{
dotnet pack $project -p:NuspecFile="$nuspecFile" @Arguments
}
else
{
dotnet pack $project @Arguments
}

Pop-Location
}
22 changes: 18 additions & 4 deletions .github/actions/publish-nuget/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
description: >
Additional warning codes for the `-p:NoWarn=` argument of `dotnet pack`. The items can be
separated by any whitespace, including newlines.
dotnet-pack-include-symbols:
required: false
default: "true"
description: If set to "true", a symbol package will be created together with the NuGet package.
secrets:
API_KEY:
required: true
Expand Down Expand Up @@ -55,6 +59,11 @@ runs:
shell: pwsh
run: dotnet restore -p:NuGetBuild=true --verbosity ${{ inputs.verbosity }}

- name: Generate nuspec file if needed
if: hashFiles('ConvertTo-Nuspec.ps1')
shell: pwsh
run: ./ConvertTo-Nuspec.ps1 '${{ steps.setup.outputs.publish-version }}'

- name: Build
uses: Lombiq/GitHub-Actions/.github/actions/build-dotnet@dev
# Notes on the configuration:
Expand Down Expand Up @@ -82,6 +91,11 @@ runs:
-p:DebugSymbols=true
-p:DebugType=portable

- name: Actions prior to dotnet pack
if: hashFiles('Invoke-BeforePack.ps1')
shell: pwsh
run: ./Invoke-BeforePack.ps1

- name: Pack
shell: pwsh
# Notes on the configuration apart from what's also for dotnet build:
Expand All @@ -96,24 +110,24 @@ runs:
${{ inputs.dotnet-pack-ignore-warning }}
'@.Split() | ? { $_ }
0liver marked this conversation as resolved.
Show resolved Hide resolved

$arguments = @(
New-NuGetPackage @(
"--configuration:Release",
"--warnaserror",
"--no-restore",
"--no-build",
"--output:artifacts",
"--output:" + (Join-Path $PWD artifacts),
"--verbosity:${{ inputs.verbosity }}",
"-p:NuGetBuild=true",
"-p:Version=${{ steps.setup.outputs.publish-version }}",
"-p:NuspecProperties=version=${{ steps.setup.outputs.publish-version }}",
"-p:GenerateDocumentationFile=True",
"-p:NoWarn=$($noWarn -join '%3B')",
0liver marked this conversation as resolved.
Show resolved Hide resolved
"-p:TreatWarningsAsErrors=true",
"-p:WarnOnPackingNonPackableProject=True",
"-p:IncludeSymbols=true",
"-p:IncludeSymbols=${{ inputs.dotnet-pack-include-symbols }}",
"-p:SymbolPackageFormat=snupkg",
"-p:NoDefaultExcludes=true"
)
dotnet pack @arguments

- name: Push with dotnet
shell: pwsh
Expand Down
10 changes: 8 additions & 2 deletions .github/actions/verify-submodule-pull-request/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ runs:
New-Item -ItemType File -Force $Profile | Out-Null
Get-Content -Raw ${{ github.action_path }}/functions.ps1 >> $Profile

# We are using env for the title input in these steps because it realistically could contain quotes, apostrophes or
# even both. This way those don't need to be escaped.
- name: Ensure Current PR Title Includes Issue Code
shell: pwsh
run: Check-Current '${{ inputs.title }}'
env:
PR_TITLE: ${{ inputs.title }}
run: Check-Current $Env:PR_TITLE

- name: Ensure Parent Repository Contains Matching PR
shell: pwsh
run: Check-Parent '${{ inputs.repository }}' '${{ inputs.title }}'
env:
PR_TITLE: ${{ inputs.title }}
run: Check-Parent '${{ inputs.repository }}' $Env:PR_TITLE
8 changes: 7 additions & 1 deletion .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ on:
description: >
Additional warning codes for the `-p:NoWarn=` argument of `dotnet pack`. The items can be
separated by any whitespace, including newlines.
dotnet-pack-include-symbols:
required: false
type: string
default: "true"
description: If set to "true", a symbol package will be created together with the NuGet package.
secrets:
# We can't access org secrets here so they need to be passed in, see:
# https://github.521000.bestmunity/t/resuable-called-workflow-environment-variables-secrets-and-trigger-event-access/207723/2
Expand All @@ -56,10 +61,11 @@ jobs:
dotnet-version: ${{ inputs.dotnet-version }}

- name: Publish to NuGet
uses: Lombiq/GitHub-Actions/.github/actions/publish-nuget@dev
uses: Lombiq/GitHub-Actions/.github/actions/publish-nuget@issue/OSOE-110
with:
source: ${{ inputs.source }}
verbosity: ${{ inputs.verbosity }}
dotnet-pack-ignore-warning: ${{ inputs.dotnet-pack-ignore-warning }}
dotnet-pack-include-symbols: ${{ inputs.dotnet-pack-include-symbols }}
env:
API_KEY: ${{ secrets.API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/test-analysis-failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
uses: Lombiq/GitHub-Actions/.github/actions/enable-corepack@dev

- name: Build and Static Code Analysis
uses: Lombiq/GitHub-Actions/.github/actions/build-dotnet@dev
uses: Lombiq/GitHub-Actions/.github/actions/build-dotnet@issue/OSOE-110
0liver marked this conversation as resolved.
Show resolved Hide resolved
with:
directory: ${{ inputs.build-directory }}
verbosity: quiet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-submodule-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Ensure Parent PR Exists
uses: Lombiq/GitHub-Actions/.github/actions/verify-submodule-pull-request@dev
uses: Lombiq/GitHub-Actions/.github/actions/verify-submodule-pull-request@issue/OSOE-110
with:
title: ${{ github.event.pull_request.title }}