diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4822691c..db8e7728 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -196,11 +196,6 @@ jobs: BuildModule: name: Build module - if: ${{ contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-ubuntu-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-macos-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-windows-latest.result) && !cancelled() }} - needs: - - TestSourceCode-pwsh-ubuntu-latest - - TestSourceCode-pwsh-macos-latest - - TestSourceCode-pwsh-windows-latest runs-on: ubuntu-latest steps: - name: Checkout Code @@ -219,7 +214,41 @@ jobs: Version: ${{ inputs.Version }} - name: Build module - uses: PSModule/Build-PSModule@v2 + uses: PSModule/Build-PSModule@v3 + with: + Name: ${{ inputs.Name }} + Path: ${{ inputs.Path }} + ModulesOutputPath: ${{ inputs.ModulesOutputPath }} + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + + BuildDocs: + name: Build docs + needs: + - BuildModule + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Debug + if: ${{ inputs.Debug }} + uses: PSModule/Debug@v0 + + - name: Initialize environment + uses: PSModule/Initialize-PSModule@v1 + with: + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + + - name: Document module + uses: PSModule/Document-PSModule@v0 with: Name: ${{ inputs.Name }} Path: ${{ inputs.Path }} @@ -230,6 +259,130 @@ jobs: Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} + - name: Commit all changes + continue-on-error: true + shell: pwsh + run: | + # Rename the gitignore file to .gitignore.bak + Rename-Item -Path '.gitignore' -NewName '.gitignore.bak' -Force + + try { + # Add all changes to the repository + git add . + git commit -m 'Update documentation' + } catch { + Write-Host "No changes to commit" + } + + # Restore the gitignore file + Rename-Item -Path '.gitignore.bak' -NewName '.gitignore' -Force + + - name: Lint documentation + uses: super-linter/super-linter/slim@latest + env: + FILTER_REGEX_INCLUDE: '${{ inputs.DocsOutputPath }}/**' + DEFAULT_BRANCH: main + DEFAULT_WORKSPACE: ${{ github.workspace }} + ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true + GITHUB_TOKEN: ${{ github.token }} + RUN_LOCAL: true + VALIDATE_ALL_CODEBASE: true + VALIDATE_JSCPD: false + VALIDATE_MARKDOWN_PRETTIER: false + VALIDATE_YAML_PRETTIER: false + VALIDATE_JSON_PRETTIER: false + VALIDATE_GITLEAKS: false + + - uses: actions/configure-pages@v5 + + - name: Install mkdoks-material + shell: pwsh + run: | + pip install mkdocs-material + pip install mkdocs-git-authors-plugin + pip install mkdocs-git-revision-date-localized-plugin + pip install mkdocs-git-committers-plugin-2 + + - name: Structure site + uses: PSModule/GitHub-Script@v1 + with: + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + Script: | + New-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -ItemType Directory -Force + Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}/*" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force + $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}' + $ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}' + $SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}' + + LogGroup "Get folderstructure" { + Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object + } + + $functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item + Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { + $fileName = $_.Name + $hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash + LogGroup " - [$fileName] - [$hash]" { + Show-FileContent -Path $_ + } + } + + LogGroup 'Build docs - Process about topics' { + $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About' + $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force + $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' } + Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru | + Rename-Item -NewName { $_.Name -replace '.txt', '.md' } + } + + LogGroup 'Build docs - Copy icon to assets' { + $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets' + $null = New-Item -Path $assetsFolderPath -ItemType Directory -Force + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + $iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png' + Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose + } + + LogGroup 'Build docs - Copy readme.md' { + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + $readmePath = Join-Path -Path $rootPath -ChildPath 'README.md' + $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md' + Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose + } + + LogGroup 'Build docs - Create mkdocs.yml' { + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + # This should be moved to an action so that we can use a default one, and not have to copy it from the repo. + $mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml' + $mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml' + $mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw + $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName) + $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER) + $mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force + Show-FileContent -Path $mkdocsTargetPath + } + + - name: Debug File system + shell: pwsh + run: | + Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object + + - name: Build mkdocs-material project + working-directory: ${{ inputs.SiteOutputPath }} + shell: pwsh + run: | + Start-LogGroup 'Build docs - mkdocs build - content' + Show-FileContent -Path mkdocs.yml + Stop-LogGroup + Start-LogGroup 'Build docs - mkdocs build' + mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site + Stop-LogGroup + + - uses: actions/upload-pages-artifact@v3 + # This is necessary as there is no way to get output from a matrix job TestModule-pwsh-ubuntu-latest: name: Test module (pwsh, ubuntu-latest) @@ -241,6 +394,8 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Debug if: ${{ inputs.Debug }} @@ -510,168 +665,3 @@ jobs: if-no-files-found: error retention-days: 1 overwrite: true - - LintDocs: - name: Lint documentation - if: ${{ needs.BuildModule.result == 'success' && !cancelled() }} - needs: BuildModule - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: Debug - if: ${{ inputs.Debug }} - uses: PSModule/Debug@v0 - - - name: Download docs artifact - uses: actions/download-artifact@v4 - with: - name: docs - path: ${{ github.workspace }} - - - name: Commit docs for linting - shell: pwsh - run: | - git config --global user.name "Github Actions" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Update documentation" - - - name: Lint documentation - uses: super-linter/super-linter/slim@latest - env: - DEFAULT_BRANCH: main - DEFAULT_WORKSPACE: ${{ github.workspace }} - ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true - GITHUB_TOKEN: ${{ github.token }} - RUN_LOCAL: true - VALIDATE_ALL_CODEBASE: false - VALIDATE_JSCPD: false - VALIDATE_MARKDOWN_PRETTIER: false - VALIDATE_YAML_PRETTIER: false - VALIDATE_GITLEAKS: false - - BuildSite: - name: Build Site - if: ${{ inputs.PublishDocs && needs.LintDocs.result == 'success' && !cancelled() }} - needs: LintDocs - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: Debug - if: ${{ inputs.Debug }} - uses: PSModule/Debug@v0 - - - name: Initialize environment - uses: PSModule/Initialize-PSModule@v1 - with: - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - - - name: Download docs artifact - uses: actions/download-artifact@v4 - with: - name: docs - path: '${{ inputs.SiteOutputPath }}/docs/Functions' - - - name: Debug - uses: PSModule/Debug@v0 - - - uses: actions/configure-pages@v5 - - - name: Install mkdoks-material - shell: pwsh - run: | - pip install mkdocs-material - pip install mkdocs-git-authors-plugin - pip install mkdocs-git-revision-date-localized-plugin - pip install mkdocs-git-committers-plugin-2 - - - name: Structure site - uses: PSModule/GitHub-Script@v1 - with: - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - Script: | - $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}' - $ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}' - $SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}' - - $functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item - Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { - $fileName = $_.Name - $hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash - LogGroup " - [$fileName] - [$hash]" { - Show-FileContent -Path $_ - } - } - - LogGroup 'Build docs - Process about topics' { - $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About' - $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force - $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' } - Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru | - Rename-Item -NewName { $_.Name -replace '.txt', '.md' } - } - - LogGroup 'Build docs - Copy icon to assets' { - $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets' - $null = New-Item -Path $assetsFolderPath -ItemType Directory -Force - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - $iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png' - Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose - } - - LogGroup 'Build docs - Copy readme.md' { - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - $readmePath = Join-Path -Path $rootPath -ChildPath 'README.md' - $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md' - Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose - } - - LogGroup 'Build docs - Create mkdocs.yml' { - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - # This should be moved to an action so that we can use a default one, and not have to copy it from the repo. - $mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml' - $mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml' - $mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw - $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName) - $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER) - $mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force - Show-FileContent -Path $mkdocsTargetPath - } - - - name: Debug - uses: PSModule/Debug@v0 - - - name: Build mkdocs-material project - uses: PSModule/GitHub-Script@v1 - with: - WorkingDirectory: ${{ inputs.SiteOutputPath }} - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - Script: | - LogGroup 'Build docs - mkdocs build - content' { - Show-FileContent -Path mkdocs.yml - } - - LogGroup 'Build docs - mkdocs build' { - mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site - } - - - uses: actions/upload-pages-artifact@v3 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 9f2c7cba..3cbf404f 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -203,11 +203,6 @@ jobs: BuildModule: name: Build module - if: ${{ contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-ubuntu-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-macos-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-windows-latest.result) && !cancelled() }} - needs: - - TestSourceCode-pwsh-ubuntu-latest - - TestSourceCode-pwsh-macos-latest - - TestSourceCode-pwsh-windows-latest runs-on: ubuntu-latest steps: - name: Checkout Code @@ -226,7 +221,41 @@ jobs: Version: ${{ inputs.Version }} - name: Build module - uses: PSModule/Build-PSModule@v2 + uses: PSModule/Build-PSModule@v3 + with: + Name: ${{ inputs.Name }} + Path: ${{ inputs.Path }} + ModulesOutputPath: ${{ inputs.ModulesOutputPath }} + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + + BuildDocs: + name: Build docs + needs: + - BuildModule + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Debug + if: ${{ inputs.Debug }} + uses: PSModule/Debug@v0 + + - name: Initialize environment + uses: PSModule/Initialize-PSModule@v1 + with: + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + + - name: Document module + uses: PSModule/Document-PSModule@v0 with: Name: ${{ inputs.Name }} Path: ${{ inputs.Path }} @@ -237,6 +266,129 @@ jobs: Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} + - name: Commit all changes + continue-on-error: true + shell: pwsh + run: | + # Rename the gitignore file to .gitignore.bak + Rename-Item -Path '.gitignore' -NewName '.gitignore.bak' -Force + + try { + # Add all changes to the repository + git add . + git commit -m 'Update documentation' + } catch { + Write-Host "No changes to commit" + } + + # Restore the gitignore file + Rename-Item -Path '.gitignore.bak' -NewName '.gitignore' -Force + + - name: Lint documentation + uses: super-linter/super-linter/slim@latest + env: + FILTER_REGEX_INCLUDE: '${{ inputs.DocsOutputPath }}/**' + DEFAULT_BRANCH: main + DEFAULT_WORKSPACE: ${{ github.workspace }} + ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true + GITHUB_TOKEN: ${{ github.token }} + RUN_LOCAL: true + VALIDATE_ALL_CODEBASE: true + VALIDATE_JSCPD: false + VALIDATE_MARKDOWN_PRETTIER: false + VALIDATE_YAML_PRETTIER: false + VALIDATE_JSON_PRETTIER: false + VALIDATE_GITLEAKS: false + + - uses: actions/configure-pages@v5 + + - name: Install mkdoks-material + shell: pwsh + run: | + pip install mkdocs-material + pip install mkdocs-git-authors-plugin + pip install mkdocs-git-revision-date-localized-plugin + pip install mkdocs-git-committers-plugin-2 + + - name: Structure site + uses: PSModule/GitHub-Script@v1 + with: + Debug: ${{ inputs.Debug }} + Prerelease: ${{ inputs.Prerelease }} + Verbose: ${{ inputs.Verbose }} + Version: ${{ inputs.Version }} + Script: | + New-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -ItemType Directory -Force + Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}/*" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force + $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}' + $ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}' + $SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}' + + LogGroup "Get folder structure" { + Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Format-List + } + + $functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item + Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { + $fileName = $_.Name + LogGroup " - $fileName" { + Show-FileContent -Path $_ + } + } + + LogGroup 'Build docs - Process about topics' { + $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About' + $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force + $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' } + Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru | + Rename-Item -NewName { $_.Name -replace '.txt', '.md' } + } + + LogGroup 'Build docs - Copy icon to assets' { + $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets' + $null = New-Item -Path $assetsFolderPath -ItemType Directory -Force + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + $iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png' + Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose + } + + LogGroup 'Build docs - Copy readme.md' { + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + $readmePath = Join-Path -Path $rootPath -ChildPath 'README.md' + $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md' + Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose + } + + LogGroup 'Build docs - Create mkdocs.yml' { + $rootPath = Split-Path -Path $ModuleSourcePath -Parent + # This should be moved to an action so that we can use a default one, and not have to copy it from the repo. + $mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml' + $mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml' + $mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw + $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName) + $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER) + $mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force + Show-FileContent -Path $mkdocsTargetPath + } + + - name: Debug File system + shell: pwsh + run: | + Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object + + - name: Build mkdocs-material project + working-directory: ${{ inputs.SiteOutputPath }} + shell: pwsh + run: | + Start-LogGroup 'Build docs - mkdocs build - content' + Show-FileContent -Path mkdocs.yml + Stop-LogGroup + Start-LogGroup 'Build docs - mkdocs build' + mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site + Stop-LogGroup + + - uses: actions/upload-pages-artifact@v3 + #This is necessary as there is no way to get output from a matrix job TestModule-pwsh-ubuntu-latest: name: Test module (pwsh, ubuntu-latest) @@ -531,179 +683,12 @@ jobs: retention-days: 1 overwrite: true - LintDocs: - name: Lint documentation - if: ${{ needs.BuildModule.result == 'success' && !cancelled() }} - needs: BuildModule - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: Debug - if: ${{ inputs.Debug }} - uses: PSModule/Debug@v0 - - - name: Initialize environment - uses: PSModule/Initialize-PSModule@v1 - with: - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - - - name: Download docs artifact - uses: actions/download-artifact@v4 - with: - name: docs - path: ${{ github.workspace }} - - - name: Commit docs for linting - shell: pwsh - run: | - git config --global user.name "Github Actions" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Update documentation" - - - name: Lint documentation - uses: super-linter/super-linter/slim@latest - env: - DEFAULT_BRANCH: main - DEFAULT_WORKSPACE: ${{ github.workspace }} - ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true - GITHUB_TOKEN: ${{ github.token }} - RUN_LOCAL: true - VALIDATE_ALL_CODEBASE: false - VALIDATE_JSCPD: false - VALIDATE_MARKDOWN_PRETTIER: false - VALIDATE_YAML_PRETTIER: false - VALIDATE_JSON_PRETTIER: false - VALIDATE_GITLEAKS: false - - BuildSite: - name: Build Site - if: ${{ inputs.PublishDocs && needs.LintDocs.result == 'success' && !cancelled() }} - needs: LintDocs - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.sha }} - - - name: Debug - if: ${{ inputs.Debug }} - uses: PSModule/Debug@v0 - - - name: Initialize environment - uses: PSModule/Initialize-PSModule@v1 - with: - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - - - name: Download docs artifact - uses: actions/download-artifact@v4 - with: - name: docs - path: '${{ inputs.SiteOutputPath }}/docs/Functions' - - - uses: actions/configure-pages@v5 - - - name: Install mkdoks-material - shell: pwsh - run: | - pip install mkdocs-material - pip install mkdocs-git-authors-plugin - pip install mkdocs-git-revision-date-localized-plugin - pip install mkdocs-git-committers-plugin-2 - - - name: Structure site - uses: PSModule/GitHub-Script@v1 - with: - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - Script: | - $moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}' - $ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}' - $SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}' - - $functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item - Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { - $fileName = $_.Name - $hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash - LogGroup " - [$fileName] - [$hash]" { - Show-FileContent -Path $_ - } - } - - LogGroup 'Build docs - Process about topics' { - $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About' - $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force - $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' } - Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru | - Rename-Item -NewName { $_.Name -replace '.txt', '.md' } - } - - LogGroup 'Build docs - Copy icon to assets' { - $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets' - $null = New-Item -Path $assetsFolderPath -ItemType Directory -Force - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - $iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png' - Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose - } - - LogGroup 'Build docs - Copy readme.md' { - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - $readmePath = Join-Path -Path $rootPath -ChildPath 'README.md' - $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md' - Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose - } - - LogGroup 'Build docs - Create mkdocs.yml' { - $rootPath = Split-Path -Path $ModuleSourcePath -Parent - # This should be moved to an action so that we can use a default one, and not have to copy it from the repo. - $mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml' - $mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml' - $mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw - $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName) - $mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER) - $mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force - Show-FileContent -Path $mkdocsTargetPath - } - - - name: Debug File system - shell: pwsh - run: | - Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object - - - name: Build mkdocs-material project - working-directory: ${{ inputs.SiteOutputPath }} - shell: pwsh - run: | - Start-LogGroup 'Build docs - mkdocs build - content' - Show-FileContent -Path mkdocs.yml - Stop-LogGroup - Start-LogGroup 'Build docs - mkdocs build' - mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site - Stop-LogGroup - - - uses: actions/upload-pages-artifact@v3 - PublishModule: name: Publish module if: ${{ needs.TestModuleStatus.result == 'success' && !cancelled() && github.event_name == 'pull_request' }} needs: - TestModuleStatus - - BuildSite + - BuildDocs runs-on: ubuntu-latest steps: - name: Checkout Code @@ -741,10 +726,10 @@ jobs: PublishSite: name: Publish documentation - if: ${{ inputs.PublishDocs && needs.BuildSite.result == 'success' && !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.merged == true }} + if: ${{ inputs.PublishDocs && needs.BuildDocs.result == 'success' && !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.merged == true }} needs: - TestModuleStatus - - BuildSite + - BuildDocs permissions: pages: write # to deploy to Pages id-token: write # to verify the deployment originates from an appropriate source diff --git a/README.md b/README.md index b324c6cc..f700871a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Process-PSModule -A workflow for the PSModule process, stitching together the `Initialize`, `Build`, `Test`, and `Publish` actions to create a complete +A workflow for the PSModule process, stitching together the `Initialize`, `Build`, `Document`, `Test`, and `Publish` actions to create a complete CI/CD pipeline for PowerShell modules. The workflow is used by all PowerShell modules in the PSModule organization. ## Specifications and practices @@ -20,13 +20,12 @@ Depending on the labels in the pull requests, the workflow will result in differ ![Process diagram](./media/Process-PSModule.png) -- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Tests the source code using PSScriptAnalyzer, PSModule source code tests suites. This runs on 4 different environments to check compatibility. - - PowerShell 7.x on Windows, Ubuntu and macOS. - - Windows PowerShell 5.1 on Windows. +- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Tests and lints the source code. This runs on 3 different environments to check compatibility. + - PowerShell LTS on Windows, Ubuntu and macOS. - [Build-PSModule](https://github.com/PSModule/Build-PSModule/) - Compiles the repository into an efficient PowerShell module. -- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Tests the compiled module using PSScriptAnalyzer, PSModule module tests and custom module tests from the module repository. This runs on 4 different environments to check compatibility. - - PowerShell 7.x on Windows, Ubuntu and macOS. - - Windows PowerShell 5.1 on Windows. +- [Document-PSModule](https://github.com/PSModule/Document-PSModule/) - Generates documentation and deploys it to GitHub Pages. +- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Tests the compiled module. This runs on 4 different environments to check compatibility. + - PowerShell LTS on Windows, Ubuntu and macOS. - [Publish-PSModule](https://github.com/PSModule/Publish-PSModule/) - Publishes the module to the PowerShell Gallery, docs to GitHub Pages, and creates a release on the GitHub repository. To use the workflow, create a new file in the `.github/workflows` directory of the module repository and add the following content. diff --git a/tests/outputTestRepo/README.md b/tests/outputTestRepo/README.md deleted file mode 100644 index b459e352..00000000 --- a/tests/outputTestRepo/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Test module - -This is a test readme. diff --git a/tests/outputTestRepo/mkdocs.yml b/tests/outputTestRepo/mkdocs.yml deleted file mode 100644 index df5e17ad..00000000 --- a/tests/outputTestRepo/mkdocs.yml +++ /dev/null @@ -1,75 +0,0 @@ -site_name: -{{ REPO_NAME }}- -theme: - name: material - language: en - font: - text: Roboto - code: Sono - logo: Assets/icon.png - favicon: Assets/icon.png - palette: - # Palette toggle for automatic mode - - media: "(prefers-color-scheme)" - toggle: - icon: material/link - name: Switch to dark mode - # Palette toggle for dark mode - - media: '(prefers-color-scheme: dark)' - scheme: slate - toggle: - primary: black - accent: green - icon: material/toggle-switch-off-outline - name: Switch to light mode - # Palette toggle for light mode - - media: '(prefers-color-scheme: light)' - scheme: default - toggle: - primary: indigo - accent: green - icon: material/toggle-switch - name: Switch to system preference - icon: - repo: material/github - features: - - navigation.instant - - navigation.instant.progress - - navigation.indexes - - navigation.top - - navigation.tracking - - navigation.expand - - search.suggest - - search.highlight - -repo_name: -{{ REPO_OWNER }}-/-{{ REPO_NAME }}- -repo_url: https://github.com/-{{ REPO_OWNER }}-/-{{ REPO_NAME }}- - -plugins: - - search - -markdown_extensions: - - toc: - permalink: true # Adds a link icon to headings - - attr_list - - admonition - - md_in_html - - pymdownx.details # Enables collapsible admonitions - -extra: - social: - - icon: fontawesome/brands/discord - link: https://discord.gg/jedJWCPAhD - name: -{{ REPO_OWNER }}- on Discord - - icon: fontawesome/brands/github - link: https://github.com/-{{ REPO_OWNER }}-/ - name: -{{ REPO_OWNER }}- on GitHub - consent: - title: Cookie consent - description: >- - We use cookies to recognize your repeated visits and preferences, as well - as to measure the effectiveness of our documentation and whether users - find what they're searching for. With your consent, you're helping us to - make our documentation better. - actions: - - accept - - reject diff --git a/tests/outputTestRepo/outputs/docs/PSModule/Get-PSModuleTest.md b/tests/outputTestRepo/outputs/docs/PSModule/Get-PSModuleTest.md deleted file mode 100644 index 2179b427..00000000 --- a/tests/outputTestRepo/outputs/docs/PSModule/Get-PSModuleTest.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -external help file: PSModuleTest-help.xml -Module Name: PSModuleTest -online version: -schema: 2.0.0 ---- - -# Get-PSModuleTest - -## SYNOPSIS -Performs tests on a module. - -## SYNTAX - -```powershell -Get-PSModuleTest [-Name] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -```powershell -Test-PSModule -Name 'World' -``` - -"Hello, World!" - -## PARAMETERS - -### -Name -Name of the person to greet. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - diff --git a/tests/outputTestRepo/outputs/docs/PSModule/New-PSModuleTest.md b/tests/outputTestRepo/outputs/docs/PSModule/New-PSModuleTest.md deleted file mode 100644 index 68096092..00000000 --- a/tests/outputTestRepo/outputs/docs/PSModule/New-PSModuleTest.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -external help file: PSModuleTest-help.xml -Module Name: PSModuleTest -online version: -schema: 2.0.0 ---- - -# New-PSModuleTest - -## SYNOPSIS -Performs tests on a module. - -## SYNTAX - -```powershell -New-PSModuleTest [-Name] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -```powershell -Test-PSModule -Name 'World' -``` - -"Hello, World!" - -## PARAMETERS - -### -Name -Name of the person to greet. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES -Testing if a module can have a [Markdown based link](https://example.com). -!"#¤%&/()=?`´^¨*'-_+§½{[]}<>|@£$€¥¢:;.," -\[This is a test\] - -## RELATED LINKS - diff --git a/tests/outputTestRepo/outputs/docs/PSModule/PSModule.md b/tests/outputTestRepo/outputs/docs/PSModule/PSModule.md deleted file mode 100644 index 79741cf4..00000000 --- a/tests/outputTestRepo/outputs/docs/PSModule/PSModule.md +++ /dev/null @@ -1 +0,0 @@ -# This is PSModule diff --git a/tests/outputTestRepo/outputs/docs/SomethingElse/Set-PSModuleTest.md b/tests/outputTestRepo/outputs/docs/SomethingElse/Set-PSModuleTest.md deleted file mode 100644 index 8c7fcf15..00000000 --- a/tests/outputTestRepo/outputs/docs/SomethingElse/Set-PSModuleTest.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -external help file: PSModuleTest-help.xml -Module Name: PSModuleTest -online version: -schema: 2.0.0 ---- - -# Set-PSModuleTest - -## SYNOPSIS -Performs tests on a module. - -## SYNTAX - -```powershell -Set-PSModuleTest [-Name] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -```powershell -Test-PSModule -Name 'World' -``` - -"Hello, World!" - -## PARAMETERS - -### -Name -Name of the person to greet. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - diff --git a/tests/outputTestRepo/outputs/docs/SomethingElse/SomethingElse.md b/tests/outputTestRepo/outputs/docs/SomethingElse/SomethingElse.md deleted file mode 100644 index d9f7e9ee..00000000 --- a/tests/outputTestRepo/outputs/docs/SomethingElse/SomethingElse.md +++ /dev/null @@ -1 +0,0 @@ -# This is SomethingElse diff --git a/tests/outputTestRepo/outputs/docs/Test-PSModuleTest.md b/tests/outputTestRepo/outputs/docs/Test-PSModuleTest.md deleted file mode 100644 index ce17f7bb..00000000 --- a/tests/outputTestRepo/outputs/docs/Test-PSModuleTest.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -external help file: PSModuleTest-help.xml -Module Name: PSModuleTest -online version: -schema: 2.0.0 ---- - -# Test-PSModuleTest - -## SYNOPSIS -Performs tests on a module. - -## SYNTAX - -```powershell -Test-PSModuleTest [-Name] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -```powershell -Test-PSModule -Name 'World' -``` - -"Hello, World!" - -## PARAMETERS - -### -Name -Name of the person to greet. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/PSModuleTest.psd1 b/tests/outputTestRepo/outputs/modules/PSModuleTest/PSModuleTest.psd1 deleted file mode 100644 index 4dfc77af..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/PSModuleTest.psd1 +++ /dev/null @@ -1,92 +0,0 @@ -@{ - RootModule = 'PSModuleTest.psm1' - ModuleVersion = '999.0.0' - CompatiblePSEditions = @( - 'Core' - 'Desktop' - ) - GUID = 'e4fb58a5-2027-4542-b7be-e5e5f352e358' - Author = 'PSModule' - CompanyName = 'PSModule' - Copyright = '(c) 2025 PSModule. All rights reserved.' - Description = 'Process a module from source code to published module.' - PowerShellVersion = '5.1' - ProcessorArchitecture = 'None' - RequiredModules = @( - @{ - ModuleVersion = '1.1.8' - ModuleName = 'DynamicParams' - } - @{ - RequiredVersion = '1.0.0' - ModuleName = 'PSSemVer' - } - @{ - ModuleVersion = '0.3.1' - ModuleName = 'Store' - } - 'Utilities' - ) - RequiredAssemblies = 'assemblies/LsonLib.dll' - ScriptsToProcess = 'scripts/loader.ps1' - TypesToProcess = @( - 'types/DirectoryInfo.Types.ps1xml' - 'types/FileInfo.Types.ps1xml' - ) - FormatsToProcess = @( - 'formats/CultureInfo.Format.ps1xml' - 'formats/Mygciview.Format.ps1xml' - ) - NestedModules = @( - 'modules/OtherPSModule.psm1' - ) - FunctionsToExport = @( - 'Get-PSModuleTest' - 'New-PSModuleTest' - 'Set-PSModuleTest' - 'Test-PSModuleTest' - ) - CmdletsToExport = @() - VariablesToExport = @( - 'Moons' - 'Planets' - 'SolarSystems' - ) - AliasesToExport = @( - 'New-PSModuleTestAlias1' - 'New-PSModuleTestAlias2' - 'New-PSModuleTestAlias3' - 'New-PSModuleTestAlias4' - 'New-PSModuleTestAlias5' - ) - ModuleList = @( - 'modules/OtherPSModule.psm1' - ) - FileList = @( - 'PSModuleTest.psm1' - 'assemblies/LsonLib.dll' - 'data/Config.psd1' - 'data/Settings.psd1' - 'formats/CultureInfo.Format.ps1xml' - 'formats/Mygciview.Format.ps1xml' - 'modules/OtherPSModule.psm1' - 'scripts/loader.ps1' - 'types/DirectoryInfo.Types.ps1xml' - 'types/FileInfo.Types.ps1xml' - ) - PrivateData = @{ - PSData = @{ - Tags = @( - 'workflow' - 'powershell' - 'powershell-module' - 'PSEdition_Desktop' - 'PSEdition_Core' - ) - LicenseUri = 'https://github.com/PSModule/Process-PSModule/blob/main/LICENSE' - ProjectUri = 'https://github.com/PSModule/Process-PSModule' - IconUri = 'https://raw.githubusercontent.com/PSModule/Process-PSModule/main/icon/icon.png' - } - } -} - diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/PSModuleTest.psm1 b/tests/outputTestRepo/outputs/modules/PSModuleTest/PSModuleTest.psm1 deleted file mode 100644 index ffcb5734..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/PSModuleTest.psm1 +++ /dev/null @@ -1,572 +0,0 @@ -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains long links.')] -[CmdletBinding()] -param() - -$baseName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) -$script:PSModuleInfo = Test-ModuleManifest -Path "$PSScriptRoot\$baseName.psd1" -$script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ } -$scriptName = $script:PSModuleInfo.Name -Write-Debug "[$scriptName] - Importing module" -#region Data importer -Write-Debug "[$scriptName] - [data] - Processing folder" -$dataFolder = (Join-Path $PSScriptRoot 'data') -Write-Debug "[$scriptName] - [data] - [$dataFolder]" -Get-ChildItem -Path "$dataFolder" -Recurse -Force -Include '*.psd1' -ErrorAction SilentlyContinue | ForEach-Object { - Write-Debug "[$scriptName] - [data] - [$($_.BaseName)] - Importing" - New-Variable -Name $_.BaseName -Value (Import-PowerShellDataFile -Path $_.FullName) -Force - Write-Debug "[$scriptName] - [data] - [$($_.BaseName)] - Done" -} -Write-Debug "[$scriptName] - [data] - Done" -#endregion Data importer -#region [init] -Write-Debug "[$scriptName] - [init] - Processing folder" -#region [init] - [initializer] -Write-Debug "[$scriptName] - [init] - [initializer] - Importing" -Write-Verbose '-------------------------------' -Write-Verbose '--- THIS IS AN INITIALIZER ---' -Write-Verbose '-------------------------------' -Write-Debug "[$scriptName] - [init] - [initializer] - Done" -#endregion [init] - [initializer] -Write-Debug "[$scriptName] - [init] - Done" -#endregion [init] -#region [classes] - [private] -Write-Debug "[$scriptName] - [classes] - [private] - Processing folder" -#region [classes] - [private] - [SecretWriter] -Write-Debug "[$scriptName] - [classes] - [private] - [SecretWriter] - Importing" -class SecretWriter { - [string] $Alias - [string] $Name - [string] $Secret - - SecretWriter([string] $alias, [string] $name, [string] $secret) { - $this.Alias = $alias - $this.Name = $name - $this.Secret = $secret - } - - [string] GetAlias() { - return $this.Alias - } -} -Write-Debug "[$scriptName] - [classes] - [private] - [SecretWriter] - Done" -#endregion [classes] - [private] - [SecretWriter] -Write-Debug "[$scriptName] - [classes] - [private] - Done" -#endregion [classes] - [private] -#region [classes] - [public] -Write-Debug "[$scriptName] - [classes] - [public] - Processing folder" -#region [classes] - [public] - [Book] -Write-Debug "[$scriptName] - [classes] - [public] - [Book] - Importing" -class Book { - # Class properties - [string] $Title - [string] $Author - [string] $Synopsis - [string] $Publisher - [datetime] $PublishDate - [int] $PageCount - [string[]] $Tags - # Default constructor - Book() { $this.Init(@{}) } - # Convenience constructor from hashtable - Book([hashtable]$Properties) { $this.Init($Properties) } - # Common constructor for title and author - Book([string]$Title, [string]$Author) { - $this.Init(@{Title = $Title; Author = $Author }) - } - # Shared initializer method - [void] Init([hashtable]$Properties) { - foreach ($Property in $Properties.Keys) { - $this.$Property = $Properties.$Property - } - } - # Method to calculate reading time as 2 minutes per page - [timespan] GetReadingTime() { - if ($this.PageCount -le 0) { - throw 'Unable to determine reading time from page count.' - } - $Minutes = $this.PageCount * 2 - return [timespan]::new(0, $Minutes, 0) - } - # Method to calculate how long ago a book was published - [timespan] GetPublishedAge() { - if ( - $null -eq $this.PublishDate -or - $this.PublishDate -eq [datetime]::MinValue - ) { throw 'PublishDate not defined' } - - return (Get-Date) - $this.PublishDate - } - # Method to return a string representation of the book - [string] ToString() { - return "$($this.Title) by $($this.Author) ($($this.PublishDate.Year))" - } -} - -class BookList { - # Static property to hold the list of books - static [System.Collections.Generic.List[Book]] $Books - # Static method to initialize the list of books. Called in the other - # static methods to avoid needing to explicit initialize the value. - static [void] Initialize() { [BookList]::Initialize($false) } - static [bool] Initialize([bool]$force) { - if ([BookList]::Books.Count -gt 0 -and -not $force) { - return $false - } - - [BookList]::Books = [System.Collections.Generic.List[Book]]::new() - - return $true - } - # Ensure a book is valid for the list. - static [void] Validate([book]$Book) { - $Prefix = @( - 'Book validation failed: Book must be defined with the Title,' - 'Author, and PublishDate properties, but' - ) -join ' ' - if ($null -eq $Book) { throw "$Prefix was null" } - if ([string]::IsNullOrEmpty($Book.Title)) { - throw "$Prefix Title wasn't defined" - } - if ([string]::IsNullOrEmpty($Book.Author)) { - throw "$Prefix Author wasn't defined" - } - if ([datetime]::MinValue -eq $Book.PublishDate) { - throw "$Prefix PublishDate wasn't defined" - } - } - # Static methods to manage the list of books. - # Add a book if it's not already in the list. - static [void] Add([Book]$Book) { - [BookList]::Initialize() - [BookList]::Validate($Book) - if ([BookList]::Books.Contains($Book)) { - throw "Book '$Book' already in list" - } - - $FindPredicate = { - param([Book]$b) - - $b.Title -eq $Book.Title -and - $b.Author -eq $Book.Author -and - $b.PublishDate -eq $Book.PublishDate - }.GetNewClosure() - if ([BookList]::Books.Find($FindPredicate)) { - throw "Book '$Book' already in list" - } - - [BookList]::Books.Add($Book) - } - # Clear the list of books. - static [void] Clear() { - [BookList]::Initialize() - [BookList]::Books.Clear() - } - # Find a specific book using a filtering scriptblock. - static [Book] Find([scriptblock]$Predicate) { - [BookList]::Initialize() - return [BookList]::Books.Find($Predicate) - } - # Find every book matching the filtering scriptblock. - static [Book[]] FindAll([scriptblock]$Predicate) { - [BookList]::Initialize() - return [BookList]::Books.FindAll($Predicate) - } - # Remove a specific book. - static [void] Remove([Book]$Book) { - [BookList]::Initialize() - [BookList]::Books.Remove($Book) - } - # Remove a book by property value. - static [void] RemoveBy([string]$Property, [string]$Value) { - [BookList]::Initialize() - $Index = [BookList]::Books.FindIndex({ - param($b) - $b.$Property -eq $Value - }.GetNewClosure()) - if ($Index -ge 0) { - [BookList]::Books.RemoveAt($Index) - } - } -} - -enum Binding { - Hardcover - Paperback - EBook -} - -enum Genre { - Mystery - Thriller - Romance - ScienceFiction - Fantasy - Horror -} -Write-Debug "[$scriptName] - [classes] - [public] - [Book] - Done" -#endregion [classes] - [public] - [Book] -Write-Debug "[$scriptName] - [classes] - [public] - Done" -#endregion [classes] - [public] -#region [functions] - [private] -Write-Debug "[$scriptName] - [functions] - [private] - Processing folder" -#region [functions] - [private] - [Get-InternalPSModule] -Write-Debug "[$scriptName] - [functions] - [private] - [Get-InternalPSModule] - Importing" -function Get-InternalPSModule { - <# - .SYNOPSIS - Performs tests on a module. - - .EXAMPLE - Test-PSModule -Name 'World' - - "Hello, World!" - #> - [CmdletBinding()] - param ( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} -Write-Debug "[$scriptName] - [functions] - [private] - [Get-InternalPSModule] - Done" -#endregion [functions] - [private] - [Get-InternalPSModule] -#region [functions] - [private] - [Set-InternalPSModule] -Write-Debug "[$scriptName] - [functions] - [private] - [Set-InternalPSModule] - Importing" -function Set-InternalPSModule { - <# - .SYNOPSIS - Performs tests on a module. - - .EXAMPLE - Test-PSModule -Name 'World' - - "Hello, World!" - #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function', - Justification = 'Reason for suppressing' - )] - [CmdletBinding()] - param ( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} -Write-Debug "[$scriptName] - [functions] - [private] - [Set-InternalPSModule] - Done" -#endregion [functions] - [private] - [Set-InternalPSModule] -Write-Debug "[$scriptName] - [functions] - [private] - Done" -#endregion [functions] - [private] -#region [functions] - [public] -Write-Debug "[$scriptName] - [functions] - [public] - Processing folder" -#region [functions] - [public] - [Test-PSModuleTest] -Write-Debug "[$scriptName] - [functions] - [public] - [Test-PSModuleTest] - Importing" -function Test-PSModuleTest { - <# - .SYNOPSIS - Performs tests on a module. - - .EXAMPLE - Test-PSModule -Name 'World' - - "Hello, World!" - #> - [CmdletBinding()] - param ( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} -Write-Debug "[$scriptName] - [functions] - [public] - [Test-PSModuleTest] - Done" -#endregion [functions] - [public] - [Test-PSModuleTest] -#region [functions] - [public] - [PSModule] -Write-Debug "[$scriptName] - [functions] - [public] - [PSModule] - Processing folder" -#region [functions] - [public] - [PSModule] - [Get-PSModuleTest] -Write-Debug "[$scriptName] - [functions] - [public] - [PSModule] - [Get-PSModuleTest] - Importing" -#Requires -Modules Utilities -#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' } -#Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' } -#Requires -Modules @{ ModuleName = 'Store'; ModuleVersion = '0.3.1' } - -function Get-PSModuleTest { - <# - .SYNOPSIS - Performs tests on a module. - - .EXAMPLE - Test-PSModule -Name 'World' - - "Hello, World!" - #> - [CmdletBinding()] - param ( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} -Write-Debug "[$scriptName] - [functions] - [public] - [PSModule] - [Get-PSModuleTest] - Done" -#endregion [functions] - [public] - [PSModule] - [Get-PSModuleTest] -#region [functions] - [public] - [PSModule] - [New-PSModuleTest] -Write-Debug "[$scriptName] - [functions] - [public] - [PSModule] - [New-PSModuleTest] - Importing" -#Requires -Modules @{ModuleName='PSSemVer'; ModuleVersion='1.0'} - -function New-PSModuleTest { - <# - .SYNOPSIS - Performs tests on a module. - - .EXAMPLE - Test-PSModule -Name 'World' - - "Hello, World!" - - .NOTES - Testing if a module can have a [Markdown based link](https://example.com). - !"#¤%&/()=?`´^¨*'-_+§½{[]}<>|@£$€¥¢:;.," - \[This is a test\] - #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function', - Justification = 'Reason for suppressing' - )] - [Alias('New-PSModuleTestAlias1')] - [Alias('New-PSModuleTestAlias2')] - [CmdletBinding()] - param ( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} - -New-Alias New-PSModuleTestAlias3 New-PSModuleTest -New-Alias -Name New-PSModuleTestAlias4 -Value New-PSModuleTest - - -Set-Alias New-PSModuleTestAlias5 New-PSModuleTest -Write-Debug "[$scriptName] - [functions] - [public] - [PSModule] - [New-PSModuleTest] - Done" -#endregion [functions] - [public] - [PSModule] - [New-PSModuleTest] -Write-Debug "[$scriptName] - [functions] - [public] - [PSModule] - Done" -#endregion [functions] - [public] - [PSModule] -#region [functions] - [public] - [SomethingElse] -Write-Debug "[$scriptName] - [functions] - [public] - [SomethingElse] - Processing folder" -#region [functions] - [public] - [SomethingElse] - [Set-PSModuleTest] -Write-Debug "[$scriptName] - [functions] - [public] - [SomethingElse] - [Set-PSModuleTest] - Importing" -function Set-PSModuleTest { - <# - .SYNOPSIS - Performs tests on a module. - - .EXAMPLE - Test-PSModule -Name 'World' - - "Hello, World!" - #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function', - Justification = 'Reason for suppressing' - )] - [CmdletBinding()] - param ( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} -Write-Debug "[$scriptName] - [functions] - [public] - [SomethingElse] - [Set-PSModuleTest] - Done" -#endregion [functions] - [public] - [SomethingElse] - [Set-PSModuleTest] -Write-Debug "[$scriptName] - [functions] - [public] - [SomethingElse] - Done" -#endregion [functions] - [public] - [SomethingElse] -Write-Debug "[$scriptName] - [functions] - [public] - Done" -#endregion [functions] - [public] -#region [variables] - [private] -Write-Debug "[$scriptName] - [variables] - [private] - Processing folder" -#region [variables] - [private] - [PrivateVariables] -Write-Debug "[$scriptName] - [variables] - [private] - [PrivateVariables] - Importing" -$script:HabitablePlanets = @( - @{ - Name = 'Earth' - Mass = 5.97 - Diameter = 12756 - DayLength = 24.0 - }, - @{ - Name = 'Mars' - Mass = 0.642 - Diameter = 6792 - DayLength = 24.7 - }, - @{ - Name = 'Proxima Centauri b' - Mass = 1.17 - Diameter = 11449 - DayLength = 5.15 - }, - @{ - Name = 'Kepler-442b' - Mass = 2.34 - Diameter = 11349 - DayLength = 5.7 - }, - @{ - Name = 'Kepler-452b' - Mass = 5.0 - Diameter = 17340 - DayLength = 20.0 - } -) - -$script:InhabitedPlanets = @( - @{ - Name = 'Earth' - Mass = 5.97 - Diameter = 12756 - DayLength = 24.0 - }, - @{ - Name = 'Mars' - Mass = 0.642 - Diameter = 6792 - DayLength = 24.7 - } -) -Write-Debug "[$scriptName] - [variables] - [private] - [PrivateVariables] - Done" -#endregion [variables] - [private] - [PrivateVariables] -Write-Debug "[$scriptName] - [variables] - [private] - Done" -#endregion [variables] - [private] -#region [variables] - [public] -Write-Debug "[$scriptName] - [variables] - [public] - Processing folder" -#region [variables] - [public] - [Moons] -Write-Debug "[$scriptName] - [variables] - [public] - [Moons] - Importing" -$script:Moons = @( - @{ - Planet = 'Earth' - Name = 'Moon' - } -) -Write-Debug "[$scriptName] - [variables] - [public] - [Moons] - Done" -#endregion [variables] - [public] - [Moons] -#region [variables] - [public] - [Planets] -Write-Debug "[$scriptName] - [variables] - [public] - [Planets] - Importing" -$script:Planets = @( - @{ - Name = 'Mercury' - Mass = 0.330 - Diameter = 4879 - DayLength = 4222.6 - }, - @{ - Name = 'Venus' - Mass = 4.87 - Diameter = 12104 - DayLength = 2802.0 - }, - @{ - Name = 'Earth' - Mass = 5.97 - Diameter = 12756 - DayLength = 24.0 - } -) -Write-Debug "[$scriptName] - [variables] - [public] - [Planets] - Done" -#endregion [variables] - [public] - [Planets] -#region [variables] - [public] - [SolarSystems] -Write-Debug "[$scriptName] - [variables] - [public] - [SolarSystems] - Importing" -$script:SolarSystems = @( - @{ - Name = 'Solar System' - Planets = $script:Planets - Moons = $script:Moons - }, - @{ - Name = 'Alpha Centauri' - Planets = @() - Moons = @() - }, - @{ - Name = 'Sirius' - Planets = @() - Moons = @() - } -) -Write-Debug "[$scriptName] - [variables] - [public] - [SolarSystems] - Done" -#endregion [variables] - [public] - [SolarSystems] -Write-Debug "[$scriptName] - [variables] - [public] - Done" -#endregion [variables] - [public] -#region [finally] -Write-Debug "[$scriptName] - [finally] - Importing" -Write-Verbose '------------------------------' -Write-Verbose '--- THIS IS A LAST LOADER ---' -Write-Verbose '------------------------------' -Write-Debug "[$scriptName] - [finally] - Done" -#endregion [finally] -#region Class exporter -# Get the internal TypeAccelerators class to use its static methods. -$TypeAcceleratorsClass = [psobject].Assembly.GetType( - 'System.Management.Automation.TypeAccelerators' -) -# Ensure none of the types would clobber an existing type accelerator. -# If a type accelerator with the same name exists, throw an exception. -$ExistingTypeAccelerators = $TypeAcceleratorsClass::Get -# Define the types to export with type accelerators. -$ExportableEnums = @( - [Binding] - [Genre] -) -$ExportableEnums | ForEach-Object { Write-Verbose "Exporting enum '$($_.FullName)'." } -foreach ($Type in $ExportableEnums) { - if ($Type.FullName -in $ExistingTypeAccelerators.Keys) { - Write-Verbose "Enum already exists [$($Type.FullName)]. Skipping." - } else { - Write-Verbose "Importing enum '$Type'." - $TypeAcceleratorsClass::Add($Type.FullName, $Type) - } -} -$ExportableClasses = @( - [Book] - [BookList] -) -$ExportableClasses | ForEach-Object { Write-Verbose "Exporting class '$($_.FullName)'." } -foreach ($Type in $ExportableClasses) { - if ($Type.FullName -in $ExistingTypeAccelerators.Keys) { - Write-Verbose "Class already exists [$($Type.FullName)]. Skipping." - } else { - Write-Verbose "Importing class '$Type'." - $TypeAcceleratorsClass::Add($Type.FullName, $Type) - } -} - -# Remove type accelerators when the module is removed. -$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { - foreach ($Type in ($ExportableEnums + $ExportableClasses)) { - $TypeAcceleratorsClass::Remove($Type.FullName) - } -}.GetNewClosure() -#endregion Class exporter -#region Member exporter -$exports = @{ - Alias = '*' - Cmdlet = '' - Function = @( - 'Get-PSModuleTest' - 'New-PSModuleTest' - 'Set-PSModuleTest' - 'Test-PSModuleTest' - ) - Variable = @( - 'Moons' - 'Planets' - 'SolarSystems' - ) -} -Export-ModuleMember @exports -#endregion Member exporter - diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/assemblies/LsonLib.dll b/tests/outputTestRepo/outputs/modules/PSModuleTest/assemblies/LsonLib.dll deleted file mode 100644 index 36618070..00000000 Binary files a/tests/outputTestRepo/outputs/modules/PSModuleTest/assemblies/LsonLib.dll and /dev/null differ diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/data/Config.psd1 b/tests/outputTestRepo/outputs/modules/PSModuleTest/data/Config.psd1 deleted file mode 100644 index fea44669..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/data/Config.psd1 +++ /dev/null @@ -1,3 +0,0 @@ -@{ - RandomKey = 'RandomValue' -} diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/data/Settings.psd1 b/tests/outputTestRepo/outputs/modules/PSModuleTest/data/Settings.psd1 deleted file mode 100644 index bcfa7b47..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/data/Settings.psd1 +++ /dev/null @@ -1,3 +0,0 @@ -@{ - RandomSetting = 'RandomSettingValue' -} diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/formats/CultureInfo.Format.ps1xml b/tests/outputTestRepo/outputs/modules/PSModuleTest/formats/CultureInfo.Format.ps1xml deleted file mode 100644 index a715e08a..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/formats/CultureInfo.Format.ps1xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - System.Globalization.CultureInfo - - System.Globalization.CultureInfo - - - - - 16 - - - 16 - - - - - - - - LCID - - - Name - - - DisplayName - - - - - - - - diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/formats/Mygciview.Format.ps1xml b/tests/outputTestRepo/outputs/modules/PSModuleTest/formats/Mygciview.Format.ps1xml deleted file mode 100644 index 4c972c2c..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/formats/Mygciview.Format.ps1xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - mygciview - - System.IO.DirectoryInfo - System.IO.FileInfo - - - PSParentPath - - - - - - 7 - Left - - - - 26 - Right - - - - 26 - Right - - - - 14 - Right - - - - Left - - - - - - - - ModeWithoutHardLink - - - LastWriteTime - - - CreationTime - - - Length - - - Name - - - - - - - - diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/modules/OtherPSModule.psm1 b/tests/outputTestRepo/outputs/modules/PSModuleTest/modules/OtherPSModule.psm1 deleted file mode 100644 index 5d6af8ea..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/modules/OtherPSModule.psm1 +++ /dev/null @@ -1,19 +0,0 @@ -function Get-OtherPSModule { - <# - .SYNOPSIS - Performs tests on a module. - - .DESCRIPTION - A longer description of the function. - - .EXAMPLE - Get-OtherPSModule -Name 'World' - #> - [CmdletBinding()] - param( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/scripts/loader.ps1 b/tests/outputTestRepo/outputs/modules/PSModuleTest/scripts/loader.ps1 deleted file mode 100644 index 973735ad..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/scripts/loader.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -Write-Verbose '-------------------------' -Write-Verbose '--- THIS IS A LOADER ---' -Write-Verbose '-------------------------' diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/types/DirectoryInfo.Types.ps1xml b/tests/outputTestRepo/outputs/modules/PSModuleTest/types/DirectoryInfo.Types.ps1xml deleted file mode 100644 index aef538b2..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/types/DirectoryInfo.Types.ps1xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - System.IO.FileInfo - - - Status - Success - - - - - System.IO.DirectoryInfo - - - Status - Success - - - - diff --git a/tests/outputTestRepo/outputs/modules/PSModuleTest/types/FileInfo.Types.ps1xml b/tests/outputTestRepo/outputs/modules/PSModuleTest/types/FileInfo.Types.ps1xml deleted file mode 100644 index 4cfaf6b8..00000000 --- a/tests/outputTestRepo/outputs/modules/PSModuleTest/types/FileInfo.Types.ps1xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - System.IO.FileInfo - - - Age - - ((Get-Date) - ($this.CreationTime)).Days - - - - - diff --git a/tests/outputTestRepo/tests/PSModuleTest.Tests.ps1 b/tests/outputTestRepo/tests/PSModuleTest.Tests.ps1 deleted file mode 100644 index 2be65edb..00000000 --- a/tests/outputTestRepo/tests/PSModuleTest.Tests.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -[CmdletBinding()] -Param( - # Path to the module to test. - [Parameter()] - [string] $Path -) - -Write-Verbose "Path to the module: [$Path]" -Verbose -Describe 'Environment Variables are available' { - It 'Should be available [<_>]' -ForEach @( - 'TEST_APP_ENT_CLIENT_ID', - 'TEST_APP_ENT_PRIVATE_KEY', - 'TEST_APP_ORG_CLIENT_ID', - 'TEST_APP_ORG_PRIVATE_KEY', - 'TEST_USER_ORG_FG_PAT', - 'TEST_USER_USER_FG_PAT', - 'TEST_USER_PAT' - ) { - $name = $_ - Write-Verbose "Environment variable: [$name]" -Verbose - Get-ChildItem env: | Where-Object { $_.Name -eq $name } | Should -Not -BeNullOrEmpty - } -} - -Describe 'PSModuleTest.Tests.ps1' { - Context 'Function: Test-PSModuleTest' { - It 'Should be able to call the function' { - Write-Verbose (Test-PSModuleTest -Name 'World' | Out-String) -Verbose - Test-PSModuleTest -Name 'World' | Should -Be 'Hello, World!' - } - } - - Context 'Function: Get-PSModuleTest' { - It 'Should be able to call the function' { - Write-Verbose (Get-PSModuleTest -Name 'World' | Out-String) -Verbose - Get-PSModuleTest -Name 'World' | Should -Be 'Hello, World!' - } - } - - Context 'Function: New-PSModuleTest' { - It 'Should be able to call the function' { - Write-Verbose (New-PSModuleTest -Name 'World' | Out-String) -Verbose - New-PSModuleTest -Name 'World' | Should -Be 'Hello, World!' - } - } - - Context 'Function: Set-PSModuleTest' { - It 'Should be able to call the function' { - Write-Verbose (Set-PSModuleTest -Name 'World' | Out-String) -Verbose - Set-PSModuleTest -Name 'World' | Should -Be 'Hello, World!' - } - } - - Context 'Variables' { - It "Exports a variable for SolarSystems that contains 'Solar System'" { - Write-Verbose ($SolarSystems | Out-String) -Verbose - $SolarSystems[0].Name | Should -Be 'Solar System' - } - } -} diff --git a/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 b/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 index 73a5c620..57257f1d 100644 --- a/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 +++ b/tests/srcTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 @@ -1,5 +1,5 @@ #Requires -Modules Utilities -#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' } +#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.1.4' } #Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' } #Requires -Modules @{ ModuleName = 'Store'; ModuleVersion = '0.3.1' } diff --git a/tests/srcTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 b/tests/srcTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 index d4e6e266..5fa16bc3 100644 --- a/tests/srcTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 +++ b/tests/srcTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ModuleName='PSSemVer'; ModuleVersion='1.0'} +#Requires -Modules @{ModuleName='PSSemVer'; ModuleVersion='1.1.4'} function New-PSModuleTest { <# diff --git a/tests/srcTestRepo/src/functions/public/completers.ps1 b/tests/srcTestRepo/src/functions/public/completers.ps1 new file mode 100644 index 00000000..6b1adbb7 --- /dev/null +++ b/tests/srcTestRepo/src/functions/public/completers.ps1 @@ -0,0 +1,8 @@ +Register-ArgumentCompleter -CommandName New-PSModuleTest -ParameterName Name -ScriptBlock { + param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) + $null = $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters + + 'Alice', 'Bob', 'Charlie' | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object { + [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) + } +} diff --git a/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 index 73a5c620..57257f1d 100644 --- a/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 +++ b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/Get-PSModuleTest.ps1 @@ -1,5 +1,5 @@ #Requires -Modules Utilities -#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.0.0' } +#Requires -Modules @{ ModuleName = 'PSSemVer'; RequiredVersion = '1.1.4' } #Requires -Modules @{ ModuleName = 'DynamicParams'; ModuleVersion = '1.1.8' } #Requires -Modules @{ ModuleName = 'Store'; ModuleVersion = '0.3.1' } diff --git a/tests/srcWithManifestTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 index d4e6e266..5fa16bc3 100644 --- a/tests/srcWithManifestTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 +++ b/tests/srcWithManifestTestRepo/src/functions/public/PSModule/New-PSModuleTest.ps1 @@ -1,4 +1,4 @@ -#Requires -Modules @{ModuleName='PSSemVer'; ModuleVersion='1.0'} +#Requires -Modules @{ModuleName='PSSemVer'; ModuleVersion='1.1.4'} function New-PSModuleTest { <# diff --git a/tests/srcWithManifestTestRepo/src/functions/public/Test-PSModuleTest.ps1 b/tests/srcWithManifestTestRepo/src/functions/public/Test-PSModuleTest.ps1 index 4056e2f6..26be2b9b 100644 --- a/tests/srcWithManifestTestRepo/src/functions/public/Test-PSModuleTest.ps1 +++ b/tests/srcWithManifestTestRepo/src/functions/public/Test-PSModuleTest.ps1 @@ -1,5 +1,4 @@ -#SkipTest:Verbose:Just want to test that a function can have multiple skips. -function Test-PSModuleTest { +function Test-PSModuleTest { <# .SYNOPSIS Performs tests on a module. @@ -16,5 +15,4 @@ function Test-PSModuleTest { [string] $Name ) Write-Output "Hello, $Name!" - Write-Verbose 'Verbose message' -Verbose }