Skip to content

Commit

Permalink
feat: golang version sdk (#224)
Browse files Browse the repository at this point in the history
* feat: mv src to python

* init go

* optimize

* support stream

* optimize code

* optimize code

* add ut

* add ut

* add ci

* update go version

* update ci

* fix mock server

* update script

* update script

* fix makefile

* update script

* update script

* fix

* optimize setting

* fix

* compat

* fix lint

* add python version

* fix ci

* fix script

* fix script

* update script

* fix script

* fix script

* fix script

* fix script

* fix script

* fix script

* update version

* add ut

* add lint

* fix ci

* fix folder

* update readme && move doc template

* update readme

* refactor

* refactor option

* test

* test

* test

* test

* fix lint

* rename

* refactor

* reset

* fix script

* update readme

* fix lint

* add comment

* add api error

* change go version

* add close in body

* update workflow

* Go (#4)

* feat: mv src to python

* init go

* optimize

* support stream

* optimize code

* optimize code

* add ut

* add ut

* add ci

* update go version

* update ci

* fix mock server

* update script

* update script

* fix makefile

* update script

* update script

* fix

* optimize setting

* fix

* compat

* fix lint

* add python version

* fix ci

* fix script

* fix script

* update script

* fix script

* fix script

* fix script

* fix script

* fix script

* fix script

* update version

* add ut

* add lint

* fix ci

* fix folder

* update readme && move doc template

* update readme

* refactor

* refactor option

* test

* test

* test

* test

* fix lint

* rename

* Multi language go (#3)

* fix: dataset, trainer, evaluaton bug fix (#237)

* fix

* add more import on __init__.py in dataset package

* cookbook update

* refactor

* reset

* fix script

* update readme

* fix lint

* add comment

* add api error

* change go version

* add close in body

* update workflow

---------

Co-authored-by: Dobiichi-Origami <56953648+Dobiichi-Origami@users.noreply.github.com>

---------

Co-authored-by: shikuan <shikuan@baidu.com>
Co-authored-by: Dobiichi-Origami <56953648+Dobiichi-Origami@users.noreply.github.com>

* fix workflow

* add cache to actions

* fix workflow

* update workflow

* update workflow

* remove changelog

* fix rtd

* add go release action

* add copyright

---------

Co-authored-by: shikuan <shikuan@baidu.com>
Co-authored-by: Dobiichi-Origami <56953648+Dobiichi-Origami@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 2, 2024
1 parent b658f26 commit 62049e3
Show file tree
Hide file tree
Showing 196 changed files with 2,322 additions and 176 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/doc_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
on:
push:
branches: ['main']
pull_request:
path:
- "python/**"
- "docs/**"
- "README.md"
workflow_dispatch:

name: Docs

defaults:
run:
shell: bash
working-directory: ./python

env:
RUFF_OUTPUT_FORMAT: github

jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- 'ubuntu-latest'
python-version:
- '3.11'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
- name: Install Poetry
run: |
pip install poetry
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
poetry lock
- name: Get Poetry version
run: poetry --version
- name: Setup Python Cache
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
cache: "poetry"
- name: Install deps
run: |
make install
- name: Build docs
run: make doc
- name: Prepare artifact
run: tar czvf /tmp/docs.tar.gz ./output/docs/_build
- uses: actions/upload-artifact@v4
with:
name: docs
path: /tmp/docs.tar.gz
52 changes: 52 additions & 0 deletions .github/workflows/doc_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Simple workflow for deploying static content to GitHub Pages
name: Release docs

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
workflow_run:
workflows: [Go Release, Python Release]
types:
- completed

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install
run: |
pip3 install poetry
make install
- name: Build docs
run: |
make doc
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: './output/docs/_build/html'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
65 changes: 65 additions & 0 deletions .github/workflows/go_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
push:
branches: ['main']
pull_request:
path:
- "go/**"
workflow_dispatch:

name: Go CI

defaults:
run:
shell: bash

jobs:
build:
name: Unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- 'ubuntu-latest'
- 'macos-latest'
- 'windows-latest'
go-version: [ '1.19', '1.20', '1.21.x' ]
python-version: [ '3.11' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
- name: Install Poetry
run: |
pip install poetry
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
cd python && poetry lock
- name: Setup Python Cache
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
cache: "poetry"
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: go/qianfan/go.mod
- name: Display version
run: |
go version
python --version
poetry --version
- name: Install deps
run: |
make install
- name: Run test
run: |
make mock
make -C go test
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: go/qianfan
78 changes: 78 additions & 0 deletions .github/workflows/go_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Go Release

on:
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build:
name: Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- 'ubuntu-latest'
go-version: [ '1.21.x' ]
python-version: [ '3.11' ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
- name: Display version
run: |
go version
python --version
- name: Install latest version of Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
pip install poetry
- name: Add Poetry to $PATH
run: |
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Get Poetry version
run: poetry --version
- name: Install deps
if: steps.cache-deps.cache-hit != 'true'
run: |
make install
- name: Run test
run: |
make mock
make -C go test
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: go/qianfan
- name: Check version
id: check-version
run: |
VERSION=$(cat go/qianfan/version.go|grep 'const Version ='|sed -r "s/.*\"v(.*)\"/\1/g")
echo $VERSION
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{ format('Go v{0}', steps.check-version.outputs.version) }}
token: ${{ secrets.QF_GITHUB_TOKEN }}
draft: false
generateReleaseNotes: true
tag: ${{ format('go/qianfan/v{0}', steps.check-version.outputs.version) }}
prerelease: ${{ contains(steps.check-version.outputs.version, 'rc') }}
commit: main
- name: Update Go module index
env:
GOPROXY: proxy.golang.org
VERSION: ${{ steps.check-version.outputs.version }}
run: |
go list -m github.com/baidubce/bce-qianfan-sdk/go/qianfan@v$VERSION
28 changes: 17 additions & 11 deletions .github/workflows/pyci.yml → .github/workflows/py_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ on:
push:
branches: ['main']
pull_request:
path:
- "python/**"
workflow_dispatch:

name: Build
name: Python CI

defaults:
run:
shell: bash
working-directory: ./python

env:
RUFF_OUTPUT_FORMAT: github

jobs:
build:
name: Build tool
name: Unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -33,23 +36,22 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
# Only runs when key from caching step changes
- name: Install latest version of Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
- name: Install Poetry
run: |
pip install poetry
# Poetry still needs to be re-prepended to the PATH on each run, since
# PATH does not persist between runs.
- name: Add Poetry to $PATH
run: |
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
poetry lock
- name: Get Poetry version
run: poetry --version
- name: Setup Python Cache
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
cache: "poetry"
- name: Install deps
if: steps.cache-deps.cache-hit != 'true'
run: |
make install
- name: run lint
Expand All @@ -58,3 +60,7 @@ jobs:
run: make test
- name: Build artifacts
run: make build
- uses: actions/upload-artifact@v4
if: ${{ matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' }}
with:
path: ${{ github.workspace }}/python/output/**
Loading

0 comments on commit 62049e3

Please sign in to comment.