mirror of
https://github.com/Canner/WrenAI.git
synced 2026-09-24 23:29:49 +08:00
chore(wren-ai-service): optimize the PyTest and Image release CI (#508)
* feat: reduce the time to install poetry and python * fix(wren-ai-service): remove the duplicate version * feat: using actions poetry to install poetry * chore: upgrade the poetry version for CI * chore: modify the trigger option to reduce the cose * chore: refactor the github action for release an image * chore(wren-ai-service): tag for producing changelogs * feat(wren-ai-service): produce change log in github action --------- Co-authored-by: Chih-Yu Yeh <chihyu.jimmy.yeh@gmail.com>
This commit is contained in:
@@ -24,7 +24,7 @@ jobs:
|
||||
else
|
||||
tag_name=commit-$(git log -1 --pretty=%h)
|
||||
fi
|
||||
echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT
|
||||
echo "TAG_NAME=$tag_name" >> $GITHUB_ENV
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
@@ -35,12 +35,18 @@ jobs:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push image
|
||||
env:
|
||||
TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }}
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:$TAG_NAME \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/canner/wren-ai-service
|
||||
tags: |
|
||||
type=raw,${{ env.TAG_NAME }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
context: ./wren-ai-service
|
||||
file: ./wren-ai-service/docker/Dockerfile
|
||||
@@ -30,13 +30,19 @@ jobs:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push image
|
||||
env:
|
||||
TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }}
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:$TAG_NAME \
|
||||
--tag ghcr.io/canner/wren-ai-service:nightly \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/canner/wren-ai-service
|
||||
tags: |
|
||||
type=raw,${{ env.TAG_NAME }}
|
||||
type=raw,nightly
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
context: ./wren-ai-service
|
||||
file: ./wren-ai-service/docker/Dockerfile
|
||||
@@ -25,6 +25,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
fetch-depth: 0
|
||||
- name: Set up Git
|
||||
run: |
|
||||
git config --global user.name "wren-ai[bot]"
|
||||
@@ -37,6 +38,32 @@ jobs:
|
||||
uses: abatilo/actions-poetry@v2
|
||||
with:
|
||||
poetry-version: 1.8.3
|
||||
- name: Generate and Save Change Log
|
||||
id: changelog
|
||||
run: |
|
||||
echo "Generating change log..."
|
||||
PREVIOUS_VERSION=release/ai-service/$(poetry version -s)
|
||||
echo "Previous version: $PREVIOUS_VERSION"
|
||||
CHANGE_LOG=$(git log --pretty=format:"%s" $PREVIOUS_VERSION..HEAD | grep wren-ai-service)
|
||||
|
||||
# Separate the change log into categories
|
||||
FEATURES=$(echo "$CHANGE_LOG" | grep "^feat" | sed 's/^/- /')
|
||||
FIXES_AND_CHORES=$(echo "$CHANGE_LOG" | grep -E "^(fix|chore)" | sed 's/^/- /')
|
||||
|
||||
# Create the full change log
|
||||
FULL_CHANGE_LOG="\nChangelog for the version\n"
|
||||
if [ -n "$FEATURES" ]; then
|
||||
FULL_CHANGE_LOG+="\nFeature and Enhancement\n$FEATURES"
|
||||
fi
|
||||
if [ -n "$FIXES_AND_CHORES" ]; then
|
||||
FULL_CHANGE_LOG+="\n\nFixes and Chores\n$FIXES_AND_CHORES"
|
||||
fi
|
||||
|
||||
{
|
||||
echo "CHANGE_LOG<<EOF"
|
||||
echo -e "$FULL_CHANGE_LOG"
|
||||
echo EOF
|
||||
} >> $GITHUB_ENV
|
||||
- name: Upgrade AI Service version
|
||||
run: |
|
||||
version=${{ github.event.inputs.version }}
|
||||
@@ -44,6 +71,8 @@ jobs:
|
||||
git add pyproject.toml
|
||||
git commit -m "Upgrade AI Service version to $version"
|
||||
git push
|
||||
git tag -a "release/ai-service/$version" -m "${{ env.CHANGE_LOG }}"
|
||||
git push origin "release/ai-service/$version"
|
||||
build-image:
|
||||
needs: upgrade-ai-service-version
|
||||
runs-on: ubuntu-latest
|
||||
@@ -59,11 +88,19 @@ jobs:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push image
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--tag ghcr.io/canner/wren-ai-service:${{ github.event.inputs.version }} \
|
||||
--tag ghcr.io/canner/wren-ai-service:latest \
|
||||
--file ./docker/Dockerfile \
|
||||
--push .
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/canner/wren-ai-service
|
||||
tags: |
|
||||
type=raw,${{ github.event.inputs.version }}
|
||||
type=raw,latest
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
context: ./wren-ai-service
|
||||
file: ./wren-ai-service/docker/Dockerfile
|
||||
@@ -1,14 +1,16 @@
|
||||
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||
|
||||
name: AI Service CI
|
||||
name: AI Service Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'wren-ai-service/**'
|
||||
- "wren-ai-service/**"
|
||||
pull_request:
|
||||
types: [ labeled ]
|
||||
types: [synchronize, labeled]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -23,25 +25,21 @@ defaults:
|
||||
working-directory: wren-ai-service
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
if: ${{ github.event.label.name == 'ci/ai-service' || github.event_name == 'push' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: [ "3.12.0" ]
|
||||
poetry-version: [ "1.8.3" ]
|
||||
pytest:
|
||||
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/ai-service') || github.event_name == 'push' }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python 3.12.0
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install Poetry
|
||||
uses: abatilo/actions-poetry@v2
|
||||
uses: abatilo/actions-poetry@v3
|
||||
with:
|
||||
poetry-version: ${{ matrix.poetry-version }}
|
||||
poetry-version: "1.8.3"
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: ./wren-ai-service/pyproject.toml
|
||||
cache: "poetry"
|
||||
- name: Install the project dependencies
|
||||
run: poetry install
|
||||
- name: Prepare testing environment and Run tests
|
||||
Reference in New Issue
Block a user