Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing ConvertTo-Expression with content from iRon7's repo #57

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
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
17 changes: 17 additions & 0 deletions .build/FixConvertToExpressionContent.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
task FixConvertToExpressionContent {

$filePath = Join-Path -Path $SourcePath -ChildPath 'Modules\ConvertToExpression\ConvertToExpression.psm1'

$fileContent = Get-Content -Path $filePath -Raw
$fileContent = $fileContent.Replace('using namespace System.Management.Automation', '')
$fileContent = $fileContent.Replace('PSMethod', 'System.Management.Automation.PSMethod')

if (-not $fileContent.StartsWith('function'))
{
$fileContent = $fileContent.Insert(0, "function ConvertTo-Expression {`n")
$fileContent += "}`n"
}

$fileContent | Set-Content -Path $filePath -Encoding UTF8

}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Based on [style guidelines](https://dsccommunity.org/styleguidelines/localizatio
- Updated the README.md with new section and updated the links.
- Renamed class files adding a prefix on each file so the task `Generate_Wiki_Content`
works (reported issue https://github.com/dsccommunity/DscResource.DocGenerator/issues/132).
- Removed code of `ConvertTo-Expression` and injecting it from https://github.com/iRon7/ConvertTo-Expression.

### Removed

Expand Down
6 changes: 6 additions & 0 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@
'DscResource.AnalyzerRules' = 'latest'
xDscResourceDesigner = 'latest'
'DscResource.DocGenerator' = 'latest'

ConvertToExpression = @{
DependencyType = 'FileDownload'
Source = 'https://raw.githubusercontent.com/iRon7/ConvertTo-Expression/93cd563fb9a1dd5b6fc9c73d6f3b95f6f2ebeca8/ConvertTo-Expression.ps1'
Target = 'source\Modules\ConvertToExpression\ConvertToExpression.psm1'
}
}
21 changes: 19 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ stages:
- job: Package_Module
displayName: 'Package Module'
pool:
vmImage: 'ubuntu-latest'
vmImage: 'windows-latest'
steps:

- pwsh: |
dotnet tool install --global GitVersion.Tool
$gitVersionObject = dotnet-gitversion | ConvertFrom-Json
Expand All @@ -36,15 +37,17 @@ stages:
}
Write-Host -Object "##vso[build.updatebuildnumber]$($gitVersionObject.FullSemVer)"
displayName: Calculate ModuleVersion (GitVersion)

- task: PowerShell@2
name: package
displayName: 'Build & Package Module'
inputs:
filePath: './build.ps1'
arguments: '-ResolveDependency -tasks pack'
pwsh: true
pwsh: false
env:
ModuleVersion: $(NuGetVersionV2)

- task: PublishPipelineArtifact@1
displayName: 'Publish Build Artifact'
inputs:
Expand All @@ -68,13 +71,15 @@ stages:
buildType: 'current'
artifactName: $(buildArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'

- task: PowerShell@2
name: test
displayName: 'Run HQRM Test'
inputs:
filePath: './build.ps1'
arguments: '-Tasks hqrmtest'
pwsh: false

- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
Expand All @@ -95,20 +100,23 @@ stages:
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: false

- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: '$(buildFolderName)/$(testResultFolderName)/NUnit*.xml'
testRunTitle: 'Unit'

- task: PublishPipelineArtifact@1
displayName: 'Publish Test Artifact'
inputs:
Expand All @@ -128,23 +136,27 @@ stages:
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

- powershell: |
Set-Service -Name wuauserv -StartupType Manual -Verbose
Start-Service -name wuauserv -Verbose

- 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()
Expand All @@ -166,19 +178,22 @@ stages:
buildType: 'current'
artifactName: $(buildArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)'

- task: DownloadPipelineArtifact@2
displayName: 'Download Test Artifact'
inputs:
buildType: 'current'
artifactName: $(testArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)'

- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage to Azure DevOps'
condition: succeededOrFailed()
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: '$(Build.SourcesDirectory)/$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml'
pathToSources: '$(Build.SourcesDirectory)/$(sourceFolderName)/'

- script: |
bash <(curl -s https://codecov.io/bash) -f "./$(buildFolderName)/$(testResultFolderName)/JaCoCo_coverage.xml"
displayName: 'Publish Code Coverage to Codecov.io'
Expand Down Expand Up @@ -206,6 +221,7 @@ stages:
buildType: 'current'
artifactName: $(buildArtifactName)
targetPath: '$(Build.SourcesDirectory)/$(buildArtifactName)'

- task: PowerShell@2
name: publishRelease
displayName: 'Publish Release'
Expand All @@ -218,6 +234,7 @@ stages:
GalleryApiToken: $(GalleryApiToken)
ReleaseBranch: $(defaultBranch)
MainGitBranch: $(defaultBranch)

- task: PowerShell@2
name: sendChangelogPR
displayName: 'Send Changelog PR'
Expand Down
8 changes: 5 additions & 3 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ BuildWorkflow:

build:
- Clean
- FixConvertToExpressionContent
- Build_Module_ModuleBuilder
- Build_NestedModules_ModuleBuilder
- Create_changelog_release_output
Expand All @@ -53,8 +54,6 @@ BuildWorkflow:
- Publish_Release_To_GitHub
- Publish_GitHub_Wiki_Content



####################################################
# PESTER Configuration #
####################################################
Expand All @@ -63,11 +62,12 @@ Pester:
OutputFormat: NUnitXML
ExcludeFromCodeCoverage:
- Modules/DscResource.Common
- Modules/ConvertToExpression
Script:
- tests/Unit
ExcludeTag:
Tag:
CodeCoverageThreshold: 25
CodeCoverageThreshold: 6
CodeCoverageOutputFile: JaCoCo_coverage.xml
CodeCoverageOutputFileEncoding: ascii

Expand All @@ -79,8 +79,10 @@ DscTest:
Tag:
ExcludeSourceFile:
- output
- Modules/ConvertToExpression
ExcludeModuleFile:
- Modules/DscResource.Common
- Modules/ConvertToExpression

ModuleBuildTasks:
Sampler:
Expand Down
3 changes: 3 additions & 0 deletions source/Classes/005.RoleCapabilitiesUtility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ $modulePath = Join-Path -Path $PSScriptRoot -ChildPath Modules
Import-Module -Name (Join-Path -Path $modulePath -ChildPath DscResource.Common)
Import-Module -Name (Join-Path -Path $modulePath -ChildPath (Join-Path -Path JeaDsc.Common -ChildPath JeaDsc.Common.psm1))

Import-Module -Name (Join-Path -Path $modulePath -ChildPath ConvertToExpression)
Import-Module -Name (Join-Path -Path $modulePath -ChildPath (Join-Path -Path ConvertToExpression -ChildPath ConvertToExpression.psm1))

$script:localizedDataRole = Get-LocalizedData -DefaultUICulture en-US -FileName 'JeaRoleCapabilities.strings.psd1'

class RoleCapabilitiesUtility
Expand Down
4 changes: 1 addition & 3 deletions source/JeaDsc.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

NestedModules = @()

FunctionsToExport = @(
'ConvertTo-Expression'
)
FunctionsToExport = @()

CmdletsToExport = @()

Expand Down
1 change: 1 addition & 0 deletions source/Modules/ConvertToExpression/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading