0

在本地,运行tsctsc -w并行于npm t -- --watch所有工作,但尝试将我所拥有的内容复制到 Github CI 并没有奏效。由于某种原因,我什至无法使用ls. 不过,TypeScript 和 Jest 的安装似乎都成功了。

当它在 Github CItsc中运行时,我只是从右下方收到所有可能命令的日志Run tsc和一个Error: Process completed with exit code 1..

这是我在 Github CI 中的当前设置:

...

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Installing TypeScript
        run: npm i -D typescript
      - name: Installing Jest
        run: npm i -D jest
      - name: Compiling TypeScript Code
        run: tsc
      - name: Running Tests
        run: npm t

这是我的package.json

{
  ...
  "main": "dist/content.js",
  "scripts": {
    "test": "jest",
    "testwatch": "jest --watchAll"
  },
  "devDependencies": {
    "@types/jest": "^26.0.15",
    "jest": "^26.6.2",
    "ts-jest": "^26.4.3",
    "typescript": "^4.0.5"
  }
}

我认为与我相关的唯一事情tsconfig.json是:

{
  "outDir": "./dist/",
  "rootDir": "./lib/",
}

我在这个设置中犯了错误吗?我错过了什么?是我的项目的完整设置。

4

1 回答 1

0

As mentioned in the comments by @jonrsharpe, the whole problem can be summarized by something close to a typo. I have basically forgotten to check out the code into the CI environment. So, I would have to add this to the start of the steps:

...
steps:
  - name: Checking out the Project's Code
    uses: actions/checkout@v2
  ...

Another issue Jon pointed out was the absence of the package-lock.json file, which would serve the purpose of making the packages installed in the project consistent with those installed in the CI VM — use npm ci instead of npm i then.

于 2020-11-07T19:50:48.640 回答