Skip to content

Commit

Permalink
chore(wren-ai-service): optimize the PyTest and Image release CI (#508)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
paopa and cyyeh authored Jul 15, 2024
1 parent 14c396d commit 0a1a47d
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 44 deletions.
26 changes: 16 additions & 10 deletions .github/workflows/ai-service-release-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
26 changes: 16 additions & 10 deletions .github/workflows/ai-service-release-nightly-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 45 additions & 8 deletions .github/workflows/ai-service-release-stable-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand All @@ -37,13 +38,41 @@ 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 }}
poetry version --next-phase $version
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
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: "1.8.3"
- name: Set up Python
uses: actions/setup-python@v5
with:
poetry-version: ${{ matrix.poetry-version }}
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
Expand Down

0 comments on commit 0a1a47d

Please sign in to comment.