Skip to content

Commit

Permalink
chore(ci): avoid reinstall pipx and pin poetry version aligned with i…
Browse files Browse the repository at this point in the history
…n api dockerfile (langgenius#10426)
  • Loading branch information
bowenliang123 authored Nov 8, 2024
1 parent 7903ba0 commit 754bfb1
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 43 deletions.
36 changes: 36 additions & 0 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Setup Poetry and Python

inputs:
python-version:
description: Python version to use and the Poetry installed with
required: true
default: '3.10'
poetry-version:
description: Poetry version to set up
required: true
default: '1.8.4'
poetry-lockfile:
description: Path to the Poetry lockfile to restore cache from
required: true
default: ''

runs:
using: composite
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: pip

- name: Install Poetry
shell: bash
run: pip install poetry==${{ inputs.poetry-version }}

- name: Restore Poetry cache
if: ${{ inputs.poetry-lockfile != '' }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: poetry
cache-dependency-path: ${{ inputs.poetry-lockfile }}
10 changes: 3 additions & 7 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Poetry
uses: abatilo/actions-poetry@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Setup Poetry and Python ${{ matrix.python-version }}
uses: ./.github/actions/setup-poetry
with:
python-version: ${{ matrix.python-version }}
cache: poetry
cache-dependency-path: api/poetry.lock
poetry-lockfile: api/poetry.lock

- name: Check Poetry lockfile
run: |
Expand Down
16 changes: 3 additions & 13 deletions .github/workflows/db-migration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,15 @@ concurrency:
jobs:
db-migration-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Setup Poetry and Python
uses: ./.github/actions/setup-poetry
with:
python-version: ${{ matrix.python-version }}
cache-dependency-path: |
api/pyproject.toml
api/poetry.lock
- name: Install Poetry
uses: abatilo/actions-poetry@v3
poetry-lockfile: api/poetry.lock

- name: Install dependencies
run: poetry install -C api
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,28 @@ jobs:
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: api/**

- name: Install Poetry
if: steps.changed-files.outputs.any_changed == 'true'
uses: abatilo/actions-poetry@v3
files: |
api/**
.github/workflows/style.yml
- name: Set up Python
uses: actions/setup-python@v5
- name: Setup Poetry and Python
if: steps.changed-files.outputs.any_changed == 'true'
with:
python-version: '3.10'
uses: ./.github/actions/setup-poetry

- name: Python dependencies
- name: Install dependencies
if: steps.changed-files.outputs.any_changed == 'true'
run: poetry install -C api --only lint

- name: Ruff check
if: steps.changed-files.outputs.any_changed == 'true'
run: poetry run -C api ruff check ./api
run: |
poetry run -C api ruff check ./api
poetry run -C api ruff format --check ./api
- name: Dotenv check
if: steps.changed-files.outputs.any_changed == 'true'
run: poetry run -C api dotenv-linter ./api/.env.example ./web/.env.example

- name: Ruff formatter check
if: steps.changed-files.outputs.any_changed == 'true'
run: poetry run -C api ruff format --check ./api

- name: Lint hints
if: failure()
run: echo "Please run 'dev/reformat' to fix the fixable linting errors."
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/vdb-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Poetry
uses: abatilo/actions-poetry@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Setup Poetry and Python ${{ matrix.python-version }}
uses: ./.github/actions/setup-poetry
with:
python-version: ${{ matrix.python-version }}
cache: poetry
cache-dependency-path: api/poetry.lock
poetry-lockfile: api/poetry.lock

- name: Check Poetry lockfile
run: |
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ To protect your privacy, please avoid posting security issues on GitHub. Instead
## License

This repository is available under the [Dify Open Source License](LICENSE), which is essentially Apache 2.0 with a few additional restrictions.

2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM python:3.10-slim-bookworm AS base
WORKDIR /app/api

# Install Poetry
ENV POETRY_VERSION=1.8.3
ENV POETRY_VERSION=1.8.4

# if you located in China, you can use aliyun mirror to speed up
# RUN pip install --no-cache-dir poetry==${POETRY_VERSION} -i https://mirrors.aliyun.com/pypi/simple/
Expand Down

0 comments on commit 754bfb1

Please sign in to comment.