javascripttypescriptnpmgithub-ci

Github CI with TypeScript and Jest


Locally, running tsc or tsc -w in parallel to npm t -- --watch all work, but trying to replicate what I have into Github CI hasn't been working. For some reason I'm not even able to print the folders with ls. And the installation of both TypeScript and Jest seem to be successful, though.

When it runs inside Github CI, I simply receive a log of all of the possible commands from tsc right below Run tsc and a Error: Process completed with exit code 1..

This is my current setup inside 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

And this is my 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"
  }
}

And the only things I think are relevant in my tsconfig.json are:

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

Have I made a mistake in this setup? What have I missed? Here is the full setup of my project.


Solution

  • 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.