Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/pr-loop.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function Invoke-EndToEndPipelineTest ($User, $Password, $Data) {
$result = az login --allow-no-subscriptions -u $User -p $Password
function Invoke-EndToEndPipelineTest ($Data) {
$path = './PowerShell/tests/e2e-pipeline.tests.ps1'
$container = New-PesterContainer -Path $path -Data $Data
Invoke-Pester -Container $container
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/pr-loop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ jobs:
AZDO_ORG: ${{ secrets.AZDO_ORG }}
AZDO_PROJECT: ${{ secrets.AZDO_PROJECT }}
AZDO_REPO: ${{ secrets.AZDO_PROJECT }}
AZURE_DEVOPS_EXT_PAT: ${{ secrets.AZDO_PAT }}
PR_LOOP_DATA: ${{ secrets.PR_LOOP_DATA }}
AZDO_SVC_CONN_NAME: ${{ secrets.AZDO_SVC_CONN_NAME }}
AZDO_SVC_CONN_URL: ${{ secrets.AZDO_SVC_CONN_NAME }}
PR_LOOP_EMAIL: ${{ secrets.PR_LOOP_EMAIL }}
PR_LOOP_USERNAME: ${{ secrets.PR_LOOP_USERNAME }}
run: |
. ./.github/workflows/pr-loop.ps1
$pair = ":$($env:AZURE_DEVOPS_EXT_PAT)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))

$data = @{
Org = $env:AZDO_ORG
Project = $env:AZDO_PROJECT
Expand All @@ -39,6 +43,7 @@ jobs:
PortalSiteName = 'ALM Accelerator Sample - almacceleratorsample'
PublishCustomizations = 'false'
CommitScope = '1'
BasicAccessToken = $encodedCreds
}
Invoke-EndToEndPipelineTest -User ${{ secrets.AZDO_USER }} -Password ${{ secrets.AZDO_PASSWORD }} -Data $data
shell: pwsh
Invoke-EndToEndPipelineTest -Data $data
shell: pwsh
12 changes: 7 additions & 5 deletions PowerShell/code-first-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function Invoke-Check-Code-First-Components{
}

<#
This function sets the pac tools path.
This function sets the pac tools path based on the build tools installation path.
#>
function Set-Pac-Tools-Path{
param (
Expand Down Expand Up @@ -300,7 +300,6 @@ function Invoke-Clone-Or-Sync-Solution{
{
# Trigger Auth
Invoke-Expression -Command "$pacexepath auth create --url $serviceConnectionUrl --name ppdev --applicationId $clientId --clientSecret $clientSecret --tenant $tenantID"
$unpackfolderpath = "$buildSourceDirectory\$repo\$solutionName\SolutionPackage"

# Trigger Clone or Sync
$cdsProjPath = "$buildSourceDirectory\$repo\$solutionName\SolutionPackage\$solutionName.cdsproj"
Expand All @@ -312,17 +311,20 @@ function Invoke-Clone-Or-Sync-Solution{
$cdsProjfolderPath = [System.IO.Path]::GetDirectoryName("$cdsProjPath")
Write-Host "Pointing to cdsproj folder path - " $cdsProjfolderPath
Set-Location -Path $cdsProjfolderPath
$syncCommand = "solution sync --processCanvasApps $processCanvasApps --packagetype Both --async"
$unpackfolderpath = "\\?\$cdsProjfolderPath\src"
# Trigger Sync
$syncCommand = "solution sync --processCanvasApps $processCanvasApps --packagetype Both --solution-folder ""$unpackfolderpath"" --async"
Write-Host "Triggering Sync - $syncCommand"
Invoke-Expression -Command "$pacexepath $syncCommand"
}
else {
if(Test-Path "$legacyFolderPath"){ # Legacy folder structure
Write-Host "Deleting legcay folder path - $legacyFolderPath"
Write-Host "Deleting legacy folder path - $legacyFolderPath"
# Delete "SolutionPackage" folder
Remove-Item "$legacyFolderPath" -recurse -Force
}

$unpackfolderpath = "\\?\$buildSourceDirectory\$repo\$solutionName\SolutionPackage"
# Trigger Clone
$cloneCommand = "solution clone -n $solutionName --processCanvasApps $processCanvasApps --outputDirectory ""$unpackfolderpath"" --packagetype Both --async"
Write-Host "Clone Command - $pacexepath $cloneCommand"
Expand Down Expand Up @@ -670,4 +672,4 @@ function Repopulate-csproj-File-Content{
Write-Host "Copy file path does not exists at $csprojCopyFilePath"
}
}
}
}
12 changes: 6 additions & 6 deletions PowerShell/tests/e2e-pipeline.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

param(
$Org, $Project, $BranchToTest, $SourceBranch, $BranchToCreate, $ExportPipelineName, $CommitMessage, $Data,
$Email, $Repo, $ServiceConnection, $SolutionName, $UserName, $PortalSiteName, $PublishCustomizations, $CommitScope
$Email, $Repo, $ServiceConnection, $SolutionName, $UserName, $PortalSiteName, $PublishCustomizations, $CommitScope, $BasicAccessToken
)

class Helper {
Expand All @@ -40,7 +40,7 @@ class Helper {
static [bool]QueueExportToGit($org, $project, $solutionName, $exportPipelineName, $body) {
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$token = [Helper]::AccessToken
$headers.Add("Authorization", "Bearer $token")
$headers.Add("Authorization", "Basic $token")
$headers.Add("Content-Type", "application/json")

$apiVersion = "?api-version=7.0"
Expand Down Expand Up @@ -72,7 +72,7 @@ class Helper {
}

BeforeAll {
[Helper]::AccessToken = (az account get-access-token | ConvertFrom-Json -Depth 100).accessToken
[Helper]::AccessToken = $BasicAccessToken
}

Describe 'E2E-Pipeline-Test' {
Expand Down Expand Up @@ -113,7 +113,7 @@ Describe 'E2E-Pipeline-Test' {
#Delete the existing pipelines to validate the creation of new pipelines during export.
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$token = [Helper]::AccessToken
$headers.Add("Authorization", "Bearer $token")
$headers.Add("Authorization", "Basic $token")
$headers.Add("Content-Type", "application/json")

$apiVersion = "?api-version=6.0-preview.2"
Expand Down Expand Up @@ -246,13 +246,13 @@ Describe 'E2E-Pipeline-Test' {
az repos pr update --id $pullRequestId --org $Org --status completed --squash true --merge-commit-message $CommitMessage --delete-source-branch true
# sleep for 15 seconds to ensure the pipeline to deploy to UAT environment is kicked off (may need to tweak)
Start-Sleep -Seconds 30
# Get the id of the pipeline to deploy to UAT and wait for it to successfully complete
# Get the id of the pipeline to deploy to UAT and complete
# TODO: See if we can improve the query below to be more precise. Works when there isn't another pipeline running triggered from the same solution branch
$result = az pipelines runs list --org $Org --project $Project --branch $SolutionName --top 1 --reason individualCI --query-order QueueTimeDesc
Write-Host "az pipelines runs list 2 : $result"
$result = $result | ConvertFrom-Json -Depth 100
$id = $result[0].id
[Helper]::WaitForPipelineToComplete($Org, $Project, $id) | Should -BeTrue
#[Helper]::WaitForPipelineToComplete($Org, $Project, $id) | Should -BeTrue
}

# Hard coding test name intentionally. Pester doesn't like it when it's a variable.
Expand Down