circleci + python + requests + slack 自动化测试集成

    技术2022-07-10  151

    circle ci 代码

    version: 2.1 orbs: python: circleci/python@0.2.1 slack: circleci/slack@3.4.2 jobs: xxxx-automated-tests: executor: python/default steps: - checkout - run: command: | pip install pipenv pipenv install pipenv run pytest ./test_api/test/test_xxxxx.py --html="./test_api/report/results.html" --junitxml="./test_api/report/results.xml" name: Test - store_test_results: path: ./test_api/report/ - store_artifacts: path: ./test_api/report/ destination: reports - slack/status workflows: main: jobs: - xxxx-automated-tests # hourly: # triggers: # - schedule: # cron: "5 * * * *" # filters: # branches: # only: # - master # jobs: # - xxxx-automated-tests

    Pipfile  

    [[source]] name = "pypi" url = "https://pypi.org/simple" verify_ssl = true [dev-packages] [packages] pytest = "*" requests = "*" pytest-html = "*" pyunitreport = "*" [requires] python_version = "3.7"

    slack 设置

    1. 设置circle ci ,找到projects ,点击Set Up Project

    2.复制circle ci 代码,并粘贴,点击Commit and Run​​​​​

    3.配置 circle ci 的project 

    4. 参照如下链接开始设置slack,设置完成就行了

    https://github.com/CircleCI-Public/slack-orb/wiki/Setup

    5. 设置circle ci里,project的环境变量

    6. 随便提交代码,触发测试, slack收到通知

    不懂就多看官网说明吧.多调试 常见问题:

    1.  circle ci 执行 shell 脚本权限不够

    git update-index --chmod=+x script.sh

    参考

    https://stackoverflow.com/questions/33942926/circleci-permission-denied-running-bash-script 

    Processed: 0.012, SQL: 9