Skip to content

Commit

Permalink
Calling of Split-Array caused wrong result in some situations (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
raandree authored Apr 3, 2023
1 parent fade0ef commit 389230e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 92 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Increase build speed of root configuration by only importing required Composites/Resources
- Added ''UseEnvironment'' parameter to cater for RSOP for identical node names in different environments
- Adding Home.md to wikiSource and correct casing.
- Redesign of the function Split-Array. Most of the time it was not working as expected, especially when requesting larger ChunkCounts (see AutomatedLab/AutomatedLab.Common/#118).
- Redesign of the function 'Split-Array'. Most of the time it was not working as expected, especially when requesting larger ChunkCounts (see AutomatedLab/AutomatedLab.Common/#118).
- Improved error handling when compiling MOF files.

### Fixed
Expand Down
93 changes: 5 additions & 88 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ variables:
testArtifactName: testResults
sourceFolderName: source
defaultBranch: main
Agent.Source.Git.ShallowFetchDepth: 0

stages:
- stage: Build
jobs:
- job: Build_Module
displayName: 'Build Module'
pool:
vmImage: 'windows-2019'
vmImage: 'windows-latest'
steps:
- pwsh: |
dotnet tool install --global GitVersion.Tool
Expand Down Expand Up @@ -61,7 +62,7 @@ stages:
- job: Test_HQRM
displayName: 'HQRM'
pool:
vmImage: 'windows-2019'
vmImage: 'windows-latest'
timeoutInMinutes: 0
steps:
- task: DownloadPipelineArtifact@2
Expand Down Expand Up @@ -89,7 +90,7 @@ stages:
- job: Test_Unit
displayName: 'Unit'
pool:
vmImage: 'windows-2019'
vmImage: 'windows-latest'
timeoutInMinutes: 0
steps:
- task: DownloadPipelineArtifact@2
Expand Down Expand Up @@ -122,77 +123,6 @@ stages:
#artifactName: 'CodeCoverageWindows' # Can be any, in the pipeline, unique name
parallel: true

# If several pipeline jobs should run unit tests, uncomment this:
## If several pipeline jobs are generating test result consider renaming this:
#- job: Test_Unit_Linux
# displayName: 'Unit Linux'
# pool:
# vmImage: 'ubuntu 16.04'
# timeoutInMinutes: 0
# steps:
# - task: DownloadPipelineArtifact@2
# displayName: 'Download Build Artifact'
# inputs:
# buildType: 'current'
# artifactName: $(buildArtifactName)
# targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
# - task: PowerShell@2
# name: test
# displayName: 'Run Unit Test'
# inputs:
# filePath: './build.ps1'
# arguments: "-Tasks test -PesterScript 'tests/Unit'"
# pwsh: true
# - task: PublishTestResults@2
# displayName: 'Publish Test Results'
# condition: succeededOrFailed()
# inputs:
# testResultsFormat: 'NUnit'
# testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
# # If several pipeline jobs are generating test result consider renaming this:
# testRunTitle: 'Unit Linux'
# - task: PublishPipelineArtifact@1
# displayName: 'Publish Test Artifact'
# inputs:
# targetPath: '$(buildFolderName)/$(testResultFolderName)/'
# # If several pipeline jobs are generating code coverage, consider renaming this:
# artifactName: 'CodeCoverageLinux' # Can be any, in the pipeline, unique name
# parallel: true

# - job: Test_Integration
# displayName: 'Integration'
# pool:
# vmImage: 'windows-2019'
# timeoutInMinutes: 0
# steps:
# - task: DownloadPipelineArtifact@2
# displayName: 'Download Build Artifact'
# inputs:
# buildType: 'current'
# artifactName: $(buildArtifactName)
# targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'
# - task: PowerShell@2
# name: configureWinRM
# displayName: 'Configure WinRM'
# inputs:
# targetType: 'inline'
# script: 'winrm quickconfig -quiet'
# pwsh: false
# - task: PowerShell@2
# name: test
# displayName: 'Run Integration Test'
# inputs:
# filePath: './build.ps1'
# arguments: "-Tasks test -CodeCoverageThreshold 0 -PesterScript 'tests/Integration'"
# pwsh: false
# - task: PublishTestResults@2
# displayName: 'Publish Test Results'
# condition: succeededOrFailed()
# inputs:
# testResultsFormat: 'NUnit'
# testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
# testRunTitle: 'Integration'

- job: Code_Coverage
displayName: 'Publish Code Coverage'
dependsOn: Test_Unit
Expand Down Expand Up @@ -220,20 +150,7 @@ stages:
# If several pipeline jobs are generating code coverage, set the correct artifact name:
artifactName: $(testArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)'
# If several pipeline jobs are generating code coverage, uncomment these tasks:
#- task: DownloadPipelineArtifact@2
# displayName: 'Download Test Artifact Linux'
# inputs:
# buildType: 'current'
# artifactName: 'CodeCoverageLinux'
# targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)'
#- task: PowerShell@2 # Merges the code coverage files.
# name: merge
# displayName: 'Merge Code Coverage files'
# inputs:
# filePath: './build.ps1'
# arguments: '-tasks merge'
# pwsh: true

- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage to Azure DevOps'
inputs:
Expand Down
11 changes: 9 additions & 2 deletions source/Public/Get-FilteredConfigurationData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ function Get-FilteredConfigurationData
$CurrentJobNumber--
if ($TotalJobCount -gt 1)
{
$allDatumNodes = Split-Array -List $allDatumNodes -ChunkCount $TotalJobCount
try
{
$allDatumNodes = Split-Array -List $allDatumNodes -ChunkCount $TotalJobCount -ErrorAction Stop
}
catch
{
Write-Error -Exception $_.Exception -Message "Error calling 'Split-Array': $($_.Exception.Message). Please make sure the 'TotalJobCount' is not greater than the number of nodes." -ErrorAction Stop
}
$allDatumNodes = @($allDatumNodes[$CurrentJobNumber].ToArray())
}
$allDatumNodes = @($allDatumNodes[$CurrentJobNumber])

return @{
AllNodes = $allDatumNodes
Expand Down
2 changes: 1 addition & 1 deletion source/Public/Split-Array.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Split-Array

if (-not $AllowEmptyChunks -and ($list.Count -lt $ChunkCount))
{
Write-Error "List count ($($List.Count)) is smaller than ChunkCount ($ChunkCount).)"
Write-Error "List count ($($List.Count)) is smaller than ChunkCount ($ChunkCount)."
return
}

Expand Down

0 comments on commit 389230e

Please sign in to comment.