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

fix: updater SSH repos nonbot commits #62

Merged
merged 3 commits into from
Nov 27, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Updater - non-bot commit checks in PRs for SSH repository URLs (starting with `[email protected]:`) ([#62](https://github.com/getsentry/github-workflows/pull/62))

### Features

- Sentry-CLI integration test action: support envelopes ([#58](https://github.com/getsentry/github-workflows/pull/58))
Expand Down
8 changes: 5 additions & 3 deletions updater/scripts/nonbot-commits.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ param(
)

Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"
$ErrorActionPreference = 'Stop'

$bot = "<[email protected]>"
$RepoUrl = $RepoUrl -replace '[email protected]:', 'https://github.com/'
$bot = '<[email protected]>'

$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
New-Item -ItemType Directory $tmpDir | Out-Null
Expand All @@ -29,7 +30,8 @@ try

if ($nonbotCommits.Length -gt 0)
{
Write-Warning "There are commits made by others than $bot"
`
Write-Warning "There are commits made by others than $bot"
}
$nonbotCommits
}
Expand Down
48 changes: 25 additions & 23 deletions updater/tests/nonbot-commits.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,34 @@ Set-StrictMode -Version latest

. "$PSScriptRoot/common/test-utils.ps1"

function NonBotCommits([Parameter(Mandatory = $true)][string] $branch)
foreach ($repoUrl in @('https://github.com/getsentry/github-workflows', '[email protected]:getsentry/github-workflows.git'))
{
$result = & "$PSScriptRoot/../scripts/nonbot-commits.ps1" `
-RepoUrl 'https://github.com/getsentry/github-workflows' -MainBranch 'main' -PrBranch $branch
if (-not $?)
function NonBotCommits([Parameter(Mandatory = $true)][string] $branch)
{
throw $result
$result = & "$PSScriptRoot/../scripts/nonbot-commits.ps1" -RepoUrl $repoUrl -MainBranch 'main' -PrBranch $branch
if (-not $?)
{
throw $result
}
elseif ($LASTEXITCODE -ne 0)
{
throw "Script finished with exit code $LASTEXITCODE"
}
$result
}
elseif ($LASTEXITCODE -ne 0)
{
throw "Script finished with exit code $LASTEXITCODE"
}
$result
}

RunTest 'empty-if-all-commits-by-bot' {
$commits = NonBotCommits 'deps/updater/tests/sentry-cli.properties'
AssertEqual '' "$commits"
}
RunTest 'empty-if-all-commits-by-bot' {
$commits = NonBotCommits 'deps/updater/tests/sentry-cli.properties'
AssertEqual '' "$commits"
}

RunTest 'empty-if-branch-doesnt-exist' {
$commits = NonBotCommits 'non-existent-branch'
AssertEqual '' "$commits"
}
RunTest 'empty-if-branch-doesnt-exist' {
$commits = NonBotCommits 'non-existent-branch'
AssertEqual '' "$commits"
}

RunTest 'non-empty-if-changed' {
$commits = NonBotCommits 'test/nonbot-commits'
AssertEqual '0b7d9cc test: keep this branch' "$commits"
}
RunTest 'non-empty-if-changed' {
$commits = NonBotCommits 'test/nonbot-commits'
AssertEqual '0b7d9cc test: keep this branch' "$commits"
}
}
Loading