Skip to content

Commit

Permalink
fix: React Native Windows E2E test app (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
statm authored May 14, 2020
1 parent d4f97a0 commit c0bfea7
Show file tree
Hide file tree
Showing 32 changed files with 4,600 additions and 3,811 deletions.
17 changes: 16 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ steps:
submodules: false
persistCredentials: false

- task: PowerShell@2
displayName: Install Visual Studio dependencies
inputs:
targetType: filePath
filePath: fixtures/react_native_windows_e2e_app/scripts/Install-VsFeatures.ps1
arguments:
-Components "Microsoft.VisualStudio.ComponentGroup.UWP.VC.v141"
-Cleanup:$true

- task: PowerShell@2
displayName: List Visual Studio Components
inputs:
targetType: filePath
filePath: fixtures/react_native_windows_e2e_app/scripts/VSComponentList.ps1

- task: CmdLine@2
displayName: Install Haul dependencies
inputs:
Expand All @@ -36,7 +51,7 @@ steps:
- task: CmdLine@2
displayName: run-windows
inputs:
script: yarn run start:app --logging --force
script: yarn run start:app --logging
workingDirectory: fixtures/react_native_windows_e2e_app

- task: PowerShell@2
Expand Down
6 changes: 5 additions & 1 deletion fixtures/react_native_windows_e2e_app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
Expand All @@ -40,6 +39,7 @@ yarn-error.log
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
Expand All @@ -54,3 +54,7 @@ buck-out/

# Bundle artifact
*.jsbundle

# MSBuild artifact
msbuild.binlog
msbuild.ProjectImports.zip
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import wd from 'wd';
import execa from 'execa';

jest.setTimeout(60000);
jest.setTimeout(80000);
const PORT = 4723;
const config = {
platformName: 'Windows',
Expand All @@ -12,7 +12,7 @@ let appiumServer = { cancel() {} };

beforeAll(async () => {
appiumServer = execa.command('yarn run appium');
await new Promise(resolve => setTimeout(resolve, 4000));
await new Promise(resolve => setTimeout(resolve, 20000));

await driver.init({ ...config, app: 'Root' });
await driver.sleep(2000);
Expand Down
27 changes: 15 additions & 12 deletions fixtures/react_native_windows_e2e_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,39 @@
"version": "0.0.1",
"private": true,
"scripts": {
"start": "../../packages/haul-cli/bin/haul start",
"prepare": "patch-package",
"start": "node ../../packages/haul-cli/bin/haul.js start",
"test": "jest",
"build:bundle": "node ../../packages/haul-cli/bin/haul.js bundle --platform windows --dev true --bundle-output windows/RNWTestApp/Bundle/index.windows.bundle --assets-dest windows/RNWTestApp/Bundle",
"start:app": "node_modules/.bin/react-native run-windows --arch x86 --no-packager"
"start:app": "node_modules/.bin/react-native run-windows --arch x64 --no-packager"
},
"dependencies": {
"apollo-cache-inmemory": "^1.6.3",
"apollo-client": "^2.6.4",
"apollo-link-http": "^1.5.16",
"graphql": "^14.5.7",
"graphql-tag": "^2.10.1",
"patch-package": "^6.2.0",
"postinstall-postinstall": "^2.0.0",
"react": "16.10.1",
"react": "16.9.0",
"react-apollo": "^3.1.1",
"react-native": "^0.60.0",
"react-native-windows": "0.60.0-vnext.115",
"react-native": "0.61.5",
"react-native-windows": "^0.61.0-0",
"rnpm-plugin-windows": "^0.3.5"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/runtime": "^7.6.0",
"@babel/core": "^7.9.6",
"@babel/runtime": "^7.9.6",
"appium": "^1.14.2",
"babel-jest": "^24.9.0",
"babel-jest": "^26.0.1",
"execa": "^2.0.4",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"jest": "^26.0.1",
"metro-react-native-babel-preset": "^0.59.0",
"patch-package": "^6.1.2",
"postinstall-prepare": "^1.0.1",
"react-test-renderer": "16.9.0",
"wd": "^1.11.4"
},
"jest": {
"preset": "react-native"
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js b/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js
index 5bddc23..b04cc32 100644
--- a/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js
+++ b/node_modules/react-native-windows/local-cli/runWindows/utils/deploy.js
@@ -80,7 +80,9 @@ function getAppxManifest(options) {
const configuration = getBuildConfiguration(options);
const appxManifestGlob = `windows/{*/bin/${
options.arch
- }/${configuration},${configuration}/*}/AppxManifest.xml`;
+ }/${configuration},${
+ options.arch
+ }/${configuration}/*}/AppxManifest.xml`;
const appxPath = glob.sync(path.join(options.root, appxManifestGlob))[0];

if (!appxPath) {
108 changes: 108 additions & 0 deletions fixtures/react_native_windows_e2e_app/scripts/Install-VSFeatures.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
param (
[Parameter(Mandatory=$true)]
[string[]] $Components,

[uri] $InstallerUri = "https://download.visualstudio.microsoft.com/download/pr/c4fef23e-cc45-4836-9544-70e213134bc8/1ee5717e9a1e05015756dff77eb27d554a79a6db91f2716d836df368381af9a1/vs_Enterprise.exe",

[string] $VsInstaller = "${env:System_DefaultWorkingDirectory}\vs_Enterprise.exe",

[string] $VsInstallOutputDir = "${env:System_DefaultWorkingDirectory}\vs",

[System.IO.FileInfo] $VsInstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise",

[System.IO.FileInfo] $VsInstallerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer",

[switch] $Collect = $false,

[switch] $Cleanup = $false,

[switch] $UseWebInstaller = $false
)

$Components | ForEach-Object {
$componentList += '--add', $_
}

$LocalVsInstaller = "$VsInstallerPath\vs_installershell.exe"

$UseWebInstaller = $UseWebInstaller -or -not (Test-Path -Path "$LocalVsInstaller")

if ($UseWebInstaller) {
Write-Host "Downloading web installer..."

Invoke-WebRequest -Method Get `
-Uri $InstallerUri `
-OutFile $VsInstaller

New-Item -ItemType directory -Path $VsInstallOutputDir

Write-Host "Running web installer to download requested components..."

Start-Process `
-FilePath "$VsInstaller" `
-ArgumentList ( `
'--layout', "$VsInstallOutputDir",
'--wait',
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-PassThru

Write-Host "Running downloaded VS installer to add requested components..."

Start-Process `
-FilePath "$VsInstallOutputDir\vs_Enterprise.exe" `
-ArgumentList (
'modify',
'--installPath', "`"$VsInstallPath`"" ,
'--wait',
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-PassThru `
-OutVariable returnCode

if ($Cleanup) {
Write-Host "Cleaning up..."

Remove-Item -Path $VsInstaller
Remove-Item -Path $VsInstallOutputDir -Recurse
}

} else {
Write-Host "Running local installer to add requested components..."

Start-Process `
-FilePath "$LocalVsInstaller" `
-ArgumentList (
'modify',
'--installPath', "`"$VsInstallPath`"" ,
'--norestart',
'--quiet' + `
$componentList
) `
-Wait `
-OutVariable returnCode
}

if ($Collect) {
Invoke-WebRequest -Method Get `
-Uri 'https://download.microsoft.com/download/8/3/4/834E83F6-C377-4DCE-A757-69A418B6C6DF/Collect.exe' `
-OutFile ${env:System_DefaultWorkingDirectory}\Collect.exe

# Should generate ${env:Temp}\vslogs.zip
Start-Process `
-FilePath "${env:System_DefaultWorkingDirectory}\Collect.exe" `
-Wait `
-PassThru

New-Item -ItemType Directory -Force ${env:System_DefaultWorkingDirectory}\vslogs
Expand-Archive -Path ${env:TEMP}\vslogs.zip -DestinationPath ${env:System_DefaultWorkingDirectory}\vslogs\

Write-Host "VC versions after installation:"
Get-ChildItem -Name "$VsInstallPath\VC\Tools\MSVC\"
}
25 changes: 25 additions & 0 deletions fixtures/react_native_windows_e2e_app/scripts/VSComponentList.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$dir = $env:temp
if ($env:Agent_TempDirectory -ne $null)
{
$dir = $env:Agent_TempDirectory
}

$installerPath = 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\'
$installationPath = . $installerPath\vswhere.exe -latest -property installationPath
$vsconfig = "$dir\vsconfig"
Write-Host "VSConfig will be at $vsconfig"

Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/c4fef23e-cc45-4836-9544-70e213134bc8/1ee5717e9a1e05015756dff77eb27d554a79a6db91f2716d836df368381af9a1/vs_Enterprise.exe' -OutFile $dir\vs_enterprise.exe
$p = Start-Process -PassThru $dir\vs_enterprise.exe -RedirectStandardError $dir\err -RedirectStandardOutput $dir\out -ArgumentList "export --installpath `"$installationPath`" --quiet --config $vsconfig"
$p.WaitForExit()
$x = [Datetime]::Now.AddSeconds(60)

do
{
Write-Host "Waiting for vsconfig file..."
Sleep 5
} while (!(Test-Path $vsconfig) -and ([datetime]::Now -lt $x))

Get-Content $dir\err
Get-Content $dir\out
Get-Content $vsconfig
4 changes: 4 additions & 0 deletions fixtures/react_native_windows_e2e_app/windows/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ packages/
*.DotSettings
.vs/
*project.lock.json

#Files generated by the VS build
**/Generated Files/**

Loading

0 comments on commit c0bfea7

Please sign in to comment.