Skip to content

Commit

Permalink
Test on Microsoft Edge (hardkoded#1339)
Browse files Browse the repository at this point in the history
* Install edge

* Move files

* here we go

* okey

* Almost there

* Force framework

* Change log location

* Remove log, we know it's working

* CodeFactor
  • Loading branch information
kblok authored Nov 29, 2019
1 parent 5d4b111 commit d1ff5ab
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 1 deletion.
38 changes: 38 additions & 0 deletions appveyor-edge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 1.0.{build}
branches:
only:
- master
image: Visual Studio 2017
configuration: Release
environment:
git_access_token:
secure: FxcQ9C8a/NgcQB5dFdZts6ZWEDT4zMhA4qPQAYwWc7huMmhmTIl1sbFEIaAWQMTL
PUPPETEER_EXECUTABLE_PATH: C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe
install:
- ps: >-
cd c:\projects\puppeteer-sharp-edge\appveyor\edge
.\InstallEdge.ps1
cd c:\projects\puppeteer-sharp-edge
before_build:
- ps: >-
dotnet restore .\lib\PuppeteerSharp.sln
New-SelfSignedCertificate -Subject "localhost" -FriendlyName "Puppeteer" -CertStoreLocation "cert:\CurrentUser\My"
Get-ChildItem -Path cert:\CurrentUSer\my | where { $_.friendlyname -eq "Puppeteer" } | Export-Certificate -FilePath C:\projects\puppeteer-sharp-edge\lib\PuppeteerSharp.TestServer\testCert.cer
build:
project: .\lib\PuppeteerSharp.sln
publish_nuget: true
include_nuget_references: true
verbosity: minimal
test_script:
- cmd: >-
cd .\lib\PuppeteerSharp.Tests
dotnet test -f netcoreapp2.2 -s test.runsettings
cache:
- $HOME/.nuget/packages
124 changes: 124 additions & 0 deletions appveyor/edge/ImageHelpers/ImageHelpers.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#
# Module manifest for module 'ImageHelpers'
#
# Generated by: chrispat
#
# Generated on: 11/1/2017
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'ImageHelpers.psm1'

# Version number of this module.
ModuleVersion = '0.0.1'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'c9334909-16a1-48f1-a94a-c7baf1b961d9'

# Author of this module
Author = 'chrispat'

# Company or vendor of this module
CompanyName = 'Unknown'

# Copyright statement for this module
Copyright = '(c) 2017 chrispat. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Helper functions for creating vsts images'

# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = '*'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()

# A URL to the license for this module.
# LicenseUri = ''

# A URL to the main website for this project.
# ProjectUri = ''

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''

} # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}


19 changes: 19 additions & 0 deletions appveyor/edge/ImageHelpers/ImageHelpers.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[CmdletBinding()]
param()

. $PSScriptRoot\PathHelpers.ps1
. $PSScriptRoot\InstallHelpers.ps1
. $PSScriptRoot\MarkdownHelpers.ps1

Export-ModuleMember -Function @(
'Test-MachinePath'
'Get-MachinePath'
'Set-MachinePath'
'Add-MachinePathItem'
'Get-SystemVariable'
'Set-SystemVariable'
'Install-MSI'
'Install-EXE'
'Add-ContentToMarkdown'
'Add-SoftwareDetailsToMarkdown'
)
83 changes: 83 additions & 0 deletions appveyor/edge/ImageHelpers/InstallHelpers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
function Install-MSI
{
Param
(
[String]$MsiUrl,
[String]$MsiName
)

$exitCode = -1

try
{
Write-Host "Downloading $MsiName..."
$FilePath = "${env:Temp}\$MsiName"

Invoke-WebRequest -Uri $MsiUrl -OutFile $FilePath

$Arguments = ('/i', $FilePath, '/QN', '/norestart' )

Write-Host "Starting Install $MsiName..."
$process = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode

if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host -Object 'Installation successful'
return $exitCode
}
else
{
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
exit $exitCode
}
}
catch
{
Write-Host -Object "Failed to install the MSI $MsiName"
Write-Host -Object $_.Exception.Message
exit -1
}
}


function Install-EXE
{
Param
(
[String]$Url,
[String]$Name,
[String[]]$ArgumentList
)

$exitCode = -1

try
{
Write-Host "Downloading $Name..."
$FilePath = "${env:Temp}\$Name"

Invoke-WebRequest -Uri $Url -OutFile $FilePath

Write-Host "Starting Install $Name..."
$process = Start-Process -FilePath $FilePath -ArgumentList $ArgumentList -Wait -PassThru
$exitCode = $process.ExitCode

if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host -Object 'Installation successful'
return $exitCode
}
else
{
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
return $exitCode
}
}
catch
{
Write-Host -Object "Failed to install the Executable $Name"
Write-Host -Object $_.Exception.Message
return -1
}
}
25 changes: 25 additions & 0 deletions appveyor/edge/ImageHelpers/MarkdownHelpers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function Add-ContentToMarkdown {
[CmdletBinding()]
param(
$Content = ""
)

Add-Content 'C:\InstalledSoftware.md' $Content
}


function Add-SoftwareDetailsToMarkdown {
[CmdletBinding()]
param(
$SoftwareName = "",
$DescriptionMarkdown = ""
)

$Content = @"
## $SoftwareName
$DescriptionMarkdown
"@
Add-ContentToMarkdown -Content $Content
}
68 changes: 68 additions & 0 deletions appveyor/edge/ImageHelpers/PathHelpers.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
function Test-MachinePath{
[CmdletBinding()]
param(
[string]$PathItem
)

$currentPath = Get-MachinePath

$pathItems = $currentPath.Split(';')

if($pathItems.Contains($PathItem))
{
return $true
}
else
{
return $false
}
}

function Set-MachinePath{
[CmdletBinding()]
param(
[string]$NewPath
)
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name Path -Value $NewPath
return $NewPath
}

function Add-MachinePathItem
{
[CmdletBinding()]
param(
[string]$PathItem
)

$currentPath = Get-MachinePath
$newPath = $PathItem + ';' + $currentPath
return Set-MachinePath -NewPath $newPath
}

function Get-MachinePath{
[CmdletBinding()]
param(

)
$currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).Path
return $currentPath
}

function Get-SystemVariable{
[CmdletBinding()]
param(
[string]$SystemVariable
)
$currentPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name $SystemVariable).$SystemVariable
return $currentPath
}

function Set-SystemVariable{
[CmdletBinding()]
param(
[string]$SystemVariable,
[string]$Value
)
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name $SystemVariable -Value $Value
return $Value
}
23 changes: 23 additions & 0 deletions appveyor/edge/InstallEdge.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
################################################################################
## File: Install-EdgePreview.ps1
## Team: Automated Testing
## Desc: Install Microsoft Edge preview
################################################################################
#Save the current value in the $p variable.
Copy-Item -Path .\ImageHelpers -Destination $home\Documents\WindowsPowerShell\Modules\ImageHelpers -Recurse -Force

Import-Module -Name ImageHelpers -Force

$temp_install_dir = 'C:\Windows\Installer'
New-Item -Path $temp_install_dir -ItemType Directory -Force

Install-EXE -Url "https://go.microsoft.com/fwlink/?linkid=2069324&Channel=Dev&language=en-us&Consent=1" -Name "MicrosoftEdgeSetup.exe" -ArgumentList "/silent /install"

# Add some things to stop Edge from auto updating.
New-NetFirewallRule -DisplayName "BlockEdgeUpdate" -Direction Outbound -Action Block -Program "C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe"

New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdgeUpdate" -Force
New-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdgeUpdate" -Name "AutoUpdateCheckPeriodMinutes" -Value 00000000 -Force
New-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdgeUpdate" -Name "UpdateDefault" -Value 00000000 -Force
New-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdgeUpdate" -Name "DisableAutoUpdateChecksCheckboxValue" -Value 00000001 -Force
New-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdgeUpdate" -Name "Update{8A69D345-D564-463C-AFF1-A69D9E530F96}" -Value 00000000 -Force
1 change: 0 additions & 1 deletion lib/PuppeteerSharp/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ private static string GetOrFetchChromeExecutable(LaunchOptions options)
{
throw new FileNotFoundException("Failed to launch chrome! path to executable does not exist", chromeExecutable);
}

return chromeExecutable;
}

Expand Down

0 comments on commit d1ff5ab

Please sign in to comment.