Skip to content

Commit

Permalink
ci: add workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SimsonW committed Mar 4, 2024
1 parent 5865524 commit 181c155
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 3 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish Package

on:
push:
tags: ["v*.*.*"]
paths-ignore:
- '**.md'
- '**.svg'
- '**.jpg'
- '**.png'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
environment: test
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set short SHA
run: echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV

- name: Check for git tag version
id: get_tag
run: |
TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
if [[ -n "$TAG" ]]; then
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
fi
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install Dependencies
run: pip install -r requirements.txt

- name: Run Version Verification
run: |
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!')"
- name: Install Twine
run: |
python -m pip install --upgrade pip
pip install twine
- name: Run Tests
env:
CLIENT_TEST_ENV: ${{ secrets.CLIENT_TEST_ENV }}
run: |
echo "$CLIENT_TEST_ENV" > .env
bash ./test/run_test.sh
- name: Build Package
run: python setup.py sdist bdist_wheel

- name: Publish Package
run: twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.IMAGE_TAG }}
release_name: Release ${{ env.IMAGE_TAG }}
body: |
This is the release for version ${{ env.IMAGE_TAG }}.
draft: false
prerelease: false
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Run test

on:
pull_request:
branches: [ "master" ]
paths-ignore:
- '**.md'
- '**.svg'
- '**.jpg'
- '**.png'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
environment: test
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set short SHA
run: echo "IMAGE_TAG=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV

- name: Check for git tag version
id: get_tag
run: |
TAG=$(git describe --tags --exact-match 2> /dev/null || echo "")
if [[ -n "$TAG" ]]; then
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
fi
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install Dependencies
run: pip install -r requirements.txt

- name: Run Tests
env:
CLIENT_TEST_ENV: ${{ secrets.CLIENT_TEST_ENV }}
run: |
echo "$CLIENT_TEST_ENV" > .env
bash ./test/run_test.sh
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
url="https://www.tasking.ai",
keywords=["TaskingAI", "LLM", "AI"],
install_requires=REQUIRES,
packages=find_packages(exclude=["test", "test.*"]),
packages=find_packages(exclude=["test", "test.*", "examples", "examples.*"]),
include_package_data=True,
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion taskingai/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = "taskingai"
__version__ = "0.1.3"
__version__ = "0.2.0"
3 changes: 2 additions & 1 deletion test/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export PYTHONPATH="${PYTHONPATH}:${parent_dir}"

echo "Starting tests..."

pytest -q --tb=no
pytest -m test_sync -q --tb=no
pytest -m test_async -q --tb=no

echo "Tests completed."

0 comments on commit 181c155

Please sign in to comment.