ci: avoid GitHub action downloads #2
+12
-10
@@ -32,27 +32,29 @@ jobs:
|
|||||||
- name: Install MySQL build dependencies
|
- name: Install MySQL build dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y default-libmysqlclient-dev pkg-config
|
sudo apt-get install -y default-libmysqlclient-dev pkg-config python3-venv
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: python3 -m pip install -r requirements-dev.txt
|
run: |
|
||||||
|
python3 -m venv .venv-ci
|
||||||
|
.venv-ci/bin/python -m pip install -r requirements-dev.txt
|
||||||
- name: Check migrations
|
- name: Check migrations
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: python3 manage.py makemigrations --check --dry-run
|
run: ../.venv-ci/bin/python manage.py makemigrations --check --dry-run
|
||||||
- name: Django checks
|
- name: Django checks
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: python3 manage.py check
|
run: ../.venv-ci/bin/python manage.py check
|
||||||
- name: ASGI import check
|
- name: ASGI import check
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: python3 -c "from config.asgi import application; print(type(application).__name__)"
|
run: ../.venv-ci/bin/python -c "from config.asgi import application; print(type(application).__name__)"
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
run: python3 -m pytest -q
|
run: .venv-ci/bin/python -m pytest -q
|
||||||
- name: MySQL migrations and tests
|
- name: MySQL migrations and tests
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: mysql://root:ci-root-password@mysql:3306/hulumath
|
DATABASE_URL: mysql://root:ci-root-password@mysql:3306/hulumath
|
||||||
run: |
|
run: |
|
||||||
python3 backend/manage.py check --database default
|
.venv-ci/bin/python backend/manage.py check --database default
|
||||||
python3 backend/manage.py check_mysql
|
.venv-ci/bin/python backend/manage.py check_mysql
|
||||||
python3 backend/manage.py migrate --noinput
|
.venv-ci/bin/python backend/manage.py migrate --noinput
|
||||||
python3 -m pytest -q
|
.venv-ci/bin/python -m pytest -q
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: docker build -t hulumath:${{ gitea.sha }} .
|
run: docker build -t hulumath:${{ gitea.sha }} .
|
||||||
|
|||||||
+12
-10
@@ -38,34 +38,36 @@ jobs:
|
|||||||
- name: 安装 MySQL 编译依赖
|
- name: 安装 MySQL 编译依赖
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y default-libmysqlclient-dev pkg-config
|
sudo apt-get install -y default-libmysqlclient-dev pkg-config python3-venv
|
||||||
|
|
||||||
- name: 安装测试依赖
|
- name: 安装测试依赖
|
||||||
run: python3 -m pip install -r requirements-dev.txt
|
run: |
|
||||||
|
python3 -m venv .venv-ci
|
||||||
|
.venv-ci/bin/python -m pip install -r requirements-dev.txt
|
||||||
|
|
||||||
- name: 检查迁移文件
|
- name: 检查迁移文件
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: python3 manage.py makemigrations --check --dry-run
|
run: ../.venv-ci/bin/python manage.py makemigrations --check --dry-run
|
||||||
|
|
||||||
- name: Django 系统检查
|
- name: Django 系统检查
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: python3 manage.py check
|
run: ../.venv-ci/bin/python manage.py check
|
||||||
|
|
||||||
- name: ASGI 启动导入检查
|
- name: ASGI 启动导入检查
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: python3 -c "from config.asgi import application; print(type(application).__name__)"
|
run: ../.venv-ci/bin/python -c "from config.asgi import application; print(type(application).__name__)"
|
||||||
|
|
||||||
- name: 运行测试
|
- name: 运行测试
|
||||||
run: python3 -m pytest -q
|
run: .venv-ci/bin/python -m pytest -q
|
||||||
|
|
||||||
- name: MySQL 迁移与全量测试
|
- name: MySQL 迁移与全量测试
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: mysql://root:ci-root-password@mysql:3306/hulumath
|
DATABASE_URL: mysql://root:ci-root-password@mysql:3306/hulumath
|
||||||
run: |
|
run: |
|
||||||
python3 backend/manage.py check --database default
|
.venv-ci/bin/python backend/manage.py check --database default
|
||||||
python3 backend/manage.py check_mysql
|
.venv-ci/bin/python backend/manage.py check_mysql
|
||||||
python3 backend/manage.py migrate --noinput
|
.venv-ci/bin/python backend/manage.py migrate --noinput
|
||||||
python3 -m pytest -q
|
.venv-ci/bin/python -m pytest -q
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
if: ${{ github.event.pull_request.merged == true }}
|
if: ${{ github.event.pull_request.merged == true }}
|
||||||
|
|||||||
Reference in New Issue
Block a user