[Day 26] BDD - 组合技

组合技 Drone + godog + Mattermost

当有需求要在k8s上透过drone定期跑godog进行BDD测试,并将测试结果推送到mattermost时,怎麽办呢?

首先需求拆解:

Create Your Pipeline

在BDD专案内,制作你的pipeline
以下以Drone为范例

kind: pipeline
type: kubernetes
name: bdd

steps:
- name: godog solo basic.feature
  image: rain123473/godog:v0.11.0
  commands:
    - cd solo
    - godog run features/basic.feature

- name: send notification
  when:
    status:
    - success
  image: plugins/slack
  settings:
    webhook:
      from_secret: bdd
    channel: ithome-bdd
    username: drone
    icon_url: https://img.icons8.com/color/2x/good-pincode.png
    template: >
        [DEV] BDD test build {{build.link}} succeeded. Good job.

- name: send failure notification
  when:
    status:
    - failure
  image: plugins/slack
  settings:
    webhook:
      from_secret: bdd
    channel: ithome-bdd
    username: drone
    icon_url: https://img.icons8.com/color/2x/high-priority.png
    template: >
       {{#success build.status}}
        [DEV] BDD test build {{build.link}} succeeded. Good job.
       {{else}}
        [DEV] BDD build {{build.link}} failed. Fix me please.
       {{/success}}

在drone yaml设定,可以使用

  when:
    status:

来绑定此step的状态,所以可以从step

  • send notification -> 当bdd测试「成功」寄送通知
  • send failure notification -> 当bdd测试「失败」寄送通知

看得出来唷!


Drone Cron

再次提醒一下
Cron Jobs 的时区是依照 UTC(Universal Time Coordinated),所以需要自己在转换一下时间
若你的需求是要台湾时间22:00~04:00,每小时触发的话,不能打22-04唷!要改成14-20才正确!

drone cron add "my/bdd-repo" "bdd-nighty-test" "0 0 14-20 * * *" --branch master

之後就能在Mattermost该channel内看到效果罗
https://ithelp.ithome.com.tw/upload/images/20210929/20115289sCtqcVTOzj.png---


以上就完成上述之需求(在k8s上透过drone定期跑godog进行BDD测试,并将测试结果推送到mattermost)了,今天就这样子拉~/images/emoticon/emoticon11.gif


<<:  冒险村19 - Activerecord-import

>>:  [Day20] Flutter GetX routing

认识CSS(三):CSS选择器

选择器(Selector)是指用来选择HTML中,哪些内容要套上的样式。 依据对象的不同有不同的写法...

MLOps专案关於安全性与合规性的10件注意事项

在ML的专案中,从资料的收集、建构模型、测试到部署到产品。这个流程除了需要自动化之外,也需要保有该行...

JavaScript - 来个多人ㄉ视讯聊天室

大家好~上次文章介绍了录音录影的功能,这次要来弄个多人视讯聊天室,竟然我们已经知道怎麽取得影音档案,...

D22 - 如何用 Apps Script 自动化地创造与客制 Google Slides?(三)一次看完所有档案的预览

今天的目标: 当要整理 Google Drive 时,会发现好多的档案、文件不确定哪个要怎麽做。一个...