Merge pull request #13 from devchat-ai/ci
Add Github Action to sync up site-packages with devchat
This commit is contained in:
commit
8d46415849
96
.github/workflows/sync-devchat.yml
vendored
Normal file
96
.github/workflows/sync-devchat.yml
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
name: Sync up devchat packages
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
devchat_branch:
|
||||||
|
description: "The branch of devchat to sync up with"
|
||||||
|
required: true
|
||||||
|
default: "main"
|
||||||
|
type: string
|
||||||
|
# push:
|
||||||
|
# branches:
|
||||||
|
# - ci
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
|
||||||
|
- name: Setup micromamba
|
||||||
|
uses: mamba-org/setup-micromamba@v1
|
||||||
|
with:
|
||||||
|
micromamba-version: "1.5.8-0"
|
||||||
|
init-shell: bash
|
||||||
|
environment-name: devchat_no_binary
|
||||||
|
create-args: >-
|
||||||
|
python=3.8
|
||||||
|
|
||||||
|
- name: Clone devchat repo to a temporary directory
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: devchat-ai/devchat
|
||||||
|
path: ./temp/devchat-repo
|
||||||
|
# ref: ${{ github.event.inputs.devchat_branch }}
|
||||||
|
|
||||||
|
- name: Generate the latest site-packages for devchat
|
||||||
|
shell: micromamba-shell {0}
|
||||||
|
run: |
|
||||||
|
SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
|
||||||
|
ITEMS_BEFORE=$(mktemp)
|
||||||
|
ls $SITE_PACKAGES > "$ITEMS_BEFORE"
|
||||||
|
echo ">>>>>>>>>> Start installing devchat dependencies..."
|
||||||
|
cd ./temp/devchat-repo
|
||||||
|
DEVCHAT_HEXSHA=$(git rev-parse HEAD | cut -c 1-8)
|
||||||
|
DEVCHAT_BRANCH=$(git branch --show-current)
|
||||||
|
pip install --no-binary :all: "pydantic<2"
|
||||||
|
pip install charset-normalizer --no-binary :all:
|
||||||
|
pip install git+https://github.com/yangbobo2021/tiktoken.git
|
||||||
|
pip install .
|
||||||
|
echo ">>>>>>>>>> Finish installing."
|
||||||
|
pip list
|
||||||
|
ITEMS_AFTER=$(mktemp)
|
||||||
|
ls $SITE_PACKAGES > "$ITEMS_AFTER"
|
||||||
|
echo ">>>>>>>>>> Replace the site-packages with the new one"
|
||||||
|
ITEMS_DIFF=$(comm -13 "$ITEMS_BEFORE" "$ITEMS_AFTER")
|
||||||
|
cd ../..
|
||||||
|
mv ./site-packages ./temp/site-packages-bk
|
||||||
|
mkdir -p ./site-packages
|
||||||
|
for item in $ITEMS_DIFF; do
|
||||||
|
cp -r "$SITE_PACKAGES/$item" ./site-packages
|
||||||
|
done
|
||||||
|
rm -rf ./temp
|
||||||
|
|
||||||
|
echo "DEVCHAT_HEXSHA=$DEVCHAT_HEXSHA" >> $GITHUB_ENV
|
||||||
|
echo "DEVCHAT_BRANCH=$DEVCHAT_BRANCH" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Commit, Push and Create PR
|
||||||
|
run: |
|
||||||
|
git config --local user.email "mingjing@merico.dev"
|
||||||
|
git config --local user.name "Update-Packages Action"
|
||||||
|
TIMESTAMP=$(date +'%Y%m%d-%H%M%S')
|
||||||
|
BRANCH_NAME=update-packages-$TIMESTAMP
|
||||||
|
git checkout -b $BRANCH_NAME
|
||||||
|
git diff --stat
|
||||||
|
git add ./site-packages
|
||||||
|
git commit -m "Sync up site-packages to devchat[$DEVCHAT_BRANCH]($DEVCHAT_HEXSHA)"
|
||||||
|
git status
|
||||||
|
git push origin $BRANCH_NAME
|
||||||
|
echo -e "This PR is auto-generated by GitHub Action. \n- devchat branch: \`$DEVCHAT_BRANCH\` \n- devchat hexsha: \`$DEVCHAT_HEXSHA\`" > pr_body
|
||||||
|
PR_BODY=$(cat pr_body)
|
||||||
|
gh pr create \
|
||||||
|
--title "Sync up site-packages to devchat[$DEVCHAT_BRANCH]($DEVCHAT_HEXSHA) $TIMESTAMP" \
|
||||||
|
--body "$PR_BODY" \
|
||||||
|
--draft \
|
||||||
|
--base main \
|
||||||
|
--head $BRANCH_NAME
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
Loading…
x
Reference in New Issue
Block a user