From 34e41c29d19040d6e23fe34bd0e0eca900bceff7 Mon Sep 17 00:00:00 2001 From: devkeydet Date: Mon, 10 Jan 2022 08:39:36 -0500 Subject: [PATCH 1/4] #208 --- .../scripts/pwsh/Start-Build-Deploy-Solution.ps1 | 10 ++++++++-- .github/workflows/tests/e2e.ps1 | 2 +- .github/workflows/workflows-pr.yml | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/pwsh/Start-Build-Deploy-Solution.ps1 b/.github/workflows/scripts/pwsh/Start-Build-Deploy-Solution.ps1 index eb5c8078..c39505d6 100644 --- a/.github/workflows/scripts/pwsh/Start-Build-Deploy-Solution.ps1 +++ b/.github/workflows/scripts/pwsh/Start-Build-Deploy-Solution.ps1 @@ -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) diff --git a/.github/workflows/tests/e2e.ps1 b/.github/workflows/tests/e2e.ps1 index 65be809e..28d8c7bd 100644 --- a/.github/workflows/tests/e2e.ps1 +++ b/.github/workflows/tests/e2e.ps1 @@ -32,7 +32,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" diff --git a/.github/workflows/workflows-pr.yml b/.github/workflows/workflows-pr.yml index c29f9d8f..057e7473 100644 --- a/.github/workflows/workflows-pr.yml +++ b/.github/workflows/workflows-pr.yml @@ -31,7 +31,7 @@ jobs: . ${{ 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 From a2c51f4a272be0060e425b31e8599f66cdf957d1 Mon Sep 17 00:00:00 2001 From: devkeydet Date: Mon, 10 Jan 2022 08:56:45 -0500 Subject: [PATCH 2/4] updates for #210 --- .github/workflows/tests/e2e.ps1 | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests/e2e.ps1 b/.github/workflows/tests/e2e.ps1 index 28d8c7bd..ac050a06 100644 --- a/.github/workflows/tests/e2e.ps1 +++ b/.github/workflows/tests/e2e.ps1 @@ -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 From f68ba6b52619d673da37d336eb2e7b1925b00e73 Mon Sep 17 00:00:00 2001 From: devkeydet Date: Mon, 10 Jan 2022 11:45:50 -0500 Subject: [PATCH 3/4] #210 --- .github/workflows/workflows-pr.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflows-pr.yml b/.github/workflows/workflows-pr.yml index 057e7473..4397f7a2 100644 --- a/.github/workflows/workflows-pr.yml +++ b/.github/workflows/workflows-pr.yml @@ -14,7 +14,7 @@ env: jobs: workflows-pr: - runs-on: ubuntu-latest + runs-on: windows-latest environment: marcsc-alm-demo-dev steps: @@ -28,6 +28,9 @@ 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/','') From fc8f73caa189cec58992e403c39630e8dbe33b10 Mon Sep 17 00:00:00 2001 From: devkeydet Date: Tue, 11 Jan 2022 05:46:07 -0500 Subject: [PATCH 4/4] changed interval for gh run watch --- .github/workflows/tests/e2e.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests/e2e.ps1 b/.github/workflows/tests/e2e.ps1 index ac050a06..0b35c229 100644 --- a/.github/workflows/tests/e2e.ps1 +++ b/.github/workflows/tests/e2e.ps1 @@ -57,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) {