gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
172 stars 42 forks source link

When using the template type `'SimpleModule'` it adds unnecessary configuration #277

Closed johlju closed 3 years ago

johlju commented 3 years ago

When using the template type 'SimpleModule' it should not add:

In RequiredModules.psd1

    'DscResource.Common'        = 'latest'
    'DscResource.Test'          = 'latest'
    'DscResource.AnalyzerRules' = 'latest'
    xDscResourceDesigner        = 'latest'
    'DscResource.DocGenerator'  = 'latest'

In build.yaml

  hqrmtest:
    - DscResource_Tests_Stop_On_Fail

When using the template type 'SimpleModule' it should ask for values for:

In azure-pipelines.yml it should ask for the name of the default branch.

trigger:
  branches:
    include:
    - main

and for

          eq(variables['Build.SourceBranch'], 'refs/heads/master'),

In azure-pipelines.yml it should ask for the name of the account name that owns the upstream repository (so that it does not try to deploy in forks).

        contains(variables['System.TeamFoundationCollectionUri'], 'synedgy')
johlju commented 3 years ago

It should ask if GitVersion should be used and if so add a GitVersion.yaml. and it should ask for the name of the default branch in the line regex: ^main$:

mode: ContinuousDelivery
next-version: 0.0.1
major-version-bump-message: '(breaking\schange|breaking|major)\b'
minor-version-bump-message: '(adds?|features?|minor)\b'
patch-version-bump-message: '\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
assembly-informational-format: '{NuGetVersionV2}+Sha.{Sha}.Date.{CommitDate}'
branches:
  master:
    tag: preview
    regex: ^main$
  pull-request:
    tag: PR
  feature:
    tag: useBranchName
    increment: Minor
    regex: f(eature(s)?)?[\/-]
    source-branches: ['master']
  hotfix:
    tag: fix
    increment: Patch
    regex: (hot)?fix(es)?[\/-]
    source-branches: ['master']

ignore:
  sha: []
merge-message-formats: {}
johlju commented 3 years ago

It should ask for the name of the default branch and add the following to the tasks publishRelease and sendChangelogPR in the pipeline job Deploy_Module. This was fixed in a recent PR.

ReleaseBranch: main
MainGitBranch: main

Example:

          - task: PowerShell@2
            name: publish_release
            displayName: 'Publish Release'
            inputs:
              filePath: './build.ps1'
              arguments: '-tasks publish'
              pwsh: true
            env:
              GitHubToken: $(GitHubToken)
              GalleryApiToken: $(GalleryApiToken)
              ReleaseBranch: main
              MainGitBranch: main
          - task: PowerShell@2
            name: send_changelog_PR
            displayName: 'Send CHANGELOG PR'
            inputs:
              filePath: './build.ps1'
              arguments: '-tasks Create_ChangeLog_GitHub_PR'
              pwsh: true
            env:
              GitHubToken: $(GitHubToken)
              ReleaseBranch: main
              MainGitBranch: main
johlju commented 3 years ago

The module script file should be empty, it should not use the template which dot-sources a lot of stuff: https://github.com/gaelcolas/Sampler/blob/master/Sampler/Templates/Sampler/module.template

johlju commented 3 years ago

This should either be removed when using SimpleModule (preferably as the template used is 'simple'), or changed to real values (even if it is commented out) not have Sampler/Sampler.psd1 which can be misleading if there is a source folder.

https://github.com/gaelcolas/Sampler/blob/acc257a2985b813c97da7e1c3b29974d038ebe68/Sampler/Templates/Build/build.yaml.template#L5-L14

johlju commented 3 years ago

The build task Publish_GitHub_Wiki_Content must be removed, unless configured correctly.

johlju commented 3 years ago

Module manifest is not prepared for preview releases. These two are commented.


    PrivateData          = @{
        PSData = @{
            # ReleaseNotes of this module
            ReleaseNotes = ''

            # Prerelease string of this module
            Prerelease = ''
        } # End of PSData hashtable
    } # End of PrivateData hashtable
johlju commented 3 years ago

Module manifest should be updated to use these:

    # Modules that must be imported into the global environment prior to importing this module
    RequiredModules = @()

    # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
    FunctionsToExport    = @()

    # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
    CmdletsToExport      = @()

    # Variables to export from this module
    VariablesToExport    = @()

    # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
    AliasesToExport      = @()

    # DSC resources to export from this module
    DscResourcesToExport = @()