我正在为CICD学习Github行动的基础知识。我用诗歌来做属地管理。但我一直在扔poetry: command not found。如果我在每一步都运行source $HOME/.poetry/env (用我有限的知识打开新的shell ),它就能工作。我试图用.bashrc修改cat $HOME/.poetry/env >> ~/.bashrc,但它不起作用。
这是我的Yaml文件,谢谢^^
name: Django CI
on:
push:
branches:
- master
- develop
pull_request:
branches:
# - develop
- master
jobs:
Unit tests:
runs-on: ubuntu-latest
strategy: # Strategy
max-parallel: 4
matrix:
python-version: [3.8]
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
steps:
- name: Checkout Github repo
uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
source $HOME/.poetry/env
cat $HOME/.poetry/env >> ~/.bashrc
poetry install
echo "OK"
- name: Run unit tests
run: |
# If I run "source $HOME/.poetry/env", It works
poetry run python manage.py test发布于 2022-04-05 15:51:08
您最好使用这一行动安装诗歌并安装venv。
这是我在我的项目中使用的东西。它包括整个venv的缓存。缓存由于不同的Python版本和/或poetry.lock中的修改而失效。
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.1.13
virtualenvs-create: true
virtualenvs-in-project: true
- name: Set up cache
uses: actions/cache@v2
id: cached-poetry-dependencies
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'https://stackoverflow.com/questions/71076272
复制相似问题