在 Real Python 的帮助下,我通过 CircleCI 了解了持续集成。我config.yml根据 RP 教程编写了这个文件:
version: 2
jobs:
build:
docker:
- image: circleci/python:3.8
working_directory: ~/repo
steps:
# Step 1: obtain repo from GitHub
- checkout
# Step 2: create virtual env and install dependencies
- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
# Step 3: run linter and tests
- run:
name: run tests
command: |
. venv/bin/activate
pytest -v --cov
接下来,在我当前的项目中实施上述内容并确保其正常工作后,我继续阅读文档并找到了一些其他编写配置文件的方法。也就是说,我喜欢顺序工作流格式,因为它将构建和测试分开为两个不同的工作。我试图重组上述配置以遵循此准则:
# Python CircleCI 2.0 configuration file
version: 2
jobs:
build:
docker:
- image: circleci/python:3.8
working_directory: ~/repo
steps:
# Step 1: obtain repo from GitHub
- checkout
# Step 2: create virtual env and install dependencies
- run:
name: install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
unittest:
docker:
- image: circleci/python:3.8
# Step 3: run linter and tests
steps :
- checkout
- run:
name: run tests
command: |
. venv/bin/activate
pytest -v --cov
workflows:
build_and_test:
jobs:
- build
- unittest:
requires:
-build
但是,这会在构建 0.3 秒后失败并出现错误:
#!/bin/sh -eo pipefail
# Unsupported or missing workflows config version
#
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false
Exited with code exit status 1
我想知道我搞砸了什么。谢谢。
牛魔王的故事
HUX布斯
隔江千里
相关分类