name: CI on: pull_request: branches: [main] concurrency: group: ci-${{ gitea.event_name }}-${{ gitea.ref }} cancel-in-progress: true jobs: test: runs-on: ubuntu-latest timeout-minutes: 20 services: mysql: image: mysql:8.0.35 env: MYSQL_ROOT_PASSWORD: ci-root-password MYSQL_DATABASE: hulumath options: >- --health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -pci-root-password --silent" --health-interval 5s --health-timeout 5s --health-retries 20 steps: - name: Checkout repository env: REPOSITORY_URL: http://117.72.28.96:8765/Jacky/Hulumath-Web.git REVISION: ${{ gitea.sha }} run: | git clone "$REPOSITORY_URL" . git checkout --detach "$REVISION" - name: Show Python version run: python3 --version - name: Install MySQL build dependencies run: | sudo apt-get update sudo apt-get install -y \ default-libmysqlclient-dev \ pkg-config \ python3-dev \ python3-venv - name: Install dependencies run: | python3 -m venv .venv-ci .venv-ci/bin/python -m pip install \ --index-url https://mirrors.aliyun.com/pypi/simple \ --timeout 120 \ --retries 5 \ -r requirements-dev.txt - name: Ruff checks run: .venv-ci/bin/ruff check backend scripts - name: Check migrations working-directory: backend run: ../.venv-ci/bin/python manage.py makemigrations --check --dry-run - name: Django checks working-directory: backend run: ../.venv-ci/bin/python manage.py check - name: ASGI import check working-directory: backend run: ../.venv-ci/bin/python -c "from config.asgi import application; print(type(application).__name__)" - name: SQLite tests and coverage run: | .venv-ci/bin/python -m pytest -q \ --cov=backend \ --cov-config=.coveragerc \ --cov-report=term \ --cov-report=xml:coverage.xml \ --cov-fail-under=75 - name: MySQL migrations and tests env: DATABASE_URL: mysql://root:ci-root-password@mysql:3306/hulumath run: | .venv-ci/bin/python backend/manage.py check --database default .venv-ci/bin/python backend/manage.py check_mysql .venv-ci/bin/python backend/manage.py migrate --noinput .venv-ci/bin/python -m pytest -q