Skip to content

Commit

Permalink
add examples (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-smile authored Nov 29, 2023
1 parent 7c0130c commit 2b7653c
Show file tree
Hide file tree
Showing 120 changed files with 3,271 additions and 2,138 deletions.
49 changes: 24 additions & 25 deletions .github/workflows/apigw-manager.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: apigw-manager

on:
push:
branches:
Expand All @@ -9,34 +11,31 @@ on:
- master
paths:
- "sdks/apigw-manager/**"
name: apigw-manager

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
python-version: ["3.6", "3.7"]
os: [ubuntu-20.04, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.1.15
- name: Install dependencies
working-directory: sdks/apigw-manager
run: |
poetry export -f requirements.txt --without-hashes -E demo --dev --output requirements.txt
python -m pip install --upgrade pip
python -m pip install . 'tox-gh-actions==2.12.0' -r requirements.txt
- name: Test with tox
working-directory: sdks/apigw-manager
run: tox
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'sdks/apigw-manager/requirements_tox.txt'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install . 'tox-gh-actions==2.12.0' -r requirements_tox.txt
working-directory: sdks/apigw-manager

- name: Test with tox
run: tox
working-directory: sdks/apigw-manager
43 changes: 24 additions & 19 deletions .github/workflows/bkapi-client-core.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: bkapi-client-core

on:
push:
branches:
Expand All @@ -9,28 +11,31 @@ on:
- "master"
paths:
- "sdks/bkapi-client-core/**"
name: bkapi-client-core

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.7]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
python-version: ["3.6", "3.7"]
os: [ubuntu-20.04, macos-latest, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install 'tox==3.23.0' 'tox-gh-actions==2.12.0'
- name: Test with tox
working-directory: sdks/bkapi-client-core
run: tox
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'sdks/bkapi-client-core/requirements_tox.txt'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install 'tox==3.23.0' 'tox-gh-actions==2.12.0'
- name: Test with tox
run: tox
working-directory: sdks/bkapi-client-core
44 changes: 43 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,46 @@ repos:
types: [python]
pass_filenames: false
entry: bash -c "cd sdks/paas-service && poetry run mypy . --config-file=./pyproject.toml"
files: '^sdks/paas-service/'
files: '^sdks/paas-service/'
# sdk bkapi-client-core
- repo: local
hooks:
- id: format
name: run ruff-formatter for "bkapi-client-core"
language: python
types: [python]
entry: bash -c 'cd sdks/bkapi-client-core/ && ruff format --config=pyproject.toml --force-exclude .'
files: sdks/bkapi-client-core/
- id: ruff
name: run ruff for "bkapi-client-core"
language: python
types: [python]
entry: bash -c 'cd sdks/bkapi-client-core/ && ruff --config=pyproject.toml --force-exclude --fix .'
files: sdks/bkapi-client-core/
- id: mypy
name: run mypy for "bkapi-client-core"
language: python
types: [python]
entry: mypy --config-file=sdks/bkapi-client-core/pyproject.toml
files: sdks/bkapi-client-core/
# sdk apigw-manager
- repo: local
hooks:
- id: format
name: run ruff-formatter for "apigw-manager"
language: python
types: [python]
entry: bash -c 'cd sdks/apigw-manager/ && ruff format --config=pyproject.toml --force-exclude .'
files: sdks/apigw-manager/
- id: ruff
name: run ruff for "apigw-manager"
language: python
types: [python]
entry: bash -c 'cd sdks/apigw-manager/ && ruff --config=pyproject.toml --force-exclude --fix .'
files: sdks/apigw-manager/
- id: mypy
name: run mypy for "apigw-manager"
language: python
types: [python]
entry: mypy --config-file=sdks/apigw-manager/pyproject.toml
files: sdks/apigw-manager/
16 changes: 0 additions & 16 deletions sdks/apigw-manager/.flake8

This file was deleted.

8 changes: 0 additions & 8 deletions sdks/apigw-manager/.isort.cfg

This file was deleted.

23 changes: 0 additions & 23 deletions sdks/apigw-manager/.pre-commit-config.yaml

This file was deleted.

13 changes: 11 additions & 2 deletions sdks/apigw-manager/CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
## Change logs

### 2.0.2
- 优化请求 bk-apigateway 接口失败时,打印的错误消息
### 3.0.0
- 添加指令 add_related_apps,支持为网关添加关联应用
- definition.yaml 添加 spec_version 字段,指定配置文件版本号
- Django Command 中,通过参数 --gateway-name 指定网关
- 基础镜像 apigw-manager 中,调整指令名称
- sync-apigateway 改为 sync-apigateway.sh
- apigw-manager 改为 apigw-manager.sh
- call_command 改为 call_command_or_warning
- call_definition_command 改为 call_definition_command_or_warning
- must_call_definition_command 改为 call_definition_command_or_exit
- 基础镜像 apigw-manager 中,sync-apigateway.sh 中去除指令 apply_apigw_permissions
- 优化请求 bk-apigateway 接口失败时,打印的错误消息
- 优化 README.md,提供 examples

### 2.0.1
- 修复镜像 sync-apigateway 中,同步任务失败时,脚本退出码为 0 的问题
Expand Down
6 changes: 4 additions & 2 deletions sdks/apigw-manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:/apigw-manager/demo/bin:$PATH"
ENV PATH="/opt/venv/bin:/apigw-manager/bin:$PATH"
RUN pip3 install --upgrade pip

COPY src /apigw-manager/src
COPY demo /apigw-manager/demo
COPY bin /apigw-manager/bin
COPY manage.py /apigw-manager/manage.py
COPY pyproject.toml /apigw-manager/pyproject.toml
COPY poetry.lock /apigw-manager/poetry.lock
COPY README.md /apigw-manager/README.md

WORKDIR /apigw-manager
RUN pip3 install .[demo,kubernetes]
RUN python manage.py migrate

WORKDIR /data

CMD ["sync-apigateway"]
CMD ["sync-apigateway.sh"]

ONBUILD ARG BK_APIGW_NAME
ONBUILD ENV BK_APIGW_NAME "${BK_APIGW_NAME}"
Expand Down
4 changes: 4 additions & 0 deletions sdks/apigw-manager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ poetry.lock: pyproject.toml
poetry lock --no-update
touch poetry.lock

.PHONY: requirements
requirements: poetry.lock
poetry export -f requirements.txt --without-hashes --extras demo --with dev --output requirements_tox.txt

README.rst: README.md
m2r --overwrite README.md

Expand Down
Loading

0 comments on commit 2b7653c

Please sign in to comment.