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
10 changes: 8 additions & 2 deletions .github/workflows/scripts/pwsh/Start-Build-Deploy-Solution.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
function Start-Build-Deploy-Solution ($files, $githubRef, $prHeadRef, $githubSha, $prHeadSha, $environment) {
function Start-Build-Deploy-Solution ($files, $githubRef, $prHeadRef, $githubSha, $prHeadSha, $environment) {
if ($files.Contains("for-test-automation.txt")){
echo "contains changes to a for-test-automation.txt file"
echo "skipping build-deploy-solution"
return
}

$filesArray = $files -split ','

$solutionDirectoriesArray = [System.Collections.ArrayList]::new()

foreach ($file in $filesArray) {
foreach ($file in $filesArray) {
if ($file.StartsWith("src/") -And $file.Contains("SolutionPackage")) {
$solutionDirectory = "{0}/{1}/{2}" -f $file.Split('/')
$solutionDirectoriesArray.Add($solutionDirectory)
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/tests/e2e.ps1
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
function e2e ($branchToTest, $solutionName, $environmentUrl, $sourceBranch, $branchToCreate, $commitMessage) {
$jsonTemplate = '
{
"solution_name":"$solutionName",
"environment_url":"$environmentUrl",
"source_branch":"$sourceBranch",
"branch_to_create":"$branchToCreate",
"commit_message":"$commitMessage",
"force_file_change":"true"
}'
$json = $ExecutionContext.InvokeCommand.ExpandString($jsonTemplate)
$workflowFile = "export-unpack-commit-solution.yml"

# run export-unpack-commit-solution.yml worklow
echo $json | gh workflow run $workflowFile --ref $branchToTest --json
WaitForWorkflowToComplete $workflowFile $branchToTest 5
gh workflow run $workflowFile --ref $branchToTest `
-f solution_name=$solutionName `
-f environment_url=$environmentUrl `
-f source_branch=$sourceBranch `
-f branch_to_create=$branchToCreate `
-f commit_message=$commitMessage `
-f force_file_change=true

WaitForWorkflowToComplete $workflowFile $branchToTest 5

# create a pr from branch with unpacked solution
$title = "[automated-test] testing workflow changes in $branchToTest branch"
$title = "[wf-e2e-test] testing workflow changes in $branchToTest branch"
gh pr create --base $sourceBranch --head $branchToCreate --title $title --body $title

# wait for the pr workflow to run
Expand All @@ -32,7 +29,7 @@ function e2e ($branchToTest, $solutionName, $environmentUrl, $sourceBranch, $bra
# deploy tagged solution
$dateFormat = Get-Date -Format "yyyyMMdd"
$tagFilter = "*$dateFormat*"
git fetch
git fetch --all --tags
$tags = git tag --list $tagFilter
$latestTag = $tags[-1]
$workflowFile = "deploy-tagged-solution-to-environment.yml"
Expand Down Expand Up @@ -60,7 +57,7 @@ function WaitForWorkflowToComplete ($workflowFile, $headBranch, $sleepSeconds) {
$workflowRunsJson = gh run list --workflow $workflowFile --json databaseId,headBranch,status
$workflowRunsArray = ConvertFrom-Json $workflowRunsJson
$testRun = $workflowRunsArray.Where({$_.headBranch -eq $headBranch -and $_.status -in "in_progress","queued"})[0]
gh run watch $testRun.databaseId
gh run watch $testRun.databaseId --interval 30
$status = gh run view $testRun.databaseId --exit-status
$hasExitCode1 = ($status -join '').Contains('exit code 1')
if ($hasExitCode1) {
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/workflows-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:

jobs:
workflows-pr:
runs-on: ubuntu-latest
runs-on: windows-latest
environment: marcsc-alm-demo-dev

steps:
Expand All @@ -28,10 +28,13 @@ jobs:
# Workflows cannot be dispatched with the standard GITHUB_TOKEN, so we use a token that can
GITHUB_TOKEN: ${{ secrets.WORKFLOW_DISPATCH_TOKEN }}
run: |
# runner doesn't have 2.4.0 yet, so forcing
choco upgrade gh

. ${{ env.workflow_tests_script_path }}/e2e.ps1

$prHeadRef = '${{ github.event.pull_request.head.ref }}'.Replace('refs/heads/','')
$branchToCreate = 'automated-test-' + $prHeadRef
$branchToCreate = 'wf-e2e-test-' + $prHeadRef

$params = @{
branchToTest = $prHeadRef
Expand Down