plugin-tester

Buildkite Plugin Tester Docker 镜像

用于通过BATS测试Buildkite插件的基础Docker镜像

下载次数: 0状态:社区镜像维护者:buildkite仓库类型:镜像最近更新:
下载命令
点击查看

Buildkite Plugin Tester 镜像文档

镜像概述

Buildkite Plugin Tester 是一个基础 Docker 镜像,专为使用 BATS (Bash Automated Testing System) 测试 Buildkite 插件而设计。该镜像提供了一致的测试环境,简化了 Buildkite 插件的开发和测试流程。

核心功能和特性

  • 预安装 BATS 测试框架及常用辅助工具
  • 内置 Buildkite 插件测试所需的核心依赖
  • 提供标准化的测试运行环境,确保测试结果一致性
  • 支持插件钩子测试、环境变量验证和命令执行测试
  • 包含测试结果格式化和报告工具
  • 轻量级设计,基于 Alpine Linux 构建

使用场景和适用范围

  • Buildkite 插件开发过程中的自动化测试
  • 插件功能验证和回归测试
  • CI/CD 流程中集成插件测试步骤
  • 插件兼容性测试
  • 开源 Buildkite 插件的标准化测试环境提供

使用方法和配置说明

基本使用

bash
docker run --rm -v "$(pwd):/plugin" docker.xuanyuan.run/buildkite/plugin-tester

Docker Compose 配置

yaml
version: '3'
services:
  test:
    image: docker.xuanyuan.run/buildkite/plugin-tester
    volumes:
      - .:/plugin
    environment:
      - PLUGIN_TEST_DEBUG=true
      - BATS_REPORT_FORMAT=junit

环境变量配置

环境变量描述默认值
PLUGIN_PATH插件目录路径/plugin
TEST_PATH测试文件路径/plugin/tests
BATS_FILE_PATTERNBATS 测试文件匹配模式*.bats
PLUGIN_TEST_DEBUG启用调试模式false
BATS_REPORT_FORMAT测试报告格式 (tap/junit)tap
BATS_JUNIT_REPORT_PATHJUnit 报告输出路径/plugin/report.xml

测试文件结构

建议在插件项目中使用以下目录结构:

/plugin
├── hooks
│   ├── command
│   ├── pre-command
│   └── post-command
└── tests
    ├── command.bats
    ├── pre-command.bats
    └── post-command.bats

在 CI 中集成

在 .buildkite/pipeline.yml 中集成测试步骤:

yaml
steps:
  - label: ":test_tube: Test plugin"
    plugins:
      - docker#v3.8.0:
          image: "docker.xuanyuan.run/buildkite/plugin-tester"
          volumes:
            - "./:/plugin"

高级用法

自定义测试命令

bash
docker run --rm -v "$(pwd):/plugin" docker.xuanyuan.run/buildkite/plugin-tester bats tests/specific-test.bats

生成 JUnit 测试报告

bash
docker run --rm -v "$(pwd):/plugin" -e BATS_REPORT_FORMAT=junit docker.xuanyuan.run/buildkite/plugin-tester

交互式调试

bash
docker run --rm -it -v "$(pwd):/plugin" --entrypoint /bin/bash docker.xuanyuan.run/buildkite/plugin-tester

测试示例

创建 tests/command.bats 文件:

bash
#!/usr/bin/env bats

@test "command hook runs successfully" {
  run buildkite-plugin-tester hook command

  assert_success
  assert_output --partial "Hello from plugin command hook"
}

@test "plugin configuration is applied" {
  run buildkite-plugin-tester env -- plugin=my-plugin config-key=value

  assert_success
  assert_env "PLUGIN_CONFIG_KEY" "value"
}

维护和支持

  • 镜像源码地址: https://github.com/buildkite-plugins/plugin-tester
  • 问题反馈: https://github.com/buildkite-plugins/plugin-tester/issues
  • BATS 文档: https://github.com/bats-core/bats-core
  • Buildkite 插件开发指南: https://buildkite.com/docs/agent/v3/plugins

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 plugin-tester 镜像标签

docker pull docker.xuanyuan.run/buildkite/plugin-tester:<标签>

DockerHub 原生拉取命令

docker pull buildkite/plugin-tester:<标签>
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载在线技术支持专业版保障服务可用付费会员免广告