Skip to content

Commit 54c2ac4

Browse files
committed
ci: add workflow
1 parent 5865524 commit 54c2ac4

File tree

9 files changed

+144
-4
lines changed

9 files changed

+144
-4
lines changed

.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHAT_COMPLETION_MODEL_ID=TpHmCB8s
2+
3+
TASKINGAI_HOST=https://api.test199.com
4+
5+
TEXT_EMBEDDING_MODEL_ID=TpEZlEOK
6+
7+
TASKINGAI_API_KEY=taxy8i3OCfeJfh0eXW0h00cF2QT7nWyy

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags: ["v*.*.*"]
6+
paths-ignore:
7+
- '**.md'
8+
- '**.svg'
9+
- '**.jpg'
10+
- '**.png'
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
environment: test
19+
steps:
20+
- name: Checkout repo
21+
uses: actions/checkout@v3
22+
23+
- name: Set short SHA
24+
run: echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV
25+
26+
- name: Check for git tag version
27+
id: get_tag
28+
run: |
29+
TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
30+
if [[ -n "$TAG" ]]; then
31+
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
32+
fi
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: 3.x
38+
39+
- name: Install Dependencies
40+
run: pip install -r requirements.txt
41+
42+
- name: Run Version Verification
43+
run: |
44+
python -c "from config import CONFIG; import os; current_tag = os.getenv('IMAGE_TAG'); assert CONFIG.VERSION == current_tag, 'Version mismatch: Expected {} but got {}'.format(CONFIG.VERSION, current_tag); print('Version matched!')"
45+
46+
47+
- name: Install Twine
48+
run: |
49+
python -m pip install --upgrade pip
50+
pip install twine
51+
52+
- name: Run Tests
53+
env:
54+
CLIENT_TEST_ENV: ${{ secrets.CLIENT_TEST_ENV }}
55+
run: |
56+
echo "$CLIENT_TEST_ENV" > .env
57+
bash ./test/run_test.sh
58+
59+
- name: Build Package
60+
run: python setup.py sdist bdist_wheel
61+
62+
- name: Publish Package
63+
run: twine upload dist/*
64+
env:
65+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
66+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
67+
68+
- name: Create Release
69+
uses: actions/create-release@v1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
tag_name: ${{ env.IMAGE_TAG }}
74+
release_name: Release ${{ env.IMAGE_TAG }}
75+
body: |
76+
This is the release for version ${{ env.IMAGE_TAG }}.
77+
draft: false
78+
prerelease: false

.github/workflows/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Run test
2+
3+
on:
4+
pull_request:
5+
branches: [ "master" ]
6+
paths-ignore:
7+
- '**.md'
8+
- '**.svg'
9+
- '**.jpg'
10+
- '**.png'
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
environment: test
19+
steps:
20+
- name: Checkout repo
21+
uses: actions/checkout@v3
22+
23+
- name: Set short SHA
24+
run: echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV
25+
26+
- name: Check for git tag version
27+
id: get_tag
28+
run: |
29+
TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
30+
if [[ -n "$TAG" ]]; then
31+
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
32+
fi
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: 3.x
38+
39+
- name: Install Dependencies
40+
run: |
41+
pip install -r requirements.txt
42+
pip install -r test_requirements.txt
43+
44+
- name: Run Tests
45+
env:
46+
CLIENT_TEST_ENV: ${{ secrets.CLIENT_TEST_ENV }}
47+
run: |
48+
echo "$CLIENT_TEST_ENV" > .env
49+
bash ./test/run_test.sh

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ setuptools>=21.0.0
55
httpx>=0.23.0
66
pydantic>=2.5.0
77

8+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
url="https://www.tasking.ai",
2525
keywords=["TaskingAI", "LLM", "AI"],
2626
install_requires=REQUIRES,
27-
packages=find_packages(exclude=["test", "test.*"]),
27+
packages=find_packages(exclude=["test", "test.*", "examples", "examples.*"]),
2828
include_package_data=True,
2929
long_description=long_description,
3030
long_description_content_type="text/markdown",

taskingai/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__title__ = "taskingai"
2-
__version__ = "0.1.3"
2+
__version__ = "0.2.0"

test/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import os
2+
from dotenv import load_dotenv
3+
4+
load_dotenv()
25

36

47
class Config:

test/run_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export PYTHONPATH="${PYTHONPATH}:${parent_dir}"
44

55
echo "Starting tests..."
66

7-
pytest -q --tb=no
7+
pytest -m test_sync -q --tb=no
8+
pytest -m test_async -q --tb=no
89

910
echo "Tests completed."
1011

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ asyncio==3.4.3
1414
pytest-tornasync>=0.6.0
1515
pytest-trio==0.8.0
1616
pytest-twisted==1.14.0
17-
Twisted==24.3.0
17+
Twisted==24.3.0
18+
dotenv==1.0.0

0 commit comments

Comments
 (0)