Skip to main content

将 CI 结果部署到 git

项目描述

西科

构建状态 派皮 执照

将 CI 结果部署到 git

cico将 CI 环境生成的人工制品提交到 Git 结果分支。

对于每个测试的分支,都会在结果分支中创建一个目录。

  • 测试分支:您提交的分支由 CI 工具签出
  • results 分支:应该部署结果的分支
    • 可以在与测试分支不同的存储库中

安装

$ pip install cico

用法

deploy.py

from cico import TravisCI
from cico.results import Directory, File, Badge

TravisCI(
    repo = GitHub(USERNAME,   # GitHub Username (e.g. 'stefanhoelzl')
                  REPO_NAME,  # GitHub Repository (e.g. 'ci-results')
                  TOKEN),     # GitHub Personal access tokens
                              # ONLY ENCRYPTED (https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml)
    branch = RESULT_BRANCH,   # Git Branch with the results (e.g. 'cico-testing')
    results = [
        # Deploy file 'testresults.tap' into folder 'tap' (destination is optional)
        File("testresults.tap", destination="tap"),

        # Deploy file 'wrong_name.tap' as 'correct_name.tap' (rename is optional)
        File("wrong_name.txt", rename="correct_name.txt"),

        # Deploy directory 'covhtml' into folder 'coverage' (desitnation is optional)
        Directory("covhtml", destination="coverage"),

        # Create a Badge with the label "My Badge" and value "96" as mybadge.svg and mybadge.png
        # (png is optional) in the directory 'badges'
        Badge("badges/mybadge", png=True, label="My Badge", value=96,
              **anybadge_arguments),  # https://github.com/jongracecox/anybadge
    ]
).commit(
    # commit message (optional)
    # {build} gets replaced by build number
    # {branch} gets replaced by name of tested branch
    message="build {build} on branch {branch}",

    # perform 'git push' even if not executed in CI environment (default=False)
    no_ci_push=True
)

.travis.ymlafter_script部分

after_script:
  - python deploy.py

.travis.ymldeploy部分

deploy:
  provider: script
  skip_cleanup: true  # prevent TravisCI from cleaning up the files you want to deploy
  script: python deploy.py

cico-testing之后在存储库的分支中的目录结构ci-results

+-- master
    o-- correct_name.txt
    +-- tap
    |   o-- testresults.tap
    +-- covhtml
    |   +-- <all contents of covhtml in the tested branch>
    +-- badges
        o-- mybadge.svg
        o-- mybadge.png

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

cico-0.1.8.tar.gz (4.4 kB 查看哈希)

已上传 source

内置分布

cico-0.1.8-py3-none-any.whl (5.7 kB 查看哈希)

已上传 py3