我想使用 GitHub Action 创建一个CI 管道,但我遇到了问题。该项目的前端是在Vue 3中开发的,并使用vitest来运行测试。它位于根目录中名为“WEB”的文件夹中。因此,我想在主分支中的每次提交时运行测试,但它返回此错误:
Error: .github#L1
each step must define a `uses` or `run` key
我使用了预先存在的“Node.js”模板,只是添加了“working-directory”属性来指定“WEB”文件夹。
这是我的“.yml”文件
name: Runs frontend tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
working-directory: ./WEB
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Execute Unit tests
- run: npm ci
- run: npm run test
最佳答案
当您添加 -
时,它会在 steps
数组中添加一个元素:
你应该这样做:
- name: Execute Unit tests
run: |
npm ci
npm run test
关于github-actions - GitHub Action Vitest CI 管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74499932/