feat: update ci gevent #1450
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: "Test state" | |
on: | |
push: | |
branches: | |
- main | |
- '*' | |
pull_request: | |
# The branches below must be a subset of the branches above | |
branches: [main, develop] | |
schedule: | |
- cron: '0 0 * * *' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# This workflow contains a single job called "build" | |
Run-API-TEST: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: dongtai/dongtai-mysql-unittest:latest | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd "mysqladmin ping --silent" | |
--health-interval 10s | |
--health-timeout 180s | |
--health-retries 10 | |
redis: | |
image: dongtai/dongtai-redis:latest | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt | |
pip install schemathesis | |
pip install httpx | |
- name: Django Api Testing | |
run: | | |
mysql --host=127.0.0.1 -uroot -p'dongtai-iast' -D dongtai_webapi < /home/runner/work/DongTai/DongTai/test/init.sql | |
cp dongtai_conf/conf/config.ini.test dongtai_conf/conf/config.ini | |
export DOC=TRUE | |
mkdir -p /tmp/logstash/report/{img,word,pdf,excel} && mkdir -p /tmp/iast_cache/package && mkdir -p /tmp/logstash/batchagent | |
python3 ./deploy/docker/version_update.py || true | |
python3 manage.py updatedepartmenttoken | |
python3 manage.py runserver 0.0.0.0:8000 > webapi.log & | |
sleep 15 | |
schemathesis run --base-url "http://localhost:8000/" -H 'Authorization: Token 67aebd78e700ad36a82a152276196b5f49fafeb0' http://localhost:8000/api/XZPcGFKoxYXScwGjQtJx8u/schema/ --hypothesis-suppress-health-check=data_too_large,filter_too_much,too_slow,large_base_example,function_scoped_fixture --validate-schema=false --hypothesis-verbosity normal | |
Run-BuildCheck: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
arch: ["linux/amd64", "linux/arm64"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and push ${{ matrix.arch }} | |
uses: docker/build-push-action@v2 | |
with: | |
file: Dockerfile | |
context: . | |
push: false | |
platforms: ${{ matrix.arch }} | |
tags: | | |
registry.cn-hongkong.aliyuncs.com/secnium/dongtai-server-test:latest | |
registry.cn-hongkong.aliyuncs.com/secnium/dongtai-server-test:1.0.${{github.run_number}} | |
Run-MypyCheck: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt | |
- name: Django Unit Testing | |
run: | | |
mypy --show-error-codes --ignore-missing-imports --no-incremental --show-error-codes --check-untyped-defs --disable-error-code var-annotated --disable-error-code list-item --disable-error-code attr-defined --disable-error-code assignment --disable-error-code misc --disable-error-code union-attr --disable-error-code index --disable-error-code call-overload --disable-error-code dict-item --disable-error-code truthy-function --disable-error-code operator --disable-error-code name-defined . | |
Run-Pep8Check: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt | |
pip install pycodestyle | |
- name: Django Unit Testing | |
run: | | |
pycodestyle --ignore=E501,E402,E302,E265,W503,W504 --statistics . | |
Run-Flake8Check: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt | |
pip install flake8 | |
- name: Django Unit Testing | |
run: | | |
flake8 --max-complexity 43 --statistics --ignore=E265,E302,E402,E501,F401,F541,F811,F841,W503,W504 --show-source . | |
Run-BanditCheck: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt | |
pip install bandit | |
- name: Django Unit Testing | |
run: | | |
bandit -iii -lll -r . | |
Run-Unit-TEST: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: dongtai/dongtai-mysql-unittest:latest | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd "mysqladmin ping --silent" | |
--health-interval 10s | |
--health-timeout 180s | |
--health-retries 10 | |
redis: | |
image: dongtai/dongtai-redis:latest | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install coverage | |
pip install -r requirements.txt | |
- name: Django Unit Testing | |
run: | | |
export CELERY_EAGER_TEST=TRUE | |
cp dongtai_conf/conf/config.ini.test dongtai_conf/conf/config.ini | |
mkdir -p /tmp/logstash/report/{img,word,pdf,excel} && mkdir -p /tmp/iast_cache/package && mkdir -p /tmp/logstash/batchagent | |
python3 ./deploy/docker/version_update.py || true | |
coverage run --source='.' manage.py test | |
coverage report | |
Run-Unit-TEST-In-Cython: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: dongtai/dongtai-mysql-unittest:latest | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd "mysqladmin ping --silent" | |
--health-interval 10s | |
--health-timeout 180s | |
--health-retries 10 | |
redis: | |
image: dongtai/dongtai-redis:latest | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install coverage | |
pip install -r requirements.txt | |
- name: Django Unit Testing | |
run: | | |
export CELERY_EAGER_TEST=TRUE | |
cp dongtai_conf/conf/config.ini.test dongtai_conf/conf/config.ini | |
mkdir -p /tmp/logstash/report/{img,word,pdf,excel} && mkdir -p /tmp/iast_cache/package && mkdir -p /tmp/logstash/batchagent | |
python3 ./deploy/docker/version_update.py || true | |
pip install Cython==3.0.0b3 | |
python setup.py build_ext --inplace | |
find . -name "*.so" | grep test | xargs rm | |
coverage run --source='.' manage.py test | |
coverage report | |
Run-API-TEST-With-Cython: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: dongtai/dongtai-mysql-unittest:latest | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd "mysqladmin ping --silent" | |
--health-interval 10s | |
--health-timeout 180s | |
--health-retries 10 | |
redis: | |
image: dongtai/dongtai-redis:latest | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ["3.10"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
sudo apt-get install build-essential cmake ninja-build python3-dev cython3 pybind11-dev libre2-dev -y | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install -r requirements.txt | |
pip install schemathesis | |
pip install httpx | |
- name: Django Api Testing | |
run: | | |
mysql --host=127.0.0.1 -uroot -p'dongtai-iast' -D dongtai_webapi < /home/runner/work/DongTai/DongTai/test/init.sql | |
cp dongtai_conf/conf/config.ini.test dongtai_conf/conf/config.ini | |
export DOC=TRUE | |
mkdir -p /tmp/logstash/report/{img,word,pdf,excel} && mkdir -p /tmp/iast_cache/package && mkdir -p /tmp/logstash/batchagent | |
python3 ./deploy/docker/version_update.py || true | |
pip install Cython==3.0.0b3 | |
python setup.py build_ext --inplace | |
python setup.py build_ext --inplace | |
python3 manage.py updatedepartmenttoken | |
python3 manage.py runserver 0.0.0.0:8000 > webapi.log & | |
sleep 15 | |
schemathesis run --base-url "http://localhost:8000/" -H 'Authorization: Token 67aebd78e700ad36a82a152276196b5f49fafeb0' http://localhost:8000/api/XZPcGFKoxYXScwGjQtJx8u/schema/ --hypothesis-suppress-health-check=data_too_large,filter_too_much,too_slow,large_base_example,function_scoped_fixture --validate-schema=false --hypothesis-verbosity normal | |
analyze: | |
name: Analyze | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
strategy: | |
fail-fast: false | |
matrix: | |
language: [ 'python' ] | |
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] | |
# Learn more about CodeQL language support at https://git.io/codeql-language-support | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Initializes the CodeQL tools for scanning. | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: ${{ matrix.language }} | |
# If you wish to specify custom queries, you can do so here or in a config file. | |
# By default, queries listed here will override any specified in a config file. | |
# Prefix the list here with "+" to use these queries and those in the config file. | |
# queries: ./path/to/local/query, your-org/your-repo/queries@main | |
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | |
# If this step fails, then you should remove it and run the build manually (see below) | |
- name: Autobuild | |
uses: github/codeql-action/autobuild@v2 | |
# ℹ️ Command-line programs to run using the OS shell. | |
# 📚 https://git.io/JvXDl | |
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | |
# and modify them (or add more) to build your code if your project | |
# uses a compiled language | |
#- run: | | |
# make bootstrap | |
# make release | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 |