Refactor CI workflow to implement caching for Node.js and Python dependencies, and update installation commands for Node.js and Python
Some checks failed
CI / build (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
This commit is contained in:
@ -10,28 +10,31 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest-2
|
runs-on: ubuntu-latest-2
|
||||||
steps:
|
steps:
|
||||||
- name: 克隆本地 checkout action
|
|
||||||
run: |
|
|
||||||
git clone http://114.67.155.184:3000/niyyzf/checkout.git ./.actions/checkout
|
|
||||||
|
|
||||||
- name: 克隆本地 setup-node action
|
|
||||||
run: |
|
|
||||||
git clone http://114.67.155.184:3000/niyyzf/setup-node.git ./.actions/setup-node
|
|
||||||
|
|
||||||
- name: 克隆本地 setup-python action
|
|
||||||
run: |
|
|
||||||
git clone http://114.67.155.184:3000/niyyzf/setup-python.git ./.actions/setup-python
|
|
||||||
|
|
||||||
- name: 检查 setup-node 目录
|
|
||||||
run: ls -l ./.actions/setup-node
|
|
||||||
|
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
uses: ./.actions/checkout
|
uses: ./.actions/checkout
|
||||||
|
|
||||||
- name: 设置 Node.js
|
# Node.js 缓存
|
||||||
uses: ./.actions/setup-node
|
- name: 缓存 node_modules
|
||||||
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
node-version: '18'
|
path: platform/node_modules
|
||||||
|
key: node-modules-${{ hashFiles('platform/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
node-modules-
|
||||||
|
|
||||||
|
# Python 缓存
|
||||||
|
- name: 缓存 pip
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: pip-cache-${{ hashFiles('back/requirements.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
pip-cache-
|
||||||
|
|
||||||
|
- name: 安装 Node.js
|
||||||
|
run: |
|
||||||
|
curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
|
||||||
|
apt-get install -y nodejs
|
||||||
|
|
||||||
- name: 安装前端依赖
|
- name: 安装前端依赖
|
||||||
working-directory: platform
|
working-directory: platform
|
||||||
@ -41,19 +44,19 @@ jobs:
|
|||||||
working-directory: platform
|
working-directory: platform
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: 设置 Python
|
- name: 安装 Python
|
||||||
uses: ./.actions/setup-python
|
run: |
|
||||||
with:
|
apt-get update
|
||||||
python-version: '3.10'
|
apt-get install -y python3 python3-pip
|
||||||
|
|
||||||
- name: 安装后端依赖
|
- name: 安装后端依赖
|
||||||
working-directory: back
|
working-directory: back
|
||||||
run: pip install -r requirements.txt
|
run: pip3 install -r requirements.txt
|
||||||
|
|
||||||
- name: 运行后端测试(如有)
|
- name: 运行后端测试(如有)
|
||||||
working-directory: back
|
working-directory: back
|
||||||
run: |
|
run: |
|
||||||
if [ -f tests/test.py ]; then python -m unittest discover -s tests; fi
|
if [ -f tests/test.py ]; then python3 -m unittest discover -s tests; fi
|
||||||
|
|
||||||
- name: 构建 Docker 镜像
|
- name: 构建 Docker 镜像
|
||||||
run: docker-compose build
|
run: docker-compose build
|
||||||
Reference in New Issue
Block a user