1

我在 github 上有一个 PowerShell 模块,它在 AppVeyor 上具有自动化功能,包括测试和发布。

最近的一项更改破坏了带有 Windows PowerShell 的新版本。一些小组仍然在 Windows PowerShell 上运行,他们向我告知了这一点(前同事)。

我的问题是是否以及如何使用 Pester 测试给定模块的两个版本。显然,在 Windows 系统上,您可以使用pwshor运行测试,powershell但我想知道是否有由Pesterv5 提供支持的更清洁的设置。

最重要的是,我想知道 AppVeyor 怎么可能,因为从文档中看,Powershell 的v5 和 v7 都没有图像?作为替代方案,文档提到可以使用多个图像,但我不明白会发生什么。目标是在 windows 和 core 上进行测试并发布一次。

4

1 回答 1

0

我曾经通过 AppVeyor 为我的一些 PowerShell 模块执行此操作。我的用例实际上是在 Linux 和 Windows 下进行测试,但这样做我有效地在 PS Core 和 Windows PowerShell 上进行测试。该模块不再使用 AppVeyor,但我返回提交历史并从其 appveyor.yml 中提取以下内容。

正如 Mathias 所说,您想使用多个图像,如果需要,您还可以让不同的图像运行不同的构建脚本:


image:
- WMF 5
- Ubuntu
- Visual Studio 2017

# Skip on updates to the readme.
# We can force this by adding [skip ci] or [ci skip] anywhere in commit message 
skip_commits:
  message: /updated README.*|update README.*s/

build: false

#Kick off the CI/CD pipeline
test_script:
  - pwsh: .\build.ps1

for:
-
  matrix:
    only:
      - image: WMF 5
  
  test_script:
  - ps: .\build.ps1

我认为这使用了 3 个图像,因为它在 Windows PowerShell、Ubuntu 上的 PS Core 和 Windows 上的 PS Core 上进行测试。

于 2021-09-20T18:21:48.633 回答