Skip to content

Commit ac2994e

Browse files
hectormmgCopilot
andcommitted
refactor(e2e): consolidate detect-changes scripts into one
msal-browser-1p has the same dependency shape as msal-react/msal-angular (wrapper over msal-browser). A single script handles all libraries with an optional -Repo1pPath parameter for when the 1P repo is also checked out. - 3p-e2e.yml: calls script with no args (Repo3pPath defaults to cwd) - 1p-e2e.yml: passes explicit -Repo3pPath and -Repo1pPath Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a390747 commit ac2994e

5 files changed

Lines changed: 74 additions & 96 deletions

File tree

.pipelines/1p-e2e.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ extends:
6969
displayName: "Compute affected libraries"
7070
inputs:
7171
targetType: filePath
72-
filePath: $(Pipeline.Workspace)/3p/.pipelines/scripts/detect-changes-1p.ps1
72+
filePath: $(Pipeline.Workspace)/3p/.pipelines/scripts/detect-changes.ps1
73+
arguments: -Repo3pPath "$(Pipeline.Workspace)/3p" -Repo1pPath "$(Pipeline.Workspace)/1p"
7374
pwsh: true
7475

7576
- template: .pipelines/templates/e2e-tests.yml@1P

.pipelines/3p-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extends:
7979
displayName: "Compute affected libraries"
8080
inputs:
8181
targetType: filePath
82-
filePath: .pipelines/scripts/detect-changes-3p.ps1
82+
filePath: .pipelines/scripts/detect-changes.ps1
8383
pwsh: true
8484

8585
- ${{ if eq(parameters.runBrowserTests, true) }}:

.pipelines/scripts/detect-changes-1p.ps1

Lines changed: 0 additions & 50 deletions
This file was deleted.

.pipelines/scripts/detect-changes-3p.ps1

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Detects which E2E suites are affected by the current PR.
2+
# Sets isOutput ADO variables for each library. Non-PR builds and shared-infra
3+
# changes default all flags to true (fail-open).
4+
#
5+
# Parameters:
6+
# -Repo3pPath Path to the 3P repo root. Defaults to the current directory.
7+
# -Repo1pPath Path to the 1P repo root. Optional; provide when the 1P repo
8+
# is checked out (i.e. in 1p-e2e.yml) to also gate msal-browser-1p.
9+
10+
param(
11+
[string]$Repo3pPath = $PWD,
12+
[string]$Repo1pPath = ""
13+
)
14+
15+
$runBrowser = $runNode = $runReact = $runAngular = $run1p = $true
16+
17+
if ($env:SYSTEM_PULLREQUEST_TARGETBRANCH) {
18+
$target = $env:SYSTEM_PULLREQUEST_TARGETBRANCH -replace '^refs/heads/', ''
19+
Write-Host "PR build: diffing against origin/$target"
20+
21+
Set-Location $Repo3pPath
22+
git fetch origin $target
23+
if ($LASTEXITCODE -ne 0) { throw "git fetch failed in 3P repo" }
24+
$changed3p = git diff --name-only "origin/$target...HEAD"
25+
26+
$changed1p = @()
27+
if ($Repo1pPath) {
28+
Set-Location $Repo1pPath
29+
git fetch origin $target 2>$null # branch may not exist in 1P repo; non-fatal
30+
$changed1p = if ($LASTEXITCODE -eq 0) {
31+
git diff --name-only "origin/$target...HEAD"
32+
} else { @() }
33+
}
34+
35+
Write-Host "Changed 3P files:`n$($changed3p -join "`n")"
36+
if ($changed1p) { Write-Host "Changed 1P files:`n$($changed1p -join "`n")" }
37+
38+
# Shared infra changes in either repo → run everything
39+
$sharedChanged = (
40+
($changed3p | Where-Object { $_ -match '^\.pipelines/' -or $_ -match '^samples/e2eTestUtils/' }).Count -gt 0 -or
41+
($changed1p | Where-Object { $_ -match '^\.pipelines/' }).Count -gt 0
42+
)
43+
44+
if ($sharedChanged) {
45+
Write-Host "Shared infra changed — running all test suites"
46+
} else {
47+
$changedCommon = ($changed3p | Where-Object { $_ -match '^lib/msal-common/' }).Count -gt 0
48+
$changedBrowser = ($changed3p | Where-Object { $_ -match '^lib/msal-browser/' -or $_ -match '^samples/msal-browser-samples/' }).Count -gt 0
49+
$changedNode = ($changed3p | Where-Object { $_ -match '^lib/msal-node/' -or $_ -match '^samples/msal-node-samples/' }).Count -gt 0
50+
$changedReact = ($changed3p | Where-Object { $_ -match '^lib/msal-react/' -or $_ -match '^samples/msal-react-samples/' }).Count -gt 0
51+
$changedAngular = ($changed3p | Where-Object { $_ -match '^lib/msal-angular/' -or $_ -match '^samples/msal-angular-samples/' }).Count -gt 0
52+
$changed1pPkg = ($changed1p | Where-Object { $_ -match '^msal-browser-1p/' -or $_ -match '^samples/' }).Count -gt 0
53+
54+
$runBrowser = $changedCommon -or $changedBrowser
55+
$runNode = $changedCommon -or $changedNode
56+
$runReact = $changedCommon -or $changedBrowser -or $changedReact
57+
$runAngular = $changedCommon -or $changedBrowser -or $changedAngular
58+
$run1p = $changedCommon -or $changedBrowser -or $changed1pPkg
59+
60+
Write-Host "Changed: common=$changedCommon browser=$changedBrowser node=$changedNode react=$changedReact angular=$changedAngular 1p=$changed1pPkg"
61+
}
62+
} else {
63+
Write-Host "Non-PR build — running all test suites"
64+
}
65+
66+
Write-Host "Run: browser=$runBrowser node=$runNode react=$runReact angular=$runAngular browser-1p=$run1p"
67+
Write-Host "##vso[task.setvariable variable=runMsalBrowser;isOutput=true]$($runBrowser.ToString().ToLower())"
68+
Write-Host "##vso[task.setvariable variable=runMsalNode;isOutput=true]$($runNode.ToString().ToLower())"
69+
Write-Host "##vso[task.setvariable variable=runMsalReact;isOutput=true]$($runReact.ToString().ToLower())"
70+
Write-Host "##vso[task.setvariable variable=runMsalAngular;isOutput=true]$($runAngular.ToString().ToLower())"
71+
Write-Host "##vso[task.setvariable variable=runMsalBrowser1p;isOutput=true]$($run1p.ToString().ToLower())"

0 commit comments

Comments
 (0)