-
-
Notifications
You must be signed in to change notification settings - Fork 1
170 lines (142 loc) · 7.53 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Build
run-name: Build and test with latest Vivaldi ${{ inputs.buildType }}
on:
workflow_dispatch:
inputs:
buildType:
description: 'Vivaldi build type'
required: true
default: 'release'
type: choice
options:
- release
- snapshot
workflow_call:
inputs:
buildType:
description: 'Whether to test the latest Vivaldi "release" or "snapshot" version'
required: true
default: 'release'
type: string
env:
BUILD_TYPE: ${{ inputs.buildType }}
jobs:
build:
runs-on: windows-latest
timeout-minutes: 10
steps:
- name: Find MSBuild
uses: microsoft/setup-msbuild@v2
- name: Clone
uses: actions/checkout@v4
- name: Read Vivaldi versions of existing test data
id: existing-test-data
run: |
$existingVersion = (Get-Content .\Tests\Data\vivaldi-${{ inputs.buildType }}-version.txt -TotalCount 1).Trim()
Out-File -InputObject "EXISTING_VERSION=$existingVersion" -FilePath $env:GITHUB_ENV -Append -Encoding UTF8
Write-Output "Repository's existing test data is from Vivaldi ${{ inputs.buildType }} $existingVersion"
- name: Check for latest Vivaldi version
id: latest-version
run: |
$sparkleUrl = if ("${{ inputs.buildType }}" -eq "snapshot") {
"https://update.vivaldi.com/update/1.0/win/appcast.x64.xml"
} else {
"https://update.vivaldi.com/update/1.0/public/appcast.x64.xml"
}
$sparkleXml = $(Invoke-WebRequest $sparkleUrl).Content
$sparkleEnclosure = ($sparkleXml | Select-Xml -XPath "/rss/channel/item/enclosure").Node
$latestVersion = (Select-Xml -Xml $sparkleEnclosure -XPath "@sparkle:version" -Namespace @{"sparkle" = "http://www.andymatuschak.org/xml-namespaces/sparkle"}).Node.Value
$downloadUrl = (Select-Xml -Xml $sparkleEnclosure -XPath "@url").Node.Value
Out-File -InputObject "LATEST_VERSION=$latestVersion" -FilePath $env:GITHUB_ENV -Append -Encoding UTF8
Out-File -InputObject "DOWNLOAD_URL=$downloadUrl" -FilePath $env:GITHUB_ENV -Append -Encoding UTF8
Write-Output "Latest Vivaldi ${{ inputs.buildType }} version is $latestVersion"
Write-Output "Latest Vivaldi ${{ inputs.buildType }} can be downloaded from $downloadUrl"
- name: Download Vivaldi
run: |
Write-Output "Downloading Vivaldi ${{ inputs.buildType }} $env:LATEST_VERSION from $env:DOWNLOAD_URL"
Invoke-WebRequest -Uri $env:DOWNLOAD_URL -OutFile vivaldi-installer.exe
- name: Install Vivaldi
run: |
Write-Output "Installing Vivaldi in silent standalone mode"
Start-Process -FilePath .\vivaldi-installer.exe -ArgumentList @(`
'--vivaldi-silent',
'--vivaldi-standalone',
'--vivaldi-install-dir="${{ github.workspace }}\vivaldi-installation"',
'--do-not-launch-chrome'
) -Wait
- name: Compare existing and latest version numbers
run: |
$isUpToDate = $env:EXISTING_VERSION -eq $env:LATEST_VERSION
Out-File -InputObject "UP_TO_DATE=$isUpToDate" -FilePath $env:GITHUB_ENV -Append -Encoding UTF8
If ($isUpToDate) {
Write-Output "::notice title=No Vivaldi ${{ inputs.buildType }} update::Test data was already up-to-date with the latest Vivaldi ${{ inputs.buildType }} version ($env:LATEST_VERSION)."
} Else {
Write-Output "::notice title=Vivaldi ${{ inputs.buildType }} update released::The latest Vivaldi ${{ inputs.buildType }} version ($env:LATEST_VERSION) is higher than the existing test data version ($env:EXISTING_VERSION)."
Out-File -InputObject "### Updated to Vivaldi ${{ inputs.buildType }} $env:LATEST_VERSION" -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding UTF8
}
- name: Copy installation files into test data
run: |
Copy-Item -Force -Path @(`
'.\vivaldi-installation\Application\*\resources\vivaldi\bundle.js',
'.\vivaldi-installation\Application\*\resources\vivaldi\background-bundle.js'
) -Destination .\Tests\Data\${{ inputs.buildType }}\BundleScript\
Write-Output "Updated bundle.js and background-bundle.js in ${{ inputs.buildType }} test data"
- name: Update version number in test data
run: |
Out-File -InputObject $env:LATEST_VERSION -FilePath .\Tests\Data\vivaldi-${{ inputs.buildType }}-version.txt -Encoding UTF8
Write-Output "Marked ${{ inputs.buildType }} test data as coming from Vivaldi $env:LATEST_VERSION"
- name: Commit and push new test data
uses: EndBug/add-and-commit@v9
env:
HOME: "~" # get rid of a benign warning
with:
add: ./Tests/Data
message: Update test data for Vivaldi ${{ inputs.buildType }} ${{ env.LATEST_VERSION }}
pathspec_error_handling: exitImmediately
author_name: Ben Hutchison
author_email: [email protected]
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
push: true
- name: Restore solution
run: msbuild -p:Configuration=Release -t:restore -p:RestoreLockedMode=true
- name: Build solution
run: msbuild -p:Configuration=Release -t:build -m
# Tests uses the BUILD_TYPE environment variable to load the correct files, as set at the top of this file. See the DataReader class.
- name: Smoke test tweaks
run: dotnet test Tests --filter DisplayName~SmokeTests --configuration Release --no-build --verbosity normal
- name: Smoke test Vivaldi startup
run: |
echo "Tweaking standalone installation"
Start-Process -FilePath ".\VivaldiCustomLauncher\bin\Release\VivaldiCustomLauncher.exe" -ArgumentList @(`
'--vivaldi-application-directory="${{ github.workspace }}\vivaldi-installation\Application"',
'--do-not-launch-vivaldi'
) -Wait
echo "Tweaks applied, starting Vivaldi"
$vivaldiProcess = Start-Process -FilePath .\vivaldi-installation\Application\vivaldi.exe -ArgumentList @("--enable-logging", "--v=1") -PassThru
echo "Started Vivaldi with PID $($vivaldiProcess.Id)"
$debugLogFile = '.\vivaldi-installation\User Data\chrome_debug.log'
$deadline = [DateTime]::Now.AddMinutes(3)
while([DateTime]::Now -lt $deadline) {
$logContents = Get-Content $debugLogFile -ErrorAction Ignore
$consoleError = $logContents | where { $_ -like "*:ERROR:CONSOLE(*" } | select -First 1
if($consoleError.Length -gt 0){
Stop-Process $vivaldiProcess
Write-Output "::error title=Failed to start Vivaldi::Error in Vivaldi console: $consoleError"
exit 1
} elseif(($logContents | where { $_ -like "*JS init startup:*" } | select -first 1).Length -gt 0){
Stop-Process $vivaldiProcess
Write-Output "Vivaldi started successfully with no console errors"
exit 0
}
Start-Sleep -Seconds 2
}
Stop-Process $vivaldiProcess
Write-Output "::error title=Failed to start Vivaldi::Timed out"
exit 1
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: VivaldiCustomLauncher-${{ inputs.buildType }}
path: VivaldiCustomLauncher\bin\Release\*.exe
if-no-files-found: error