Skip to content

Commit 03be3f5

Browse files
authored
test: improve test scripts & test on all supported platforms (#49)
1 parent 8886eba commit 03be3f5

15 files changed

+586
-447
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
text eol=lf

.github/workflows/updater-scripts-tests.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,25 @@ on:
66

77
jobs:
88
test:
9-
runs-on: ubuntu-latest
9+
name: ${{ matrix.host }}
10+
runs-on: ${{ matrix.host }}-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
host:
15+
- ubuntu
16+
- macos
17+
- windows
1018
steps:
19+
- run: git config --global core.autocrlf false
20+
1121
- uses: actions/checkout@v3
22+
23+
- name: Install make
24+
if: ${{ matrix.host == 'macos' }}
25+
run: |
26+
brew install make
27+
echo "$(brew --prefix)/opt/make/libexec/gnubin" >> $GITHUB_PATH
28+
1229
- run: make test
1330
working-directory: updater

.github/workflows/versioning.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
steps:
1111
- uses: Actions-R-Us/actions-tagger@f411bd910a5ad370d4511517e3eac7ff887c90ea # v2.0.2
1212
with:
13-
publish_latest_tag: true
13+
publish_latest_tag: true

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Updater - update deprecated actions ([#48](https://github.com/getsentry/github-workflows/pull/48))
88

9+
### Features
10+
11+
- Danger - ignore "deps" and "test" PR flavors in changelog checks ([#49](https://github.com/getsentry/github-workflows/pull/49))
12+
913
## 2.4.0
1014

1115
### Features

danger/dangerfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function checkChangelog() {
6868

6969
// Check if skipped
7070
if (
71-
["ci", "chore(deps)", "build(deps)"].includes(prFlavor) ||
71+
["ci", "test", "deps", "chore(deps)", "build(deps)"].includes(prFlavor) ||
7272
(danger.github.pr.body + "").includes("#skip-changelog")
7373
) {
7474
return;

updater/scripts/get-changelog.ps1

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
1-
param(
2-
[Parameter(Mandatory = $true)][string] $RepoUrl,
3-
[Parameter(Mandatory = $true)][string] $OldTag,
4-
[Parameter(Mandatory = $true)][string] $NewTag
5-
)
6-
7-
Set-StrictMode -Version latest
8-
9-
$prefix = 'https?://(www\.)?github.com/'
10-
if (-not ($RepoUrl -match "^$prefix"))
11-
{
12-
Write-Warning "Only github.com repositories are currently supported. Given RepoUrl doesn't look like one: $RepoUrl"
13-
return
14-
}
15-
16-
$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
17-
18-
try
19-
{
20-
git clone --depth 1 $RepoUrl $tmpDir
21-
22-
$file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } )
23-
if ("$file" -eq "")
24-
{
25-
Write-Warning "Couldn't find a changelog"
26-
return
27-
}
28-
elseif ($file -is [Array])
29-
{
30-
Write-Warning "Multiple changelogs found: $file"
31-
return
32-
}
33-
Write-Host "Found changelog: $file"
34-
[string[]]$lines = Get-Content $file
35-
}
36-
finally
37-
{
38-
Write-Host "Removing $tmpDir"
39-
Remove-Item -Recurse -Force -ErrorAction Continue -Path $tmpDir
40-
}
41-
42-
$foundFirst = $false
43-
$changelog = ""
44-
for ($i = 0; $i -lt $lines.Count; $i++)
45-
{
46-
$line = $lines[$i]
47-
48-
if (-not $foundFirst)
49-
{
50-
if ($line -match "^#+ +v?$NewTag\b")
51-
{
52-
$foundFirst = $true
53-
}
54-
else
55-
{
56-
continue
57-
}
58-
}
59-
elseif ($line -match "^#+ +v?$OldTag\b")
60-
{
61-
break
62-
}
63-
64-
$changelog += "$line`n"
65-
}
66-
67-
$changelog = $changelog.Trim()
68-
if ($changelog.Length -gt 1)
69-
{
70-
$changelog = "# Changelog`n$changelog"
71-
# Increase header level by one.
72-
$changelog = $changelog -replace "(#+) ", '$1# '
73-
# Remove at-mentions.
74-
$changelog = $changelog -replace '@', ''
75-
# Make PR/issue references into links to the original repository (unless they already are links).
76-
$changelog = $changelog -replace '(?<!\[)#([0-9]+)', ('[#$1](' + $RepoUrl + '/issues/$1)')
77-
# Replace any links pointing to github.com so that the target PRs/Issues don't get na notification.
78-
$changelog = $changelog -replace ('\(' + $prefix), '(https://github-redirect.dependabot.com/'
79-
}
80-
81-
# Limit the changelog length to ~60k to allow for other text in the PR body (total PR limit is 65536 characters).
82-
$limit = 60000
83-
if ($changelog.Length -gt $limit)
84-
{
85-
$oldLength = $changelog.Length
86-
Write-Warning "Truncating changelog because it's $($changelog.Length - $limit) characters longer than the limit $limit."
87-
while ($changelog.Length -gt $limit)
88-
{
89-
$changelog = $changelog.Substring(0, $changelog.LastIndexOf("`n"))
90-
}
91-
$changelog += "`n`n> :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**"
92-
}
93-
94-
$changelog
1+
param(
2+
[Parameter(Mandatory = $true)][string] $RepoUrl,
3+
[Parameter(Mandatory = $true)][string] $OldTag,
4+
[Parameter(Mandatory = $true)][string] $NewTag
5+
)
6+
7+
Set-StrictMode -Version latest
8+
9+
$prefix = 'https?://(www\.)?github.com/'
10+
if (-not ($RepoUrl -match "^$prefix"))
11+
{
12+
Write-Warning "Only github.com repositories are currently supported. Given RepoUrl doesn't look like one: $RepoUrl"
13+
return
14+
}
15+
16+
$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
17+
18+
try
19+
{
20+
git clone --depth 1 $RepoUrl $tmpDir
21+
22+
$file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } )
23+
if ("$file" -eq "")
24+
{
25+
Write-Warning "Couldn't find a changelog"
26+
return
27+
}
28+
elseif ($file -is [Array])
29+
{
30+
Write-Warning "Multiple changelogs found: $file"
31+
return
32+
}
33+
Write-Host "Found changelog: $file"
34+
[string[]]$lines = Get-Content $file
35+
}
36+
finally
37+
{
38+
Write-Host "Removing $tmpDir"
39+
Remove-Item -Recurse -Force -ErrorAction Continue -Path $tmpDir
40+
}
41+
42+
$foundFirst = $false
43+
$changelog = ""
44+
for ($i = 0; $i -lt $lines.Count; $i++)
45+
{
46+
$line = $lines[$i]
47+
48+
if (-not $foundFirst)
49+
{
50+
if ($line -match "^#+ +v?$NewTag\b")
51+
{
52+
$foundFirst = $true
53+
}
54+
else
55+
{
56+
continue
57+
}
58+
}
59+
elseif ($line -match "^#+ +v?$OldTag\b")
60+
{
61+
break
62+
}
63+
64+
$changelog += "$line`n"
65+
}
66+
67+
$changelog = $changelog.Trim()
68+
if ($changelog.Length -gt 1)
69+
{
70+
$changelog = "# Changelog`n$changelog"
71+
# Increase header level by one.
72+
$changelog = $changelog -replace "(#+) ", '$1# '
73+
# Remove at-mentions.
74+
$changelog = $changelog -replace '@', ''
75+
# Make PR/issue references into links to the original repository (unless they already are links).
76+
$changelog = $changelog -replace '(?<!\[)#([0-9]+)', ('[#$1](' + $RepoUrl + '/issues/$1)')
77+
# Replace any links pointing to github.com so that the target PRs/Issues don't get na notification.
78+
$changelog = $changelog -replace ('\(' + $prefix), '(https://github-redirect.dependabot.com/'
79+
}
80+
81+
# Limit the changelog length to ~60k to allow for other text in the PR body (total PR limit is 65536 characters).
82+
$limit = 60000
83+
if ($changelog.Length -gt $limit)
84+
{
85+
$oldLength = $changelog.Length
86+
Write-Warning "Truncating changelog because it's $($changelog.Length - $limit) characters longer than the limit $limit."
87+
while ($changelog.Length -gt $limit)
88+
{
89+
$changelog = $changelog.Substring(0, $changelog.LastIndexOf("`n"))
90+
}
91+
$changelog += "`n`n> :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**"
92+
}
93+
94+
$changelog

updater/scripts/set-github-env.ps1

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
param(
2-
[Parameter(Mandatory = $true)][string] $Name,
3-
[string] $Data = ''
4-
)
5-
6-
Set-StrictMode -Version latest
7-
8-
if ($null -eq $env:GITHUB_ENV) {
9-
throw "GITHUB_ENV environment variable is missing - this script is supposed to be run in GitHub-Actions."
10-
}
11-
12-
Write-Output "$Name<<EOF`n$Data`nEOF" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
1+
param(
2+
[Parameter(Mandatory = $true)][string] $Name,
3+
[string] $Data = ''
4+
)
5+
6+
Set-StrictMode -Version latest
7+
8+
if ($null -eq $env:GITHUB_ENV) {
9+
throw "GITHUB_ENV environment variable is missing - this script is supposed to be run in GitHub-Actions."
10+
}
11+
12+
Write-Output "$Name<<EOF`n$Data`nEOF" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

updater/scripts/sort-versions.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ function GetComparableVersion([Parameter(Mandatory = $true)][string] $value)
3838
}
3939

4040
$List | Sort-Object -Property @{Expression = { GetComparableVersion $_ } }
41-

0 commit comments

Comments
 (0)