fix: 代码优化 #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bkuser_ci_check | |
on: | |
push: | |
branches: [ main, pre_*, ft_*, release/* ] | |
paths: | |
- "src/bk-user/**" | |
- "src/idp-plugins/**" | |
pull_request: | |
branches: [ main, pre_*, ft_*, release/* ] | |
paths: | |
- "src/bk-user/**" | |
- "src/idp-plugins/**" | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: create idp plugin symbolic link | |
run: | | |
ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-user/bkuser | |
- name: Format & Lint with ruff | |
run: | | |
pip install ruff==0.1.4 | |
ruff format src/bk-user --config=src/bk-user/pyproject.toml --no-cache | |
ruff src/bk-user --config=src/bk-user/pyproject.toml --no-cache | |
- name: Lint with mypy | |
run: | | |
pip install mypy==1.6.1 types-requests==2.31.0.2 types-setuptools==57.4.18 types-dataclasses==0.1.7 types-redis==3.5.18 types-PyMySQL==1.1.0.1 types-six==0.1.9 types-toml==0.1.5 types-pytz==2023.3.0.0 types-urllib3==1.26.25.14 | |
mypy src/bk-user --config-file=src/bk-user/pyproject.toml | |
test: | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Start MySQL Container | |
uses: samin/mysql-action@v1.3 | |
with: | |
mysql version: "8.0" | |
mysql database: bk-user | |
mysql user: root | |
mysql password: root_pwd | |
mysql root password: root_pwd | |
- name: Start Redis Container | |
uses: supercharge/redis-github-action@1.4.0 | |
with: | |
redis-version: "3.2.0" | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: create idp plugin symbolic link | |
run: | | |
ln -s $(pwd)/src/idp-plugins/idp_plugins $(pwd)/src/bk-user/bkuser | |
- name: Set up Poetry | |
uses: abatilo/actions-poetry@v2.3.0 | |
with: | |
poetry-version: "1.5.1" | |
- name: Install dependencies | |
working-directory: src/bk-user | |
run: poetry install | |
- name: Run unittest | |
working-directory: src/bk-user | |
run: | | |
# random secret | |
export BK_APP_SECRET="fod6MKVTVi_3M5HgGoj-qI7b3l0dgCzTBwGypnDz4vg=" | |
# random secret key | |
export BKKRILL_ENCRYPT_SECRET_KEY="tttHSBLiVdQPItrfy7n9dV7AxAUMZpYVkD6IHMbL0VE=" | |
export BK_USER_URL="" | |
export BK_COMPONENT_API_URL="" | |
export BK_API_URL_TMPL="" | |
export MYSQL_PASSWORD=root_pwd | |
export MYSQL_HOST="127.0.0.1" | |
export INITIAL_ADMIN_USERNAME=admin | |
export INITIAL_ADMIN_PASSWORD=admin_pwd | |
export DJANGO_SETTINGS_MODULE=bkuser.settings | |
poetry run pytest ./tests |