【问题标题】:Stopping Travis-CI and AppVeyor from running at same time停止 Travis-CI 和 AppVeyor 同时运行
【发布时间】:2016-09-09 07:20:55
【问题描述】:

所以我在我的 github 上为一个开源项目进行持续集成。

对于这个项目,我已经确定我要运行集成测试, 作为 CI 的一部分。

现在因为集成测试使用单一的有限资源, 我一次只能运行一个。

所以我已经将 AppVeyor 和 Travis 都设置为一次只运行一个构建/测试。 但他们彼此并不了解。

处理这种情况的聪明方法是什么?

我目前的解决方法是获得第二个有限的理由,这样我就可以同时拥有两者。 但这有点贵; (对于某些费用价值)。

【问题讨论】:

  • 您可以使用某种外部“全局”互斥锁(锁)。这可以是在 Azure 网站上免费托管的外部 Redis 缓存或 AWS S3 存储项或简单的 Web API 服务。

标签: continuous-integration integration-testing travis-ci appveyor


【解决方案1】:

您可以使用 Appveyor REST API (https://www.appveyor.com/docs/api/projects-builds/#get-project-last-build) 让 Travis 等待 Appveyor 构建完成。这是 PowerShell 中的示例(我知道 PowerShell 不是 Travis 原生的,但这是我创建和测试示例的最简单方法)。

$token = '<your_api_token>'
$headers = @{
  "Authorization" = "Bearer $token"
  "Content-type" = "application/json"
}

while ((Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects/<your_account)namr>/<your_project_slug>' -Headers $headers  -Method Get).build.status -eq "running") {
    write-host "waiting for Appveyor build to stop running"
    Start-sleep 1
}

因此,如果您在 Travis 测试执行之前放置这样的内容,它应该会阻止并发访问您的有限资源。 此外,最好再添加一个条件以在一段时间后停止等待,即使它仍处于 running 状态,以防止事情永远卡住。

最后,我相信您可以采取其他方式——让 Appveyor 等待 Travis 完成构建。我只是不熟悉 Travis API 为您提供示例。

谢谢你, 伊利亚。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-14
    • 1970-01-01
    • 2017-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    相关资源
    最近更新 更多