Allow to Update-VSTeamWorkItem to add relations with other work items #439
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "build module" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- trunk | |
paths: | |
- "src/**" | |
- "Tests/**" | |
- ".docs/**" | |
- ".github/" | |
- "!.github/images/" | |
- "!.github/*.md" | |
- "!.vscode/**" | |
- "!.devContainer/**" | |
- "!tools/**" | |
- "!.gitignore" | |
- "!LICENSE" | |
- "!*.md" | |
pull_request: | |
branches: | |
- trunk | |
jobs: | |
build-stage: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
fail-fast: true | |
permissions: | |
checks: write | |
steps: | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
- name: Install and cache PowerShell modules | |
id: psmodulecache | |
uses: potatoqualitee/psmodulecache@v5.2 | |
with: | |
modules-to-cache: Pester, PSScriptAnalyzer, SHiPS, Trackyon.Utils, Trackyon.Markdown, Metadata, platyPS | |
- name: .NET Restore | |
shell: pwsh | |
run: dotnet restore --no-cache # have to use no cache of the build will fail on Windows | |
- name: Build module | |
shell: pwsh | |
run: | | |
if ("${{ matrix.os }}" -eq 'ubuntu-latest') { | |
./Build-Module.ps1 -configuration Release -buildHelp | |
} else { | |
./Build-Module.ps1 -configuration Release | |
} | |
- name: Run C# unit tests | |
shell: pwsh | |
run: dotnet test --logger "trx;LogFileName=test-results.trx" --logger "console;verbosity=detailed" | |
# - name: Publish C# test results | |
# if: success() || failure() | |
# uses: dorny/test-reporter@v1 | |
# with: | |
# name: C# tests results (${{ matrix.os }}) | |
# path: '**/test-results.trx' | |
# reporter: dotnet-trx | |
- name: Run PowerShell unit tests | |
shell: pwsh | |
run: | | |
Import-Module ./dist/*.psd1 | |
# This loads [PesterConfiguration] into scope | |
Import-Module Pester | |
$pesterArgs = [PesterConfiguration]::Default | |
$pesterArgs.Run.Exit = $true | |
$pesterArgs.Run.Throw = $true | |
$pesterArgs.Run.PassThru = $false | |
$pesterArgs.TestResult.Enabled = $true | |
$pesterArgs.Output.Verbosity = 'None' | |
$pesterArgs.Run.Path = './Tests/function' | |
$pesterArgs.TestResult.OutputFormat = 'JUnitXml' | |
$pesterArgs.TestResult.OutputPath = 'test-results.xml' | |
$env:VSTEAM_NO_UPDATE_MESSAGE = $true | |
$env:VSTEAM_NO_MODULE_MESSAGES = $true | |
Invoke-Pester -Configuration $pesterArgs | |
# - name: Publish PowerShell test results | |
# uses: dorny/test-reporter@v1 | |
# with: | |
# name: PS tests results (${{ matrix.os }}) | |
# path: '**/test-results.xml' | |
# reporter: jest-junit | |
- name: Copy files to staging folders | |
if: ${{ matrix.os == 'ubuntu-latest'}} | |
shell: pwsh | |
run: | | |
Copy-Item -Path "./dist/" -Destination ./staging/VSTeam/dist/ -Recurse -Force | |
Copy-Item -Path "./.gitignore","./README.md" -Destination ./staging/VSTeam/ -Recurse -Force | |
Copy-Item -Path "./Tests/SampleFiles/" -Destination ./staging/test/Tests/SampleFiles -Recurse -Force | |
Copy-Item -Path "./Tests/integration/tests/" -Destination ./staging/test/Tests/integration/tests -Recurse -Force | |
Copy-Item -Path "./tools/scripts/" -Destination ./staging/tools/scripts -Recurse -Force | |
Copy-Item -Path "./dist/*.psd1" -Destination ./staging/test/dist -Recurse -Force | |
- name: Run Static Code Analysis | |
if: ${{ matrix.os == 'ubuntu-latest'}} | |
shell: pwsh | |
run: | | |
Import-PowerShellDataFile ./dist/*.psd1 | Select-Object -ExpandProperty RequiredModules | Import-Module | |
$r = Invoke-ScriptAnalyzer -Path ./dist -Recurse | Where-Object severity -ne "Information" | |
$count = 0 | |
$r | ForEach-Object { | |
Write-Host "::error file=$($_.ScriptPath),line=$($_.Line),col=$($_.Column)::$($_.Message)" | |
$count++ | |
} | |
if ($count -ne 0) { throw "Static Code Analysis with error count = $count" } | |
- name: Publish Module | |
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: module | |
path: "./staging/VSTeam" | |
- name: Publish unit tests | |
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test | |
path: "./staging/test" | |
- name: Publish pipeline scripts | |
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pipeline-scripts | |
path: "./staging/tools" | |
package-stage: | |
name: Package | |
uses: ./.github/workflows/reusable.package.yml | |
needs: build-stage | |
secrets: | |
ghToken: ${{ secrets.GITHUB_TOKEN }} | |
testing-stage: | |
name: Testing API | |
uses: ./.github/workflows/reusable.integration-tests.yml | |
needs: package-stage | |
with: | |
pesterVersion: "5.2.0" | |
secrets: | |
ghToken: ${{ secrets.GITHUB_TOKEN }} | |
publish-stage: | |
name: PowerShell Gallery | |
needs: testing-stage | |
environment: "PowerShell Gallery" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download PS module artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: module | |
path: ./module | |
- name: Download nuget package artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: VSTeamPackage | |
path: ./nuget | |
- name: Download pipeline scripts | |
uses: actions/download-artifact@v3 | |
with: | |
name: pipeline-scripts | |
path: ./tools | |
- name: Get Next Version | |
id: semver | |
uses: ietf-tools/semver-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: trunk | |
- name: Publish module | |
shell: pwsh | |
run: | | |
./Install-ModuleDependencies.ps1 -ModulePath "../../module/dist" | |
./Invoke-PublishModule.ps1 -PSGalleryApiKey $env:NUGETAPIKEY -ModulePath "../../module" | |
env: | |
NUGETAPIKEY: ${{secrets.NUGETAPIKEY}} | |
working-directory: "./tools/scripts" | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
with: | |
path: "vsteam-repo" | |
- name: Update Version in PSD1 | |
run: | | |
if ($null -eq (Get-Module -Name Metadata -ListAvailable)) { | |
$null = Install-Module -Name Metadata -Scope CurrentUser -Force | |
} | |
$path = "vsteam-repo/Source/VSTeam.psd1" | |
$version = "${{ steps.semver.outputs.next }}" | |
$manifest = Import-Metadata -Path $path | |
$manifest.ModuleVersion = $version | |
$null = Export-Metadata -Path $path -InputObject $manifest | |
shell: pwsh | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "chore: Update VSTeam.psd1 Version to ${{ steps.semver.outputs.next }}" | |
file_pattern: "vsteam-repo/Source/VSTeam.psd1" | |
- uses: ncipollo/release-action@v1 | |
with: | |
name: ${{ steps.semver.outputs.next }} | |
artifacts: "nuget/*" | |
makeLatest: true | |
draft: false | |
artifactErrorsFailBuild: true | |
allowUpdates: true | |
commit: trunk | |
discussionCategory: "Announcements" | |
generateReleaseNotes: true | |
token: ${{ secrets.GITHUB_TOKEN }} |