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-482: Enforce parameter splatting instead of backtick in Lombiq.Analyzers.PowerShell #120

Merged
merged 25 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5b29bfb
Automatically fixing PS analyzer violations
BenedekFarkas Nov 25, 2022
b500235
Windows PowerShell compatibility fixes and automatic styling fixes by…
BenedekFarkas Nov 25, 2022
bc7fd59
Merge remote-tracking branch 'origin/dev' into issue/OSOE-482
BenedekFarkas Nov 25, 2022
bd228aa
Merge remote-tracking branch 'origin/dev' into issue/OSOE-482
BenedekFarkas Nov 28, 2022
888945d
Merge remote-tracking branch 'origin/dev' into issue/OSOE-482
BenedekFarkas Nov 29, 2022
ad048d9
Merge branch 'dev' into issue/OSOE-482
BenedekFarkas Dec 18, 2022
04192b6
Fixing code stying and indentation in build-and-test-orchard-core wor…
BenedekFarkas Dec 18, 2022
f54f552
Updating action references to issue branch
BenedekFarkas Dec 18, 2022
e0736e2
Fixing indentation and code styling in Set-XUnitMaxParallelThreads.ps1
BenedekFarkas Dec 18, 2022
2533bcd
Reverting incorrectly auto-fixed ternary operators
BenedekFarkas Dec 18, 2022
998ceea
Simplifying dotnet test parameter list construction in Invoke-Solutio…
BenedekFarkas Dec 18, 2022
2b03c32
Reverting auto-fix to replace curl with Invoke-WebRequest in Check-Pa…
BenedekFarkas Dec 18, 2022
e7d774c
Fixing code formatting in AddJiraIssueCodeToPullRequest and removing …
BenedekFarkas Dec 18, 2022
e41fd14
Updating Check-Parent script to use Invoke-WebRequest instead of curl
BenedekFarkas Dec 19, 2022
d5237b9
Updating create-jira-issues-for-community-activities action to use In…
BenedekFarkas Dec 19, 2022
e5c2229
Updating action references to issue branch in workflows
BenedekFarkas Dec 19, 2022
c232f73
Fixing indentation in validate-submodule-pull-request workflow
BenedekFarkas Dec 19, 2022
66961df
Removing PS analyzer settings that allowed aliases according to compl…
BenedekFarkas Dec 19, 2022
0fc4b42
Merge branch 'dev' into issue/OSOE-482
BenedekFarkas Dec 20, 2022
9c456db
create-jira-issues-for-community-activities action: Updating the cons…
BenedekFarkas Dec 20, 2022
7a2f589
Updating create-jira-issues-for-community-activities to use the issue…
BenedekFarkas Dec 20, 2022
eec00a1
Updating "Add Remote Link to Jira Issue" step in create-jira-issues-f…
BenedekFarkas Dec 20, 2022
d2d99a4
Removing ProgressPreference override from Check-Parent.ps1, because G…
BenedekFarkas Dec 20, 2022
f0b061e
Reverting experimental/test change
BenedekFarkas Dec 20, 2022
fb77614
Updating workflow branch references to dev
BenedekFarkas Dec 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ param(
[string] $JiraBaseUrl,
[string] $GitHubRepository,
[string] $Branch,
[string] $GitHubToken,
[string] $Title,
[string] $Body,
[string] $PullRequestId
Expand All @@ -13,30 +12,36 @@ $jiraBrowseUrl = $JiraBaseUrl + '/browse/';
$originalTitle = $Title
$originalBody = $Body

if ($Branch -NotLike "*issue*") {
if ($Branch -NotLike "*issue*")
{
Exit
}

$Branch -match '(\w+-\d+)'
$issueKey = $matches[0]
$issueLink = "[$issueKey]($jiraBrowseUrl$issuekey)"

if ($Title -NotLike "*$issueKey*") {
if ($Title -NotLike "*$issueKey*")
{
$Title = $issueKey + ": " + $Title
}

if (-Not $Body) {
if (-Not $Body)
{
$Body = $issueLink
}
elseif ($Body -NotLike "*$issueKey*") {
elseif ($Body -NotLike "*$issueKey*")
{
$Body = $issueLink + "`n" + $Body
}
elseif ($Body -NotLike "*``[$issueKey``]``($jiraBrowseUrl$issuekey``)*") {
elseif ($Body -NotLike "*``[$issueKey``]``($jiraBrowseUrl$issuekey``)*")
{
$Body = $Body.replace($issueKey, $issueLink)
}

if (($Title -ne $originalTitle) -or ($Body -ne $originalBody)) {
$bodyParams = @{"title" = $Title; "body" = $Body} | ConvertTo-Json
if (($Title -ne $originalTitle) -or ($Body -ne $originalBody))
{
$bodyParams = @{"title" = $Title; "body" = $Body } | ConvertTo-Json
$url = "https://api.github.com/repos/$GitHubRepository/pulls/$PullRequestId"
Invoke-WebRequest $url -Headers (Get-GitHubApiAuthorizationHeader) -Method Patch -Body $bodyParams
}
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param (
param (
[string] $Configuration,
[string] $SolutionOrProject,
[string] $Verbosity,
Expand Down Expand Up @@ -111,7 +111,8 @@ if ($expectedErrorCodes)
}
}

if ($fail -gt 0) {
if ($fail -gt 0)
{
Write-Warning $report.ToString() # We use warning so it doesn't stop prematurely.
Write-Output ("::error::Verification Mismatch " + ($errorLines -join " "))
exit 1
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-dotnet/Write-CacheConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function Invoke-Maybe($Block) { try { Invoke-Command -ScriptBlock $Block } catch

$paths = @()

if ($IsNuget) { $paths += ,'~/.nuget/packages' }
if ($IsNuget) { $paths += , '~/.nuget/packages' }

if ($IsNpm)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param
param
(
$GitHub,
$IssueComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if ([string]::IsNullOrEmpty($Env:DISCUSSION_JIRA_ISSUE_DESCRIPTION))
{
$templates["DISCUSSION_JIRA_ISSUE_DESCRIPTION"] = @"
$templates["DISCUSSION_JIRA_ISSUE_DESCRIPTION"] = @"
h1. Summary
See the linked GitHub discussion, including all the comments. Please do all communication there, unless it's confidential or administrative.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ inputs:
required: false
default: "true"
description: >
If set to "true", Jira issue titles will be suffixed with "in <issue-component>" if the issue-component
parameter is specified, or the repository name. If set to "false", no suffix will be added to Jira issue titles.
If set to "true", Jira issue titles will be suffixed with "in <issue-component>" if the issue-component
parameter is specified, or the repository name. If set to "false", no suffix will be added to Jira issue titles.
Piedone marked this conversation as resolved.
Show resolved Hide resolved

runs:
using: "composite"
Expand Down Expand Up @@ -100,21 +100,25 @@ runs:
if: steps.issue-related-pr.outputs.is-issue-pr == 'False'
shell: pwsh
run: |
# Note that while --fail will fail the command if the request fails, it won't show the server output. Thus,
# remove for debugging. --fail-with-body provides that too, but is only available under curl >=7.76.0 which is
# not yet available for GitHub Actions, see https://github.com/Lombiq/GitHub-Actions/issues/53.
curl --request POST `
--url '${{ env.JIRA_BASE_URL }}/rest/api/3/issue/${{ steps.create-issue.outputs.issue }}/remotelink' `
--user '${{ env.JIRA_USER_EMAIL }}:${{ env.JIRA_API_TOKEN }}' `
--header 'Accept: application/json' `
--header 'Content-Type: application/json' `
--fail `
--data '{
\"object\": {
\"url\":\"${{ steps.issue-details.outputs.link-url }}\",
\"title\":\"${{ steps.issue-details.outputs.link-title }}\"
}
}'
$linkProperties = @{
Piedone marked this conversation as resolved.
Show resolved Hide resolved
object = @{
url = '${{ steps.issue-details.outputs.link-url }}'
title = '${{ steps.issue-details.outputs.link-title }}'
}
}
$requestParameters = @{
Uri = '${{ env.JIRA_BASE_URL }}/rest/api/3/issue/${{ steps.create-issue.outputs.issue }}/remotelink'
Method = 'POST'
ContentType = 'application/json'
Headers = @{
Accept = 'application/json'
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('${{ env.JIRA_USER_EMAIL }}:${{ env.JIRA_API_TOKEN }}'))
Piedone marked this conversation as resolved.
Show resolved Hide resolved
ContentType = 'application/json'
}
Body = ConvertTo-Json($linkProperties)
}

Invoke-WebRequest @requestParameters
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Piedone marked this conversation as resolved.
Show resolved Hide resolved

- name: Update GitHub Issue
if: steps.issue-related-pr.outputs.is-issue-pr == 'False' && github.event.issue
Expand All @@ -126,4 +130,4 @@ runs:
issue-number: ${{ github.event.issue.number }}
title: ${{ github.event.issue.title }} (${{ steps.create-issue.outputs.issue }})
body: "${{ github.event.issue.body }}\n\n[Jira issue](${{ env.JIRA_BASE_URL }}/browse/${{ steps.create-issue.outputs.issue }})"
update-mode: 'replace'
update-mode: "replace"
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param (
param (
[string] $SolutionOrProject,
[string] $Verbosity,
[string] $TreatWarningsAsErrors,
Expand Down Expand Up @@ -68,7 +68,7 @@ msbuild $SolutionOrProject @buildSwitches

# error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 were not found. To resolve this, install the
# Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET
# Framework Developer Packs at https://aka.ms/msbuild/developerpacks
# Framework Developer Packs at https://aka.ms/msbuild/developerpacks

if ($?)
{
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/publish-nuget/Update-ManifestVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ $manifests = Get-ChildItem $WorkDir -File -Recurse -Filter "Manifest.cs" |
Select-String -List -Pattern '(OrchardCore.Modules.Manifest|OrchardCore.DisplayManagement.Manifest)' |
Select-Object -ExpandProperty Path

foreach ($manifest in $manifests) {
foreach ($manifest in $manifests)
{
Piedone marked this conversation as resolved.
Show resolved Hide resolved
$regex = '(?<head>\[assembly:\s*(Module|Theme)\(([^\]]*Version\W*=\W*"))([^"]*)', "`${head}$PackageVersion"
(Get-Content -Raw $manifest) -replace $regex | Out-File $manifest

Expand Down
6 changes: 3 additions & 3 deletions .github/actions/test-dotnet/Invoke-SolutionTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Set-GitHubOutput "test-count" $tests.Length

Write-Output "Starting to execute tests from $($tests.Length) projects."

foreach ($test in $tests) {
foreach ($test in $tests)
{
# This could benefit from grouping, above the level of the potential groups created by the tests (the Lombiq UI
# Testing Toolbox adds per-test groups too). However, there's no nested grouping, see
# https://github.com/actions/runner/issues/1477. See the # c341ef145d2a0898c5900f64604b67b21d2ea5db commit for a
Expand All @@ -62,8 +63,7 @@ foreach ($test in $tests) {
# This is for xUnit ITestOutputHelper, see https://xunit.net/docs/capturing-output.
'--logger', 'console;verbosity=detailed'
'--verbosity', $Verbosity
$Filter ? '--filter' : ''
$Filter ? $Filter : ''
$Filter ? '--filter', $Filter : ''
$test
)

Expand Down
20 changes: 10 additions & 10 deletions .github/actions/test-dotnet/Set-XUnitMaxParallelThreads.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
param (
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
$MaxParallelThreads
)

Write-Output "Setting maxParallelThreads in xunit.runner.json files to $MaxParallelThreads."

$parameters = @{
# -Filter is the fastest way to find files because its value is passed directly to the file system API.
Filter = "xunit.runner.json"
Recurse = $true
# -FollowSymLink is needed because without it errors will be thrown of type:
# "Get-ChildItem: The system cannot find the path specified."
FollowSymlink = $true
# Ignore warnings that will be printed due to multiple symlinks pointing to the same physical file.
WarningAction = "Ignore"
# -Filter is the fastest way to find files because its value is passed directly to the file system API.
Filter = "xunit.runner.json"
Recurse = $true
# -FollowSymLink is needed because without it errors will be thrown of type:
# "Get-ChildItem: The system cannot find the path specified."
FollowSymlink = $true
# Ignore warnings that will be printed due to multiple symlinks pointing to the same physical file.
WarningAction = "Ignore"
}

$configFiles = Get-ChildItem @parameters
Expand All @@ -27,7 +27,7 @@ $configFiles | ForEach-Object {
}
else
{
$json | Add-Member -Name 'maxParallelThreads' -value $MaxParallelThreads -MemberType NoteProperty
$json | Add-Member -Name 'maxParallelThreads' -Value $MaxParallelThreads -MemberType NoteProperty
}

ConvertTo-Json -InputObject $json > $PSItem
Expand Down
11 changes: 8 additions & 3 deletions .github/actions/verify-submodule-pull-request/Check-Parent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
[string] $Branch
)

$url = "https://api.github.com/repos/$Repository/pulls?state=open&per_page=100"
$titles = curl -s -H 'Accept: application/vnd.github.v3+json' $url | ConvertFrom-Json | ForEach-Object { $PSItem.title }
$ProgressPreference = "SilentlyContinue"
Piedone marked this conversation as resolved.
Show resolved Hide resolved
$requestParameters = @{
Uri = "https://api.github.com/repos/$Repository/pulls?state=open&per_page=100"
Method = "Get"
Headers = @{ Accept = "application/vnd.github.v3+json" }
}
$titles = (Invoke-WebRequest @requestParameters).Content | ConvertFrom-Json | ForEach-Object { $PSItem.title }
Piedone marked this conversation as resolved.
Show resolved Hide resolved

if (!($Branch -match '(\w+-\d+)'))
{
Exit
exit
}

$issueCode = $matches[0]
Expand Down
Loading