亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 CircleCI 中使用順序工作流

在 CircleCI 中使用順序工作流

慕哥9229398 2023-05-09 10:50:56
在 Real Python 的幫助下,我通過 CircleCI 了解了持續集成。我config.yml根據 RP 教程編寫了這個文件:version: 2jobs:  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 fileversion: 2jobs:  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 --covworkflows:  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.falseExited with code exit status 1我想知道我搞砸了什么。謝謝。
查看完整描述

3 回答

?
牛魔王的故事

TA貢獻1830條經驗 獲得超3個贊

我得到了同樣的錯誤并通過僅將版本更改為 2.1 解決了它:版本:2.1



查看完整回答
反對 回復 2023-05-09
?
HUX布斯

TA貢獻1876條經驗 獲得超6個贊

好吧,我想通了這個問題:

在 Real Python 教程中,構建和測試都是在單個作業中完成的,該作業在單個 docker 容器內運行。

我沒有意識到的是,每個工作都需要一個碼頭工人,而這些工作不共享碼頭工人。

這意味著為了將我的工作build和我的工作分開test,我必須:

  1. 重建虛擬環境

  2. 重新激活它

  3. 重新安裝安裝依賴項。

對于這兩個工作。只有這樣我才能運行 pytest。

這看起來效率很低,但現在可以了!


查看完整回答
反對 回復 2023-05-09
?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

我得到了相同的結果,并將添加的版本修復到工作流選項卡。像那樣:

workflows:
  version: 2
  build_and_test:
    jobs:
      ...

但要小心空格或制表符。


查看完整回答
反對 回復 2023-05-09
  • 3 回答
  • 0 關注
  • 209 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號