You are welcome to share any comments or issues you having around this process in the Discord or Slack #DSC channel.
Before you start, here’s an overview of what the new CI looks like:
NOTE: The build is running on Linux in the CI pipeline to be able to support cross-platform DSC resources, so that makes all paths case-sensitive! Have that in mind when updating paths and folders in the configuration files. Make sure they match the repository, or change the repository file and folder names).
We are moving away from AppVeyor to Azure DevOps because Azure Pipelines gives us longer run time per job plus parallel jobs on a free account (for open source projects).
Also, we are no longer requiring signing of CLA since the modules are now part of DSC Community.
This will prepare the old releases to look like the new automatic releases
that will be done once a repository has been converted. For example the
tags will help GitVersion
to determine the next version, and the
GitHub Releases is to connect each tag with a GitHub Release and update
the release notes for that release.
You can use the script Convert-GitTagForDsc.ps1 to re-create all existing tags. You run it with the following.
# Move to the local repo
cd c:\source\{repositoryFolder}
# Make sure you have the remote names to upstream and fork.
git remote -v
# Get latest changes so we get all commits that the tags uses
git checkout master
git fetch origin master # origin is the remote pointing to upstream DSC Community repository.
git rebase origin/master
git push my master --force # my is the remote pointing to fork
<#
Remote - remote name to your fork
Upstream - remote name to the upstream DSC Community repository.
DeleteOldTags - will remove the old tags.
You can run it with parameter WhatIf to see what it will do.
#>
.\Convert-GitTagForDsc.ps1 -DeleteOldTags -Remote 'my' -Upstream 'origin' -Verbose
Make sure all the previous releases to PowerShell Gallery has tags. If there are any tags missing then create those tags.
NOTE: At least the latest (newest) release MUST have a tag in the new format, otherwise GitVersion will not evaluate the versions correctly.
If there are no missing tags, then you MUST re-create the last tag so that it is using semantic versioning and the correct format for the tag. See article How To Delete Local and Remote Tags on Git. If you ran the script in the previous section this have probably been resolved already.
git tag
. Compare the tags reported by git tag
and the actual
releases in the change log and or the PowerShell Gallery.git log --pretty=oneline
and search up the SHA for each release commit (the description could be
something like Merge pull request #xxxx from PowerShell/dev
).v13.1.0
on the specific
commit and adding a descriptive text on the tag.
git tag -a v13.1.0 596ff25a61099b312a6f9e2eb2c6dccc9597ac28 -m "Release of version 13.1.0.0 of {RepositoryName}"
git tag
should list the new tags, and running git show v13.1.0
would show a specific tag.git push origin --tags # origin is the remote pointing to upstream
git push my --tags # my is the remote pointing to fork
For each tag in GitHub create a GitHub release by copying the corresponding change log entries to the release notes of the GitHub release.
v13.2.0
and in the description block
paste in the change log entries.NOTE: You must be an elevated administrator to install this.
choco install GitVersion.Portable
Create a new working branch based on dev branch.
cd c:\source\{repositoryName}
git checkout dev
git fetch origin dev # origin is the remote pointing to upstream
git rebase origin/dev
git push my dev --force # my is the remote pointing to fork
git checkout -b add-new-ci
Suggest adding commits to this working branch as necessary when changing files in each section.
Run the following to get the necessary pipeline files and folders that we need to covert the module.
Overwrite any files it suggest, then check the git
diff if you need to
keep anything. Remove any .bak files that are created if they ar no longer
needed.
cd C:\source\{RepositoryName}
Install-Module -Name 'Sampler' -Scope 'CurrentUser'
$samplerModule = Import-Module -Name Sampler -PassThru
$invokePlasterParameters = @{
TemplatePath = Join-Path -Path $samplerModule.ModuleBase -ChildPath 'Templates/Sampler'
DestinationPath = '..\'
ModuleType = 'dsccommunity'
ModuleName = Split-path -Leaf $PWD
SourceDirectory = 'source'
}
Invoke-Plaster @invokePlasterParameters
We must change the folder structure because that is a prerequisite for the build and automatic release.
source
(if they exist).
Tests
to lower-case tests
.
git mv Tests tests2
git mv tests2 tests
SqlServerDsc.psd1
into the source
folder. Overwrite any current file..codecov.yml
.appveyor.yml
. Please make a note of anything specific
in this file meant to help run tests, like installation of features
etcetera. You need to add it to the new pipeline later.Change the module manifest in the source folder, e.g. SqlServerDsc.psd1
.
$moduleName = '{ModuleName}'
$powerShellVersion = '5.1' # Must be 5.1 to support the property DscResourcesToExport. Change manually after.
# Temporarily install the module from the PowerShell Gallery to get the DSC resource names.
Install-Module -Name $moduleName -Scope CurrentUser
$dscResourcesToExport = (Get-DscResource -Module $moduleName).Name
Uninstall-Module -Name $moduleName -Force
$manifestPath = "source\$($moduleName).psd1"
$updateModuleManifestParameters = @{
Author = 'DSC Community'
CompanyName = 'DSC Community'
Copyright = 'Copyright the DSC Community contributors. All rights reserved.'
DscResourcesToExport = $dscResourcesToExport
IconUri = 'https://dsccommunity.org/images/DSC_Logo_300p.png'
LicenseUri = "https://github.com/dsccommunity/$moduleName/blob/master/LICENSE"
Path = $manifestPath
PreRelease = 'preview'
ProjectUri = "https://github.com/dsccommunity/$moduleName"
ReleaseNotes = ' '
ModuleVersion = '0.0.1' # Module Version is now controlled by GitVersion
PowerShellVersion = $powerShellVersion
}
Update-ModuleManifest @updateModuleManifestParameters
'*'
is not optimal. Update or
add the export properties to optimize discovery. If any of these are
already exporting objects then leave that export property as is.
# Functions to export from this module
FunctionsToExport = @()
# Cmdlets to export from this module
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = @()
# Aliases to export from this module
AliasesToExport = @()
README.md
Branches
section of the file README.md
(if it exists).Note: To get the definition id, browse to the pipeline in the DSC Community Azure DevOps organization and look in the URL, e.g. https://dev.azure.com/dsccommunity/xFailOverCluster/_build?definitionId=5&_a=summary You have to get back to this once the pipeline is configured!
# {RepositoryName}
[![Build Status](https://dev.azure.com/dsccommunity/{repositoryName}/_apis/build/status/dsccommunity.{repositoryName}?branchName=master)](https://dev.azure.com/dsccommunity/{repositoryName}/_build/latest?definitionId={definitionId}&branchName=master)
![Azure DevOps coverage (branch)](https://img.shields.io/azure-devops/coverage/dsccommunity/{repositoryName}/{definitionId}/master)
[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/dsccommunity/{repositoryName}/{definitionId}/master)](https://dsccommunity.visualstudio.com/{repositoryName}/_test/analytics?definitionId={definitionId}&contextType=build)
[![PowerShell Gallery (with prereleases)](https://img.shields.io/powershellgallery/vpre/{repositoryName}?label={repositoryName}%20Preview)](https://www.powershellgallery.com/packages/{repositoryName}/)
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/{repositoryName}?label={repositoryName})](https://www.powershellgallery.com/packages/{repositoryName}/)
## Code of Conduct
This project has adopted this [Code of Conduct](CODE_OF_CONDUCT.md).
## Releases
For each merge to the branch `master` a preview release will be
deployed to [PowerShell Gallery](https://www.powershellgallery.com/).
Periodically a release version tag will be pushed which will deploy a
full release to [PowerShell Gallery](https://www.powershellgallery.com/).
## Contributing
Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing).
[...](/Examples/Resources/...)
) to the
correct path [...](/source/Examples/Resources/...)
https://github.com/PowerShell/...
to
https://github.com/dsccommunity/...
.CHANGELOG.md
NOTE: Build pipeline uses the format of keep a changelog so we need to change the changelog accordingly.
# Change log for {RepositoryName}
The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- SqlServerDsc
- Added automatic release with a new CI pipeline.
### Changed
- SqlServerDsc
- Add .gitattributes file to checkout file correctly with CRLF.
- Updated .vscode/analyzersettings.psd1 file to correct use PSSA rules
and custom rules in VS Code.
- Fix hashtables to align with style guideline ([issue #1437](https://github.com/dsccommunity/{RepositoryName}/issues/1437)).
- SqlServerMaxDop
- Fix line endings in code which did not use the correct format.
### Deprecated
- None
### Removed
- None
### Fixed
- None
### Security
- None
git log --tags --simplify-by-decoration --pretty="format:%ai %d"
## [13.2.0.0] - 2019-09-18
### Changed
- Changes to SqlServerDsc
- Fix keywords to lower-case to align with guideline.
- Fix keywords to have space before a parenthesis to align with guideline.
- Fix typo in SqlSetup strings ([issue #1419](https://github.com/dsccommunity/{RepositoryName}/issues/1419)).
https://github.com/PowerShell/
to
https://github.com/dsccommunity/
..github/PULL_REQUEST_TEMPLATE.md
Make sure this file is updated to reflect having a CHANGELOG.md. The following is a proposed file but can changed to reflected other needs.
<!--
Thanks for submitting a Pull Request (PR) to this project. Your contribution to this project
is greatly appreciated!
Please prefix the PR title with the resource name, e.g. 'ResourceName: My short description'.
If this is a breaking change, then also prefix the PR title with 'BREAKING CHANGE:',
e.g. 'BREAKING CHANGE: ResourceName: My short description'.
You may remove this comment block, and the other comment blocks, but please keep the headers
and the task list.
-->
#### Pull Request (PR) description
<!--
Replace this comment block with a description of your PR. Also, make sure you have updated the
CHANGELOG.md, see the task list below. An entry in the CHANGELOG.md is mandatory for all PRs.
-->
#### This Pull Request (PR) fixes the following issues
<!--
If this PR does not fix an open issue, replace this comment block with None. If this PR
resolves one or more open issues, replace this comment block with a list of the issues using
a GitHub closing keyword, e.g.:
- Fixes #123
- Fixes #124
-->
#### Task list
<!--
To aid community reviewers in reviewing and merging your PR, please take the time to run
through the below checklist and make sure your PR has everything updated as required.
Change to [x] for each task in the task list that applies to your PR. For those task that
don't apply to you PR, leave those as is.
-->
- [ ] Added an entry to the change log under the Unreleased section of the file CHANGELOG.md.
Entry should say what was changed and how that affects users (if applicable), and
reference the issue being resolved (if applicable).
- [ ] Resource documentation added/updated in README.md.
- [ ] Resource parameter descriptions added/updated in README.md, schema.mof and comment-based
help.
- [ ] Comment-based help added/updated.
- [ ] Localization strings added/updated in all localization files as appropriate.
- [ ] Examples appropriately added/updated.
- [ ] Unit tests added/updated. See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines).
- [ ] Integration tests added/updated (where possible). See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines).
- [ ] New/changed code adheres to [DSC Community Style Guidelines](https://dsccommunity.org/styleguidelines).
.github/ISSUE_TEMPLATE/Problem_with_resource.md
Change the last line to the following, removing the sentence within the parenthesis.
#### Version of the DSC module that was used
.MetaTestOptIn.json
since it is no longer used.
We opt-in to everything by default, to opt-out see the section on
testing.Copyright (c) DSC Community contributors.
./source/en-US
to describe the module. Change as necessary, like module name. E.g.
TOPIC
about_{RepositoryName}
SHORT DESCRIPTION
DSC resources for deployment and configuration of {Product Name}.
LONG DESCRIPTION
This module contains DSC resources for deployment and configuration of {Product Name}.
EXAMPLES
PS C:\> Get-DscResource -Module {RepositoryName}
NOTE:
Thank you to the DSC Community contributors who contributed to this module by
writing code, sharing opinions, and provided feedback.
TROUBLESHOOTING NOTE:
Go to the Github repository for read about issues, submit a new issue, and read
about new releases. https://github.com/dsccommunity/{RepositoryName}
SEE ALSO
- https://github.com/dsccommunity/{RepositoryName}
KEYWORDS
DSC, DscResource, {productTag}
build.yaml
Modules
if the folder exist under the source folder,
or if there are any helper modules (which need to be moved to the Modules
folder).
CopyPaths:
- Modules
RequiredModules.psd1
RequiredModules.psd1
. We need to pin the version
we should use for both an example and an integration tests.
NOTE: We must pin the version due to how the DSC resource modules are detected when configuration files are compiled. If we do not pin versions the CI pipeline will se duplicate modules due to the folder structure the CI pipeline is using when building the pipeline. E.g. paths used
\output\;\output\RequiredModules
.
# Prerequisites modules needed for examples and integration tests of
# the {RepositoryName} module.
PSDscResources = '2.12.0.0'
StorageDsc = '4.9.0.0'
NetworkingDsc = '7.4.0.0'
GitVersion.yml
next-version
to the next minor version (using semantic
versioning). This version is from where gitversion
tries to evaluate
version. For example if the latest release was 13.2.0
(or 13.2.0.0
)
then set next-version
to 13.3.0
.BE AWARE: If the last version released was
13.2.0
and you want to raise the major version to14.0.0
you cannot setnext-version
to14.0.0
. If you want next released version to be14.0.0
then setnext-version
to13.3.0
and then add a commit with the wordbreaking
ormajor
in the commit message.
If there are any helper modules then move those to the Modules
folder
under the source folder (and change the code accordingly). Then for each
helper module these steps should be done.
New-ModuleManifest
, e.g.$helperModuleName = '{HelperModuleName}'
# Need the full path to work with WriteAllText().
$helperModulePath = "$PWD\source\Modules\$helperModuleName"
$manifestFile = "$HelperModulePath\$helperModuleName.psd1"
Import-Module $helperModulePath
$functionsToExport = (Get-Command -Module $helperModuleName).Name
$newModuleManifestParameters = @{
Path = $manifestFile
Author = 'DSC Community'
CompanyName = 'DSC Community'
Copyright = 'Copyright the DSC Community contributors. All rights reserved.'
Description = "Functions used by the DSC resources in $helperModuleName."
RootModule = "$($helperModuleName).psm1"
FunctionsToExport = $functionsToExport
CmdletsToExport = ''
VariablesToExport = ''
AliasesToExport = ''
}
New-ModuleManifest @newModuleManifestParameters
# Converts the file to UTF-8 (without BOM)
$content = Get-Content -Path $manifestFile -Encoding 'Unicode' -Raw
[System.IO.File]::WriteAllText($manifestFile, $content, [System.Text.Encoding]::ASCII)
Export-ModuleMember
cmdlet from the module script file.If an example uses an external module in the configuration then that module
must use a pinned version. The pinned version must be the same version that
was pinned in the file RequiredModules.psd1
(or make sure to pin the same
version there too). Example of pinning a version in the configuration file.
Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0'
Import-DscResource -ModuleName 'StorageDsc' -ModuleVersion '4.9.0.0'
This requires that all steps above have been done. Running this command will make sure the dependencies are resolved and prepare the build environment.
This must be run each time changes are made to the file RequiredModules.psd1
,
or if there are new releases of external modules listed in the file
RequiredModules.psd1
.
NOTE: This does not install anything, it downloads the prerequisites into the
output
folder.
.\build.ps1 -ResolveDependency -Tasks noop
This builds the module after which for example tests can be run on the built
module. The built module will look the same as the one that is release.
GitVersion
is used to determine the next version if it is installed.
This must be run each time changes have been made to files in the source folder.
.\build.ps1 -Tasks build
For examples that are published to the Gallery the Script File Information
section need to be changed. This script must be run after the build task
have been run because it needs to resolve the modules in a $PSModulePath
.
Update parameter Version
as needed.
NOTE: The cmdlet
Update-ScriptFileInfo
needs to be able to resolve modules. If an example is dependent on other modules, e.g. PSDscResources, they need to be present in a$PSModulePath
. If not you will get a parse error. Dependent modules should have already been pinned in the fileRequiredModules.psd1
and in each example file.
$moduleName = '<repositoryName>'
Get-ChildItem -Path '.\source\Examples' -Filter '*.ps1' -Recurse | % {
Update-ScriptFileInfo -Path $_.FullName `
-Version '1.0.1' `
-Author 'DSC Community' `
-CompanyName 'DSC Community' `
-Copyright 'DSC Community contributors. All rights reserved.' `
-LicenseUri "https://github.com/dsccommunity/$moduleName/blob/master/LICENSE" `
-ProjectUri "https://github.com/dsccommunity/$moduleName" `
-ReleaseNotes 'Updated author, copyright notice, and URLs.' `
-IconUri 'https://dsccommunity.org/images/DSC_Logo_300p.png'
}
build.yaml
test:
task, remove the activity hqrmtest
.Pester
update the key Script
to this.
Script:
- tests/Unit
Pester
remove all the items from the key ExcludeTag
.
Remove these:
- helpQuality
- FunctionalQuality
- TestQuality
From all unit tests remove the header that was part
of the previous test framework. Everything between and including
#region HEADER
and #endregion HEADER
(!! beware not to delete any variables and
any helper modules, that need to be imported). Replace it with the following code,
add the code inside the function Invoke-TestSetup
. Also update the function
Invoke-TestCleanup
. Make sure the Invoke-TestSetup
is called outside the try
-block.
function Invoke-TestSetup
{
try
{
Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop'
}
catch [System.IO.FileNotFoundException]
{
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.'
}
$script:testEnvironment = Initialize-TestEnvironment `
-DSCModuleName $script:dscModuleName `
-DSCResourceName $script:dscResourceName `
-ResourceType 'Mof' `
-TestType 'Unit'
}
function Invoke-TestCleanup
{
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}
Invoke-TestSetup
try
{
InModuleScope $script:dscResourceName {
# All tests goes here
}
}
finally
{
Invoke-TestCleanup
}
From all integration tests remove the header that was part
of the previous test framework. Everything between and including
#region HEADER
and #endregion HEADER
. Replace it with the following
code. Make sure to change the parameter of the cmdlet Restore-TestEnvironment
at the end of the file too.
try
{
Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop'
}
catch [System.IO.FileNotFoundException]
{
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.'
}
$script:testEnvironment = Initialize-TestEnvironment `
-DSCModuleName $script:dscModuleName `
-DSCResourceName $script:dscResourceName `
-ResourceType 'Mof' `
-TestType 'Integration'
Change the parameter of the cmdlet Restore-TestEnvironment
at the end
of the file.
finally
{
Restore-TestEnvironment -TestEnvironment $script:testEnvironment
}
If an integration tests uses an external module in the configuration then
that module must use a pinned version. The pinned version must be the same
version that was pinned in the file RequiredModules.psd1
(or make sure to
pin the same version there too). Example of pinning a version in the
configuration file.
Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0'
Import-DscResource -ModuleName 'StorageDsc' -ModuleVersion '4.9.0.0'
For any helper modules, add this to each unit test (and remove any other code that imported the helper module previously).
#region HEADER
$script:projectPath = "$PSScriptRoot\..\.." | Convert-Path
$script:projectName = (Get-ChildItem -Path "$script:projectPath\*\*.psd1" | Where-Object -FilterScript {
($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and
$(try { Test-ModuleManifest -Path $_.FullName -ErrorAction Stop } catch { $false })
}).BaseName
$script:parentModule = Get-Module -Name $script:projectName -ListAvailable | Select-Object -First 1
$script:subModulesFolder = Join-Path -Path $script:parentModule.ModuleBase -ChildPath 'Modules'
Remove-Module -Name $script:parentModule -Force -ErrorAction 'SilentlyContinue'
$script:subModuleName = (Split-Path -Path $PSCommandPath -Leaf) -replace '\.Tests.ps1'
$script:subModuleFile = Join-Path -Path $script:subModulesFolder -ChildPath "$($script:subModuleName)"
Import-Module $script:subModuleFile -Force -ErrorAction 'Stop'
#endregion HEADER
InModuleScope $script:subModuleName {
# The unit tests
}
Make sure all tests have been updated as mentioned previously.
This runs all the unit tests for the module. It runs the tests that are
configured under the key Script
(under the key Pester
) in the file
build.yaml
.
Remember to run the build task if any file has been changed in the source folder.
.\build.ps1 -Tasks hqrmtest
.\build.ps1 -Tasks test
To run the integration tests you will need to add the parameter
PesterScript
, e.g..\build.ps1 -Tasks test -PesterScript 'tests/Integration'.
Only do this in a lab environment or CI environment.
azure-pipelines.yml
Build_artefact
with Build
(in one locations).test_module
with the following.
- stage: Test
dependsOn: Build
jobs:
- job: Test_HQRM
displayName: 'HQRM'
pool:
vmImage: 'windows-2019'
timeoutInMinutes: 0
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'output'
downloadPath: '$(Build.SourcesDirectory)'
- 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()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'output/testResults/NUnit*.xml'
testRunTitle: 'HQRM'
- job: Test_Unit
displayName: 'Unit'
pool:
vmImage: 'windows-2019'
timeoutInMinutes: 0
steps:
- powershell: |
$repositoryOwner,$repositoryName = $env:BUILD_REPOSITORY_NAME -split '/'
echo "##vso[task.setvariable variable=RepositoryOwner;isOutput=true]$repositoryOwner"
echo "##vso[task.setvariable variable=RepositoryName;isOutput=true]$repositoryName"
name: dscBuildVariable
displayName: 'Set Environment Variables'
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'output'
downloadPath: '$(Build.SourcesDirectory)'
- 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: 'output/testResults/NUnit*.xml'
testRunTitle: 'Unit (Windows Server Core)'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
condition: succeededOrFailed()
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: 'output/testResults/CodeCov*.xml'
pathToSources: '$(Build.SourcesDirectory)/output/$(dscBuildVariable.RepositoryName)'
- job: Test_Integration
displayName: 'Integration'
pool:
vmImage: 'windows-2019'
timeoutInMinutes: 0
steps:
- task: DownloadBuildArtifacts@0
displayName: 'Download Build Artifact'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'output'
downloadPath: '$(Build.SourcesDirectory)'
- 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 -PesterScript 'tests/Integration' -CodeCoverageThreshold 0"
pwsh: false
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'output/testResults/NUnit*.xml'
testRunTitle: 'Integration (Windows Server Core)'
Deploy
.
dependsOn
replace test_module
to Test
.contains(variables['System.TeamFoundationCollectionUri'], 'synedgy')
replace 'synedgy'
with 'dsccommunity'
.Test_Integration
can be removed. If there are no integration tests yet the job can still
be present so that once an integration tests is added it will be tested.
The job will pass if no integration tests are found (it will even pass if
no Integration
folder exist).vmImage
to a supported image listed in the section
Use a Microsoft-hosted agent.appveyor.yml
. For example to install a feature, add this
before the task Test
in the job Test_Integration
.
- powershell: |
Install-WindowsFeature -IncludeAllSubFeature -IncludeManagementTools -Name 'Web-Server'
name: InstallWebServerFeature
PesterScript
, e.g. ./build.ps1 -Tasks test -PesterScript 'tests/Integration'
.
Pester:
# Run the script in order. First all of unit tests in no particular order,
# and then all the integration tests in a specific group order.
- tests/Unit
# Group 1
- tests/Integration/MSFT_SqlSetup.Integration.Tests.ps1
# Group 2
- tests/Integration/MSFT_SqlAgentAlert.Integration.Tests.ps1
- tests/Integration/MSFT_SqlServerNetwork.Integration.Tests.ps1
- tests/Integration/MSFT_SqlServerLogin.Integration.Tests.ps1
- tests/Integration/MSFT_SqlServerEndPoint.Integration.Tests.ps1
- tests/Integration/MSFT_SqlServerDatabaseMail.Integration.Tests.ps1
- tests/Integration/MSFT_SqlRSSetup.Integration.Tests.ps1
- tests/Integration/MSFT_SqlDatabaseDefaultLocation.Integration.Tests.ps1
- tests/Integration/MSFT_SqlDatabase.Integration.Tests.ps1
- tests/Integration/MSFT_SqlAlwaysOnService.Integration.Tests.ps1
- tests/Integration/MSFT_SqlAgentOperator.Integration.Tests.ps1
- tests/Integration/MSFT_SqlServiceAccount.Integration.Tests.ps1
- tests/Integration/MSFT_SqlAgentFailsafe.Integration.Tests.ps1
# Group 3
- tests/Integration/MSFT_SqlServerRole.Integration.Tests.ps1
- tests/Integration/MSFT_SqlRS.Integration.Tests.ps1
- tests/Integration/MSFT_SqlDatabaseUser.Integration.Tests.ps1
# Group 4
- tests/Integration/MSFT_SqlScript.Integration.Tests.ps1
# Group 5
- tests/Integration/MSFT_SqlServerSecureConnection.Integration.Tests.ps1
- tests/Integration/MSFT_SqlScriptQuery.Integration.Tests.ps1
If you want to add Codecov.io functionality to the repository please see the article Add Codecov Support to Repository.
This is an optional step.
Adding your fork to a free Azure DevOps organization means that when you push a working branch to your fork and it will be tested the same way as when you send in a PR.
This is similar to what the upstream repository is using to run CI pipeline, it is using the https://dev.azure.com/dsccommunity organization.
This is can be used to test that everything works as expected before sending in a PR. It can also be used to start a test run that takes a long time without having the development environment powered on. Just commit and push the changes and the Azure Pipelines will run the CI for you.
azure-pipelines.yml
by browsing the branch you
recently pushed above.*
(asterisk).Next time you push a commit to a branch in your fork the Azure Pipeline will trigger on that and start a run.
NOTE: Even if we choose a specific YAML file that will not be used, instead the YAML file from the branch being pushed will be used, so any changes to the file
azure-pipelines.yml
will be reflected.
Once all the tests are passing (preferably verified in you own Azure DevOps organization) it time to update the upstream repository on the DscCommunity GitHub account.
If you don’t have access to execute one or more of these steps then send a message to @johlju, @PlagueHO, or @gaelcolas privately or in the DSC Slack channel.
Remove old webhooks that no longer will be used.
ci.appveyor.com
).hooks.waffle.io
). If it exists.cla.microsoft.com
). If it exists.git push --set-upstream origin add-new-ci
.NOTE: This needs to be done by one that has admin rights on the DSC Community Azure DevOps organization. If you don’t have admin rights then contact @gaelcolas on the Slack #DSC channel and provide the e-mail address you want to access the Azure DevOps organization with. He will create the Azure DevOps project for the repository. He will also invite you as a stakeholder to the DSC Community Azure DevOps organization and give you permission in the Azure DevOps project.
Prior to doing this, make sure that the working branch was pushed to
the upstream repository since we need to have access to the file
azure-pipelines.yml
in the next step.
azure-pipelines.yml
by browsing the branch
you just pushed above. Then on the box that says Run, instead just
choose Save in the drop-down list.GitHubToken
- This should have the value of the GitHub Personal
Access Token (PAT) for the specific repository (created from the DSC
Community GitHub account)GalleryApiToken
- This should have the value of the PowerShell
Gallery API keyBrowse to the repository settings page and change the branch protection
rules for both branch dev
and branch master
to remove the status check
for AppVeyor and CLA. See branch protection rules at
https://github.com/dsccommunity/{repository}/settings/branches.
dev
branch.add-new-ci
, from the upstream repository.In the repository, change the default branch to master
at
https://github.com/dsccommunity/{repository}/settings/branches.
NOTE: GitHub will say “Changing the default branch can have unintended consequences that can affect new pull requests and clones.”. We have to help contributors so solve any consequences so just ignore ignore it and continue.
Browse to the repository settings page and set the branch protection
rules for branch master
to add the status check for Azure Pipelines.
See branch protection rules at https://github.com/dsccommunity/{repository}/settings/branches.
Branch protection rules:
Status check to set (will only show once the CI has been run):
dsccommunity.{repositoryName} (Build Package Module)
dsccommunity.{repositoryName} (Test HQRM)
dsccommunity.{repositoryName} (Test Integration)
dsccommunity.{repositoryName} (Test Unit)
Plus any other test status checks you have cofngiured for other platforms etc.
NOTE: Names can differ depending on what the jobs were named in the file
azure-pipelines.yml
.
Ask @gaelcolas to transfer the package for the repository over to the
DSC Community. This must be done prior to merging changes into the
master
branch.
All modules have been transferred to the DSC Community PowerShell Gallery account.
dev
to Allow force push
at https://github.com/dsccommunity/{repository}/settings/branches.master
into the upstream
branch dev
. This must be done to keep the commits that us used by the
tags.
git checkout dev
# get latest changes from upstream dev into local branch dev
git fetch origin dev
git rebase origin/dev
# get latest changes from upstream master into local branch dev
git fetch origin master
git rebase origin/master
# push changes to upstream dev
git push --set-upstream origin dev --force
dev
branch targeting the master
branch.This will publish a preview version.
Once the next full version should be deployed, do these steps to push
a new release version tag. Important to have the correct format vX.Y.Z
,
e.g. v1.14.1
.
Assuming ‘origin’ is the remote name pointing the upstream repository, if not then change appropriately.
# Make sure to get the latest history, use rebase to retain the linear
# commit history.
git checkout master
git fetch origin master
git rebase origin/master
# Creates the full version tag.
git fetch origin --tags # Pull all tags from upstream master branch
git describe --tags # To see the the latest tag, e.g. vX.Y.Z-preview0002
git tag vX.Y.Z # Change X.Y.Z to next version number, prefixed with 'v'.
git push origin --tags # Push the new tag that was created locally
NOTE: You could also tag a specific commit if not all commits should be released.
dev
from upstream repositoryBE AWARE OF AFFECTED PULL REQUESTS.
master
.dev
by running git push origin :dev
(or by manually
deleting it through GitHub). You might need to remove it as a protected
branch first in https://github.com/dsccommunity/{repositoryName}/settings/branches.This is to updated the forked repository. All these steps are optional.
master
in the forked repository.dev
from the forked repository.master
in the forked repository.
git checkout master
git fetch origin master
git rebase origin/master
git push my --force
When the repository was moved Reviewable might have been disconnected which means that the Reviewable button might or might not show up on a PR (depends on if or how the contributor have configured Reviewable).
If there are a Reviewable button showing up on a PR, then click on that
button as usual. If there are no reviewable button, then browse to reviewable
using https://reviewable.io/reviews/dsccommunity/{repositoryName}/{PRnumber}
that you build from the repository name and the PR number, e.g.
https://reviewable.io/reviews/dsccommunity/xExchange/439
. When doing this
the Reviewable button should reappear on the PR,
Once on the Reviewable page, look at the bottom of the page for a warning popup message saying “This review will only sync with the PR on demand because the repo is not connected”. Click on the green button that says CONNECT DSCCOMMUNITY/{repositoryName}.
Reviewable should now have been re-connected.