Build and test with latest Vivaldi snapshot #950
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Set up MSBuild | |
uses: microsoft/[email protected] | |
- name: Clone | |
uses: actions/[email protected] | |
- 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 }} $existingReleaseVersion" | |
- 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 | |
Write-Output "Vivaldi installation finished" | |
cat $env:TEMP\vivaldi_installer.log | |
- 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::Test data version ($env:EXISTING_VERSION) is lower than the latest Vivaldi ${{ inputs.buildType }} version ($env:LATEST_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-common-bundle.js' | |
) -Destination .\Tests\Data\${{ inputs.buildType }}\BundleScript\ | |
Write-Output "Updated bundle.js and background-common-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/[email protected] | |
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/[email protected] | |
with: | |
name: VivaldiCustomLauncher | |
path: VivaldiCustomLauncher\bin\Release\*.exe | |
if-no-files-found: error |