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..0b35c229 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 @@ -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" @@ -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) { diff --git a/.github/workflows/workflows-pr.yml b/.github/workflows/workflows-pr.yml index c29f9d8f..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,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