From 15bc19ed4c07bce16a2606ba5e9af411306c8347 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 14 Nov 2022 14:32:14 +0100 Subject: [PATCH 1/6] test: improve test scripts & test on all supported platforms --- .github/workflows/updater-scripts-tests.yml | 10 ++- updater/scripts/update-dependency.ps1 | 35 ++++++-- updater/tests/common/test-utils.ps1 | 20 ++++- updater/tests/sort-versions.ps1 | 8 +- updater/tests/update-dependency.ps1 | 95 +++++++++++++++++++-- 5 files changed, 147 insertions(+), 21 deletions(-) diff --git a/.github/workflows/updater-scripts-tests.yml b/.github/workflows/updater-scripts-tests.yml index 854751a..8bb94e2 100644 --- a/.github/workflows/updater-scripts-tests.yml +++ b/.github/workflows/updater-scripts-tests.yml @@ -6,7 +6,15 @@ on: jobs: test: - runs-on: ubuntu-latest + name: ${{ matrix.host }} + runs-on: ${{ matrix.host }}-latest + strategy: + fail-fast: false + matrix: + host: + - ubuntu + - macos + - windows steps: - uses: actions/checkout@v3 - run: make test diff --git a/updater/scripts/update-dependency.ps1 b/updater/scripts/update-dependency.ps1 index 1080249..30858d9 100644 --- a/updater/scripts/update-dependency.ps1 +++ b/updater/scripts/update-dependency.ps1 @@ -23,6 +23,18 @@ if (-not (Test-Path $Path )) # If it's a directory, we consider it a submodule dependendency. Otherwise, it must a properties-style file or a script. $isSubmodule = (Test-Path $Path -PathType Container) +function SetOutput([string] $name, $value) +{ + if (Test-Path env:GITHUB_OUTPUT) + { + "$name=$value" | Tee-Object $env:GITHUB_OUTPUT -Append + } + else + { + "$name=$value" + } +} + if (-not $isSubmodule) { $isScript = $Path -match '\.(ps1|sh)$' @@ -34,8 +46,17 @@ if (-not $isSubmodule) { chmod +x $Path } - $result = & $Path $action $value - if (-not $?) + try + { + $result = & $Path $action $value + $failed = -not $? + } + catch + { + $result = $_ + $failed = $true + } + if ($failed) { throw "Script execution failed: $Path $action $value | output: $result" } @@ -133,11 +154,11 @@ if ("$Tag" -eq "") $latestTag = $tags[-1] $latestTagNice = ($latestTag -match "^[0-9]") ? "v$latestTag" : $latestTag - "originalTag=$originalTag" | Tee-Object $env:GITHUB_OUTPUT -Append - "latestTag=$latestTag" | Tee-Object $env:GITHUB_OUTPUT -Append - "latestTagNice=$latestTagNice" | Tee-Object $env:GITHUB_OUTPUT -Append - "url=$url" | Tee-Object $env:GITHUB_OUTPUT -Append - "mainBranch=$mainBranch" | Tee-Object $env:GITHUB_OUTPUT -Append + SetOutput "originalTag" $originalTag + SetOutput "latestTag" $latestTag + SetOutput "latestTagNice" $latestTagNice + SetOutput "url" $url + SetOutput "mainBranch" $mainBranch if ("$originalTag" -eq "$latestTag") { diff --git a/updater/tests/common/test-utils.ps1 b/updater/tests/common/test-utils.ps1 index 1e5f507..622e280 100644 --- a/updater/tests/common/test-utils.ps1 +++ b/updater/tests/common/test-utils.ps1 @@ -1,5 +1,10 @@ -function RunTest ([string] $name, [ScriptBlock] $code) +function RunTest ([string] $name, [ScriptBlock] $code, [string] $skipReason = "") { + if ($skipReason -ne "") + { + Write-Warning "Test $name - skipped $skipReason" + return + } try { Write-Host "Test $name - starting" -ForegroundColor Yellow @@ -31,6 +36,19 @@ function AssertEqual([string] $expected, [string] $actual) throw "AssertEqual failed" } } + +function AssertContains([string[]] $list, [string] $value) +{ + if (-not ($list -contains $value)) + { + Write-Host "Expected list to contain '$value':" -ForegroundColor Red + Write-Host "========================================" + Write-Host $list + Write-Host "========================================" + throw "AssertContains failed" + } +} + function AssertFailsWith([string] $substring, [scriptblock] $block) { $e = $null diff --git a/updater/tests/sort-versions.ps1 b/updater/tests/sort-versions.ps1 index 002ab49..e71334e 100644 --- a/updater/tests/sort-versions.ps1 +++ b/updater/tests/sort-versions.ps1 @@ -2,7 +2,7 @@ Set-StrictMode -Version latest . "$PSScriptRoot/common/test-utils.ps1" -function Sort([Parameter(Mandatory = $true)][string[]] $List) +function SortVersions([Parameter(Mandatory = $true)][string[]] $List) { $result = & "$PSScriptRoot/../scripts/sort-versions.ps1" $List if (-not $?) @@ -13,17 +13,17 @@ function Sort([Parameter(Mandatory = $true)][string[]] $List) } RunTest "sort standard versions" { - $sorted = Sort @('3.0.0', '5.4.11', 'v1.2.3', '5.4.1') + $sorted = SortVersions @('3.0.0', '5.4.11', 'v1.2.3', '5.4.1') AssertEqual @('v1.2.3', '3.0.0', '5.4.1', '5.4.11') $sorted } RunTest "sort standard versions v2" { - $sorted = Sort @('3.0.0', 'v6.0', '5.4.11', '5.5', 'v1.2.3', '5.4.1') + $sorted = SortVersions @('3.0.0', 'v6.0', '5.4.11', '5.5', 'v1.2.3', '5.4.1') AssertEqual @('v1.2.3', '3.0.0', '5.4.1', '5.4.11', '5.5', 'v6.0') $sorted } # TODO, currently doesn't respect (order) stuff like RC, Beta, etc. # RunTest "sort with pre-releases" { -# $sorted = Sort @('3.0.0', '5.4.11', 'v1.2.3', '5.4.1', '5.4.11-rc.0') +# $sorted = SortVersions @('3.0.0', '5.4.11', 'v1.2.3', '5.4.1', '5.4.11-rc.0') # AssertEqual @('v1.2.3', '3.0.0', '5.4.1', '5.4.11-rc.0', '5.4.11') $sorted # } diff --git a/updater/tests/update-dependency.ps1 b/updater/tests/update-dependency.ps1 index 19b0707..f395825 100644 --- a/updater/tests/update-dependency.ps1 +++ b/updater/tests/update-dependency.ps1 @@ -9,6 +9,7 @@ function UpdateDependency([Parameter(Mandatory = $true)][string] $path, [string] { throw $result } + $result } $testDir = "$PSScriptRoot/testdata/dependencies" @@ -39,6 +40,47 @@ RunTest "version pattern match" { AssertEqual @("repo=$repo", "version=0.28.0") (Get-Content $testFile) } +function _testOutput([string[]] $output) +{ + AssertContains $output 'originalTag=0' + AssertContains $output 'originalTag=0' + AssertContains $output 'latestTag=0.28.0' + AssertContains $output 'latestTagNice=v0.28.0' + AssertContains $output 'url=https://github.com/getsentry/sentry-cli' + AssertContains $output 'mainBranch=master' +} + +RunTest "writes output" { + $testFile = "$testDir/test.properties" + $repo = 'https://github.com/getsentry/sentry-cli' + @("repo=$repo", "version=0") | Out-File $testFile + $stdout = UpdateDependency $testFile '^0\.' + _testOutput $stdout +} + +RunTest "writes to env:GITHUB_OUTPUT" { + $testFile = "$testDir/test.properties" + $repo = 'https://github.com/getsentry/sentry-cli' + @("repo=$repo", "version=0") | Out-File $testFile + $outFile = "$testDir/outfile" + New-Item $outFile -ItemType File + try + { + $env:GITHUB_OUTPUT = $outFile + $stdout = UpdateDependency $testFile '^0\.' + Write-Host "Testing standard output" + _testOutput $stdout + Write-Host "Testing env:GITHUB_OUTPUT" + _testOutput (Get-Content $outFile) + } + finally + { + # Delete the file and unser the env variable + Remove-Item $outFile + Remove-Item env:GITHUB_OUTPUT + } +} + # Note: without custom sorting, this would have yielded 'v1.7.31_gradle_plugin' RunTest "version sorting must work properly" { $testFile = "$testDir/test.properties" @@ -95,9 +137,18 @@ esac '@ | Out-File $testScript UpdateDependency $testScript AssertEqual $currentVersion (Get-Content $testFile) +} -skipReason ($IsWindows ? "on Windows" : '') + +RunTest "powershell-script fails in get-version" { + $testScript = "$testDir/test.ps1" + @' +throw "Failure" +'@ | Out-File $testScript + + AssertFailsWith "get-version | output: Failure" { UpdateDependency $testScript } } -RunTest "script fails in get-version" { +RunTest "bash-script fails in get-version" { $testScript = "$testDir/test.sh" @' #!/usr/bin/env bash @@ -106,9 +157,22 @@ exit 1 '@ | Out-File $testScript AssertFailsWith "get-version | output: Failure" { UpdateDependency $testScript } +} -skipReason ($IsWindows ? "on Windows" : '') + +RunTest "powershell-script fails in get-repo" { + $testScript = "$testDir/test.ps1" + @' +param([string] $action, [string] $value) +if ($action -eq "get-repo") +{ + throw "Failure" +} +'@ | Out-File $testScript + + AssertFailsWith "get-repo | output: Failure" { UpdateDependency $testScript } } -RunTest "script fails in get-repo" { +RunTest "bash-script fails in get-repo" { $testScript = "$testDir/test.sh" @' #!/usr/bin/env bash @@ -118,23 +182,38 @@ get-version) get-repo) echo "Failure" exit 1 - ;; +;; esac '@ | Out-File $testScript AssertFailsWith "get-repo | output: Failure" { UpdateDependency $testScript } +} -skipReason ($IsWindows ? "on Windows" : '') + +RunTest "powershell-script fails in set-version" { + $testScript = "$testDir/test.ps1" + @' +param([string] $action, [string] $value) +switch ($action) +{ + "get-version" { '' } + "get-repo" { +'@ + '"' + $repoUrl + '"' + @' + } + "set-version" { throw "Failure" } +} +'@ | Out-File $testScript + + AssertFailsWith "set-version $currentVersion | output: Failure" { UpdateDependency $testScript } } -RunTest "script fails in set-version" { - $testFile = "$testDir/test.version" - '' | Out-File $testFile +RunTest "bash-script fails in set-version" { $testScript = "$testDir/test.sh" @' #!/usr/bin/env bash cd $(dirname "$0") case $1 in get-version) - cat test.version + echo "" ;; get-repo) echo @@ -148,4 +227,4 @@ esac '@ | Out-File $testScript AssertFailsWith "set-version $currentVersion | output: Failure" { UpdateDependency $testScript } -} \ No newline at end of file +} -skipReason ($IsWindows ? "on Windows" : '') \ No newline at end of file From ab633452407a12398d2581b20acdd5321f5a3bd4 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 14 Nov 2022 14:39:55 +0100 Subject: [PATCH 2/6] chore: gitattributes --- .gitattributes | 1 + updater/scripts/get-changelog.ps1 | 188 ++++++------- updater/scripts/set-github-env.ps1 | 24 +- updater/scripts/update-changelog.ps1 | 320 +++++++++++------------ updater/scripts/update-dependency.ps1 | 362 +++++++++++++------------- updater/tests/sentry-cli.properties | 4 +- 6 files changed, 450 insertions(+), 449 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d01653a --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +text eol=lf diff --git a/updater/scripts/get-changelog.ps1 b/updater/scripts/get-changelog.ps1 index a17b25f..1a2253a 100644 --- a/updater/scripts/get-changelog.ps1 +++ b/updater/scripts/get-changelog.ps1 @@ -1,94 +1,94 @@ -param( - [Parameter(Mandatory = $true)][string] $RepoUrl, - [Parameter(Mandatory = $true)][string] $OldTag, - [Parameter(Mandatory = $true)][string] $NewTag -) - -Set-StrictMode -Version latest - -$prefix = 'https?://(www\.)?github.com/' -if (-not ($RepoUrl -match "^$prefix")) -{ - Write-Warning "Only github.com repositories are currently supported. Given RepoUrl doesn't look like one: $RepoUrl" - return -} - -$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid()) - -try -{ - git clone --depth 1 $RepoUrl $tmpDir - - $file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } ) - if ("$file" -eq "") - { - Write-Warning "Couldn't find a changelog" - return - } - elseif ($file -is [Array]) - { - Write-Warning "Multiple changelogs found: $file" - return - } - Write-Host "Found changelog: $file" - [string[]]$lines = Get-Content $file -} -finally -{ - Write-Host "Removing $tmpDir" - Remove-Item -Recurse -Force -ErrorAction Continue -Path $tmpDir -} - -$foundFirst = $false -$changelog = "" -for ($i = 0; $i -lt $lines.Count; $i++) -{ - $line = $lines[$i] - - if (-not $foundFirst) - { - if ($line -match "^#+ +v?$NewTag\b") - { - $foundFirst = $true - } - else - { - continue - } - } - elseif ($line -match "^#+ +v?$OldTag\b") - { - break - } - - $changelog += "$line`n" -} - -$changelog = $changelog.Trim() -if ($changelog.Length -gt 1) -{ - $changelog = "# Changelog`n$changelog" - # Increase header level by one. - $changelog = $changelog -replace "(#+) ", '$1# ' - # Remove at-mentions. - $changelog = $changelog -replace '@', '' - # Make PR/issue references into links to the original repository (unless they already are links). - $changelog = $changelog -replace '(? :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**" -} - -$changelog +param( + [Parameter(Mandatory = $true)][string] $RepoUrl, + [Parameter(Mandatory = $true)][string] $OldTag, + [Parameter(Mandatory = $true)][string] $NewTag +) + +Set-StrictMode -Version latest + +$prefix = 'https?://(www\.)?github.com/' +if (-not ($RepoUrl -match "^$prefix")) +{ + Write-Warning "Only github.com repositories are currently supported. Given RepoUrl doesn't look like one: $RepoUrl" + return +} + +$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid()) + +try +{ + git clone --depth 1 $RepoUrl $tmpDir + + $file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } ) + if ("$file" -eq "") + { + Write-Warning "Couldn't find a changelog" + return + } + elseif ($file -is [Array]) + { + Write-Warning "Multiple changelogs found: $file" + return + } + Write-Host "Found changelog: $file" + [string[]]$lines = Get-Content $file +} +finally +{ + Write-Host "Removing $tmpDir" + Remove-Item -Recurse -Force -ErrorAction Continue -Path $tmpDir +} + +$foundFirst = $false +$changelog = "" +for ($i = 0; $i -lt $lines.Count; $i++) +{ + $line = $lines[$i] + + if (-not $foundFirst) + { + if ($line -match "^#+ +v?$NewTag\b") + { + $foundFirst = $true + } + else + { + continue + } + } + elseif ($line -match "^#+ +v?$OldTag\b") + { + break + } + + $changelog += "$line`n" +} + +$changelog = $changelog.Trim() +if ($changelog.Length -gt 1) +{ + $changelog = "# Changelog`n$changelog" + # Increase header level by one. + $changelog = $changelog -replace "(#+) ", '$1# ' + # Remove at-mentions. + $changelog = $changelog -replace '@', '' + # Make PR/issue references into links to the original repository (unless they already are links). + $changelog = $changelog -replace '(? :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**" +} + +$changelog diff --git a/updater/scripts/set-github-env.ps1 b/updater/scripts/set-github-env.ps1 index 4e21187..0775a66 100644 --- a/updater/scripts/set-github-env.ps1 +++ b/updater/scripts/set-github-env.ps1 @@ -1,12 +1,12 @@ -param( - [Parameter(Mandatory = $true)][string] $Name, - [string] $Data = '' -) - -Set-StrictMode -Version latest - -if ($null -eq $env:GITHUB_ENV) { - throw "GITHUB_ENV environment variable is missing - this script is supposed to be run in GitHub-Actions." -} - -Write-Output "$Name<version *= *).*$", "`${prop}$value" - $content | Out-File $Path - - $readVersion = (Get-Content $Path -Raw | ConvertFrom-StringData).version - - if ("$readVersion" -ne "$value") - { - throw "Update failed - read-after-write yielded '$readVersion' instead of expected '$value'" - } - } - Default - { - throw "Unknown action $action" - } - } - } - } -} - -if ("$Tag" -eq "") -{ - if ($isSubmodule) - { - git submodule update --init --no-fetch --single-branch $Path - Push-Location $Path - try - { - $originalTag = $(git describe --tags) - git fetch --tags - [string[]]$tags = $(git tag --list) - $url = $(git remote get-url origin) - $mainBranch = $(git remote show origin | Select-String "HEAD branch: (.*)").Matches[0].Groups[1].Value - } - finally - { - Pop-Location - } - } - else - { - $originalTag = DependencyConfig 'get-version' - $url = DependencyConfig 'get-repo' - - # Get tags for a repo without cloning. - [string[]]$tags = $(git ls-remote --refs --tags $url) - $tags = $tags | ForEach-Object { ($_ -split "\s+")[1] -replace '^refs/tags/', '' } - - $headRef = ($(git ls-remote $url HEAD) -split "\s+")[0] - if ("$headRef" -eq '') - { - throw "Couldn't determine repository head (no ref returned by ls-remote HEAD" - } - $mainBranch = (git ls-remote --heads $url | Where-Object { $_.StartsWith($headRef) }) -replace '.*\srefs/heads/', '' - } - - $url = $url -replace '\.git$', '' - - if ("$Pattern" -eq '') - { - # Use a default pattern that excludes pre-releases - $Pattern = '^v?([0-9.]+)$' - } - - Write-Host "Filtering tags with pattern '$Pattern'" - $tags = $tags -match $Pattern - - if ($tags.Length -le 0) - { - throw "Found no tags matching pattern '$Pattern'" - } - - $tags = & "$PSScriptRoot/sort-versions.ps1" $tags - - Write-Host "Sorted tags: $tags" - $latestTag = $tags[-1] - $latestTagNice = ($latestTag -match "^[0-9]") ? "v$latestTag" : $latestTag - - SetOutput "originalTag" $originalTag - SetOutput "latestTag" $latestTag - SetOutput "latestTagNice" $latestTagNice - SetOutput "url" $url - SetOutput "mainBranch" $mainBranch - - if ("$originalTag" -eq "$latestTag") - { - return - } - $Tag = $latestTag -} - -if ($isSubmodule) -{ - Write-Host "Updating submodule $Path to $Tag" - Push-Location $Path - git checkout $Tag - Pop-Location -} -else -{ - Write-Host "Updating 'version' in $Path to $Tag" - DependencyConfig 'set-version' $tag -} +param( + # Path to the dependency, which can be either of the following: + # - a submodule + # - a [.properties](https://en.wikipedia.org/wiki/.properties) file with `version` (e.g. 1.0.0) and `repo` (e.g. https://github.com/getsentry/dependency) + # - a script (.sh, .ps1) that takes the executes a given action based on a given argument: + # * `get-version` - return the currently specified dependency version + # * `get-repo` - return the repository url (e.g. https://github.com/getsentry/dependency) + # * `set-version` - update the dependency version (passed as another string argument after this one) + [Parameter(Mandatory = $true)][string] $Path, + # RegEx pattern that will be matched against available versions when picking the latest one + [string] $Pattern = '', + # Specific version - if passed, no discovery is performed and the version is set directly + [string] $Tag = '' +) + +Set-StrictMode -Version latest + +if (-not (Test-Path $Path )) +{ + throw "Dependency $Path doesn't exit"; +} + +# If it's a directory, we consider it a submodule dependendency. Otherwise, it must a properties-style file or a script. +$isSubmodule = (Test-Path $Path -PathType Container) + +function SetOutput([string] $name, $value) +{ + if (Test-Path env:GITHUB_OUTPUT) + { + "$name=$value" | Tee-Object $env:GITHUB_OUTPUT -Append + } + else + { + "$name=$value" + } +} + +if (-not $isSubmodule) +{ + $isScript = $Path -match '\.(ps1|sh)$' + function DependencyConfig ([Parameter(Mandatory = $true)][string] $action, [string] $value = $null) + { + if ($isScript) + { + if (Get-Command 'chmod' -ErrorAction SilentlyContinue) + { + chmod +x $Path + } + try + { + $result = & $Path $action $value + $failed = -not $? + } + catch + { + $result = $_ + $failed = $true + } + if ($failed) + { + throw "Script execution failed: $Path $action $value | output: $result" + } + return $result + } + else + { + switch ($action) + { + "get-version" + { + return (Get-Content $Path -Raw | ConvertFrom-StringData).version + } + "get-repo" + { + return (Get-Content $Path -Raw | ConvertFrom-StringData).repo + } + "set-version" + { + $content = Get-Content $Path + $content = $content -replace "^(?version *= *).*$", "`${prop}$value" + $content | Out-File $Path + + $readVersion = (Get-Content $Path -Raw | ConvertFrom-StringData).version + + if ("$readVersion" -ne "$value") + { + throw "Update failed - read-after-write yielded '$readVersion' instead of expected '$value'" + } + } + Default + { + throw "Unknown action $action" + } + } + } + } +} + +if ("$Tag" -eq "") +{ + if ($isSubmodule) + { + git submodule update --init --no-fetch --single-branch $Path + Push-Location $Path + try + { + $originalTag = $(git describe --tags) + git fetch --tags + [string[]]$tags = $(git tag --list) + $url = $(git remote get-url origin) + $mainBranch = $(git remote show origin | Select-String "HEAD branch: (.*)").Matches[0].Groups[1].Value + } + finally + { + Pop-Location + } + } + else + { + $originalTag = DependencyConfig 'get-version' + $url = DependencyConfig 'get-repo' + + # Get tags for a repo without cloning. + [string[]]$tags = $(git ls-remote --refs --tags $url) + $tags = $tags | ForEach-Object { ($_ -split "\s+")[1] -replace '^refs/tags/', '' } + + $headRef = ($(git ls-remote $url HEAD) -split "\s+")[0] + if ("$headRef" -eq '') + { + throw "Couldn't determine repository head (no ref returned by ls-remote HEAD" + } + $mainBranch = (git ls-remote --heads $url | Where-Object { $_.StartsWith($headRef) }) -replace '.*\srefs/heads/', '' + } + + $url = $url -replace '\.git$', '' + + if ("$Pattern" -eq '') + { + # Use a default pattern that excludes pre-releases + $Pattern = '^v?([0-9.]+)$' + } + + Write-Host "Filtering tags with pattern '$Pattern'" + $tags = $tags -match $Pattern + + if ($tags.Length -le 0) + { + throw "Found no tags matching pattern '$Pattern'" + } + + $tags = & "$PSScriptRoot/sort-versions.ps1" $tags + + Write-Host "Sorted tags: $tags" + $latestTag = $tags[-1] + $latestTagNice = ($latestTag -match "^[0-9]") ? "v$latestTag" : $latestTag + + SetOutput "originalTag" $originalTag + SetOutput "latestTag" $latestTag + SetOutput "latestTagNice" $latestTagNice + SetOutput "url" $url + SetOutput "mainBranch" $mainBranch + + if ("$originalTag" -eq "$latestTag") + { + return + } + $Tag = $latestTag +} + +if ($isSubmodule) +{ + Write-Host "Updating submodule $Path to $Tag" + Push-Location $Path + git checkout $Tag + Pop-Location +} +else +{ + Write-Host "Updating 'version' in $Path to $Tag" + DependencyConfig 'set-version' $tag +} diff --git a/updater/tests/sentry-cli.properties b/updater/tests/sentry-cli.properties index f0611ca..3147cf8 100644 --- a/updater/tests/sentry-cli.properties +++ b/updater/tests/sentry-cli.properties @@ -1,2 +1,2 @@ -version = 2.0.0 -repo = https://github.com/getsentry/sentry-cli +version = 2.0.0 +repo = https://github.com/getsentry/sentry-cli From 951c96b72f762d130effbd99d21d807f0ab4ddc5 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 14 Nov 2022 14:43:19 +0100 Subject: [PATCH 3/6] danger: don't expect a changelog on "test" PR flavor --- danger/dangerfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/danger/dangerfile.js b/danger/dangerfile.js index 59872f2..f80f96f 100644 --- a/danger/dangerfile.js +++ b/danger/dangerfile.js @@ -68,7 +68,7 @@ async function checkChangelog() { // Check if skipped if ( - ["ci", "chore(deps)", "build(deps)"].includes(prFlavor) || + ["ci", "test", "deps", "chore(deps)", "build(deps)"].includes(prFlavor) || (danger.github.pr.body + "").includes("#skip-changelog") ) { return; From 983f46b9e2bbcb84b5c4c1474c49bc017ba0114e Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 14 Nov 2022 14:46:54 +0100 Subject: [PATCH 4/6] ci: install make on macos updater test --- .github/workflows/updater-scripts-tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/updater-scripts-tests.yml b/.github/workflows/updater-scripts-tests.yml index 8bb94e2..bfc8424 100644 --- a/.github/workflows/updater-scripts-tests.yml +++ b/.github/workflows/updater-scripts-tests.yml @@ -17,5 +17,12 @@ jobs: - windows steps: - uses: actions/checkout@v3 + + - name: Install make + if: ${{ matrix.host == 'macos' }} + run: | + brew install make + echo "$(brew --prefix)/opt/make/libexec/gnubin" >> $GITHUB_PATH + - run: make test working-directory: updater From 74b63ba9b8911cb12ce5497e4791de57f954e8e3 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 14 Nov 2022 15:34:36 +0100 Subject: [PATCH 5/6] ci: disable autocrlf in tests --- .github/workflows/updater-scripts-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/updater-scripts-tests.yml b/.github/workflows/updater-scripts-tests.yml index bfc8424..67aa8a3 100644 --- a/.github/workflows/updater-scripts-tests.yml +++ b/.github/workflows/updater-scripts-tests.yml @@ -16,6 +16,8 @@ jobs: - macos - windows steps: + - run: git config --global core.autocrlf false + - uses: actions/checkout@v3 - name: Install make From 0f0ef6988524ee8a7abeb45d1d7ec1458eb1dd90 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Mon, 14 Nov 2022 15:39:56 +0100 Subject: [PATCH 6/6] chore: update changelog --- .github/workflows/versioning.yml | 2 +- CHANGELOG.md | 4 ++++ updater/scripts/sort-versions.ps1 | 1 - updater/tests/common/test-utils.ps1 | 2 +- updater/tests/get-changelog.ps1 | 2 +- updater/tests/update-dependency.ps1 | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/versioning.yml b/.github/workflows/versioning.yml index 41f86d4..8ab9c12 100644 --- a/.github/workflows/versioning.yml +++ b/.github/workflows/versioning.yml @@ -10,4 +10,4 @@ jobs: steps: - uses: Actions-R-Us/actions-tagger@f411bd910a5ad370d4511517e3eac7ff887c90ea # v2.0.2 with: - publish_latest_tag: true \ No newline at end of file + publish_latest_tag: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 81b9768..56dc235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Updater - update deprecated actions ([#48](https://github.com/getsentry/github-workflows/pull/48)) +### Features + +- Danger - ignore "deps" and "test" PR flavors in changelog checks ([#49](https://github.com/getsentry/github-workflows/pull/49)) + ## 2.4.0 ### Features diff --git a/updater/scripts/sort-versions.ps1 b/updater/scripts/sort-versions.ps1 index c615c26..1b2248c 100644 --- a/updater/scripts/sort-versions.ps1 +++ b/updater/scripts/sort-versions.ps1 @@ -38,4 +38,3 @@ function GetComparableVersion([Parameter(Mandatory = $true)][string] $value) } $List | Sort-Object -Property @{Expression = { GetComparableVersion $_ } } - diff --git a/updater/tests/common/test-utils.ps1 b/updater/tests/common/test-utils.ps1 index 622e280..785fe00 100644 --- a/updater/tests/common/test-utils.ps1 +++ b/updater/tests/common/test-utils.ps1 @@ -64,4 +64,4 @@ function AssertFailsWith([string] $substring, [scriptblock] $block) { throw "AssertFailsWith failed - expected to find '$substring' in the error '$e'" } -} \ No newline at end of file +} diff --git a/updater/tests/get-changelog.ps1 b/updater/tests/get-changelog.ps1 index 4fb4fcc..efd2607 100644 --- a/updater/tests/get-changelog.ps1 +++ b/updater/tests/get-changelog.ps1 @@ -107,4 +107,4 @@ RunTest "get-changelog truncates too long text" { Write-Host $actual throw "Expected changelog to contain message '$msg'" } -} \ No newline at end of file +} diff --git a/updater/tests/update-dependency.ps1 b/updater/tests/update-dependency.ps1 index f395825..b5607d6 100644 --- a/updater/tests/update-dependency.ps1 +++ b/updater/tests/update-dependency.ps1 @@ -227,4 +227,4 @@ esac '@ | Out-File $testScript AssertFailsWith "set-version $currentVersion | output: Failure" { UpdateDependency $testScript } -} -skipReason ($IsWindows ? "on Windows" : '') \ No newline at end of file +} -skipReason ($IsWindows ? "on Windows" : '')