Skip to content

Updated dependencies and minimal requirements in setup.py #847

Updated dependencies and minimal requirements in setup.py

Updated dependencies and minimal requirements in setup.py #847

Workflow file for this run

name: Build, Lint, Test & Scan
on:
push:
pull_request:
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup the environment
run: |
python3 -V
python3 -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build docs using Sphinx
working-directory: docs
run: |
pip install -r requirements.txt
make html
- name: Save HTML docs
uses: actions/upload-artifact@v3
with:
name: docs
path: docs/build/html
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup the environment
run: |
python3 -V
python3 -m pip install --upgrade pip
pip install flake8 pytest pylint
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=12 --max-line-length=120 --statistics
- name: Lint with PyLint
run: pylint matebot_core/ -j 0 && echo "OK" || echo "FAIL"
test-sqlite:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and setup the environment
run: |
python3 -V
python3 -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run unittests with temporary sqlite3
run: python3 -X tracemalloc=5 -m unittest tests -v
test-mariadb:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
image:
- mariadb:10.5
- mariadb:10.9
- mariadb:10.10
python-lib:
- mysqlclient
- pymysql
services:
database:
image: ${{ matrix.image }}
env:
MARIADB_USER: username
MARIADB_PASSWORD: password
MARIADB_DATABASE: db
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
ports:
- 127.0.0.1:3306:3306/tcp
options: >-
--health-cmd="mysqladmin ping"
--health-interval 5s
--health-timeout 3s
--health-retries 3
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install extra C dependency
run: sudo apt install default-libmysqlclient-dev build-essential -y
if: ${{ matrix.python-lib == 'mysqlclient' }}
- name: Install dependencies and setup the environment
run: |
python3 -V
python3 -m pip install --upgrade pip
pip install ${{ matrix.python-lib }}
pip install -r requirements.txt
- name: Prepare config for pymysql
run: |
python3 -m matebot_core init --database mysql+pymysql://username:password@127.0.0.1/db?charset=utf8mb4 --no-migrations --no-community
echo -e '\nDATABASE_URL = "mysql+pymysql://username:password@127.0.0.1/db?charset=utf8mb4"' >> tests/conf.py
if: ${{ matrix.python-lib == 'pymysql' }}
- name: Prepare config for mysqlclient
run: |
python3 -m matebot_core init --database mysql+mysqldb://username:password@127.0.0.1/db?charset=utf8mb4 --no-migrations --no-community
echo -e '\nDATABASE_URL = "mysql+mysqldb://username:password@127.0.0.1/db?charset=utf8mb4"' >> tests/conf.py
if: ${{ matrix.python-lib == 'mysqlclient' }}
- name: Perform database migrations
run: |
alembic upgrade head
rm -fv config.json
- name: Prepare unittests
run: |
echo 'COMMAND_INITIALIZE_DATABASE = ["/bin/bash", ".github/workflows/test_mysql_setup.sh"]' >> tests/conf.py
echo 'COMMAND_CLEANUP_DATABASE = ["/bin/bash", ".github/workflows/test_mysql_teardown.sh"]' >> tests/conf.py
bash .github/workflows/test_mysql_setup.sh
bash .github/workflows/test_mysql_teardown.sh
sync
- name: Run unittests
run: python3 -X tracemalloc=5 -m unittest tests -v
- name: Read log file
run: |
if [ -f mysql.log ]; then cat mysql.log; fi
rm -fv mysql.log
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker image
uses: docker/build-push-action@v3
with:
context: .
tags: matebot_core:latest
- name: Run Docker image shortly
run: timeout -v --preserve-status 10s docker run --rm -e DATABASE_CONNECTION=sqlite:///test.db matebot_core:latest
- name: Run the SQLite tests in the image
run: docker run --rm --entrypoint bash -e DATABASE_CONNECTION=sqlite:///test.db matebot_core:latest -c "python3 -m unittest tests -v"
analyze:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: python
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:python"