From b4439f4a6b12f89d755851b313eff0e9ea0b3ab5 Mon Sep 17 00:00:00 2001 From: Howard Wolosky Date: Thu, 28 May 2020 16:29:18 -0700 Subject: [PATCH] Fixing the CI build (#183) There were a number of issues going on: * Needed to force Pester `v4.10.1` for the install because `5.0` was just released and has some breaking changes to investigate. * Pester was failing to save its output because the output directory didn't exist. Without that, it couldn't actually publish the results. * The `ciOrganizationName` pipeline variable had a typo in it, which meant that we were passing an empty string as the `OrganizationName` to tests that needed it * We needed to ensure consistent line endings for `Tests/Config/Settings.ps1` so that the hash generated on all platforms (Windows/mac/Linux) would be the same. * GitHub changed the default HTML generated for README.md which was causing two RepositoryContents tests to fail. * Needed to make sure that the three platforms (Windows/mac/Linux) run the unit tests _serially_ instead of in parallel, because they each modify the shared state of the same account, and when running at the same time they were stomping over each other and causing erroneous failures. Resolves #182 --- .gitattributes | 4 ++++ CONTRIBUTING.md | 2 +- Tests/GitHubContents.tests.ps1 | 2 +- build/pipelines/azure-pipelines.ci.yaml | 4 ++++ build/pipelines/templates/run-unitTests.yaml | 5 +++-- 5 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..477d176 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Need to make sure that this file always has consistent line endings since we store the hash +# of it in GitHubConfiguration.ps1 in order to be able to determine if it has been modified +# or not. +Tests/Config/Settings.ps1 text eol=crlf \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e62fffd..1cf400f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -295,7 +295,7 @@ This module supports testing using the [Pester UT framework](https://github.com/ To install it: ```powershell -Install-Module -Name Pester +Install-Module -Name Pester -RequiredVersion 4.10.1 -AllowClobber -SkipPublisherCheck -Force ``` #### Configuring Your Environment diff --git a/Tests/GitHubContents.tests.ps1 b/Tests/GitHubContents.tests.ps1 index 554ce61..474d4f1 100644 --- a/Tests/GitHubContents.tests.ps1 +++ b/Tests/GitHubContents.tests.ps1 @@ -22,7 +22,7 @@ try # Need two separate blocks to set constants because we need to reference a constant from the first block in this block. @{ - htmlOutput = "

$repoGuid

" + htmlOutput = "

$repoGuid

" rawOutput = "# $repoGuid" }.GetEnumerator() | ForEach-Object { Set-Variable -Force -Scope Script -Option ReadOnly -Visibility Private -Name $_.Key -Value $_.Value diff --git a/build/pipelines/azure-pipelines.ci.yaml b/build/pipelines/azure-pipelines.ci.yaml index d294cc7..9adc9f1 100644 --- a/build/pipelines/azure-pipelines.ci.yaml +++ b/build/pipelines/azure-pipelines.ci.yaml @@ -30,13 +30,17 @@ jobs: - job: Linux pool: vmImage: 'ubuntu-16.04' + dependsOn: Windows # Run in series instead of parallel because the UT's are modifying the same shared state steps: + - template: ./templates/verify-testConfigSettingsHash.yaml - template: ./templates/run-staticAnalysis.yaml - template: ./templates/run-unitTests.yaml - job: macOS pool: vmImage: 'macOS-10.14' + dependsOn: Linux # Run in series instead of parallel because the UT's are modifying the same shared state steps: + - template: ./templates/verify-testConfigSettingsHash.yaml - template: ./templates/run-staticAnalysis.yaml - template: ./templates/run-unitTests.yaml diff --git a/build/pipelines/templates/run-unitTests.yaml b/build/pipelines/templates/run-unitTests.yaml index 58b8329..53d6482 100644 --- a/build/pipelines/templates/run-unitTests.yaml +++ b/build/pipelines/templates/run-unitTests.yaml @@ -15,17 +15,18 @@ steps: - powershell: | - Install-Module -Name Pester -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Force -Verbose + Install-Module -Name Pester -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -RequiredVersion 4.10.1 -Force -Verbose displayName: 'Install Pester' - powershell: | + $null = New-Item -Path ..\ -Name Pester -ItemType Directory -Force Invoke-Pester -CodeCoverage .\*.ps*1 -CodeCoverageOutputFile ../Pester/coverage.xml -CodeCoverageOutputFileFormat JaCoCo -EnableExit -Strict -OutputFile ../Pester/test-results.xml -OutputFormat NUnitXml workingDirectory: '$(System.DefaultWorkingDirectory)' displayName: 'Run Unit Tests via Pester' env: ciAccessToken: $(GitHubAccessToken) ciOwnerName: $(GitHubOwnerName) - ciOrganizatioName: $(GitHubOrganizationName) + ciOrganizationName: $(GitHubOrganizationName) - task: PublishTestResults@2 displayName: 'Publish Test Results'