plantain-00 / type-coverage

A CLI tool to check type coverage for typescript code
MIT License
1.21k stars 43 forks source link

Platform Dependent Results #51

Closed pacarvalho closed 4 years ago

pacarvalho commented 4 years ago

Version(if relevant): 2.7.1 (TSC 3.9.3)

Environment(if relevant):

Local: macOS 10.15.4 Local Github Action: node:12.6-buster-slim (running act locally for debug) Actual Github Action: ubuntu-lastest

Code(if relevant):

name: Typescript Coverage

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js 
        uses: actions/setup-node@v1
        with:
          node-version: 14.2.0
      - run: npm install -g global add type-coverage typescript
      - run: type-coverage

Expected:

I expected the results from running type-coverage locally and on the Github Action to be the same. However, they diverge by approximately 10%. Furthermore, in the Github action a list of files (variables?) is printed out whereas this does not happen locally.

Actual:

Last few lines of output running the Github Action with https://github.com/nektos/act locally (same result when run on actual Action):

| /github/workspace/App.tsx:64:41: key
| /github/workspace/App.tsx:64:46: value
| /github/workspace/App.tsx:66:15: key
| /github/workspace/App.tsx:66:20: key
| /github/workspace/App.tsx:67:15: name
| /github/workspace/App.tsx:67:21: key
| /github/workspace/App.tsx:68:37: value
| /github/workspace/App.tsx:68:43: component
| /github/workspace/App.tsx:69:15: options
| /github/workspace/App.tsx:69:24: value
| /github/workspace/App.tsx:69:30: options
(MISSING) 13298 89.80%!
| The type coverage rate(89.80%!)(MISSING) is lower than the target(90%!)(MISSING).

Complete output from running type-coverage locally:

➜  app git:(master) ✗ type-coverage
12964 / 13298 97.48%
type-coverage success.
plantain-00 commented 4 years ago

No enough information, just a guess. You didn't provide -p, then it's . as fallback, maybe current work directory is different between your local and github action.

pacarvalho commented 4 years ago

I discovered the problem!

Running locally it takes into consideration the node_modules folder which, as expected, is not pushed to GIT. However, the --ignore-files node_modules/* does not appear to fix the problem locally. Only deleting the folder solves it.

plantain-00 commented 4 years ago

If there is a case, --ignore-files a.ts, then even there is any in a.ts, it will not count. But if in b.ts import { A } from './a.ts', then types in a.ts will be used by b.ts(by Typescritpt API) that may introduce any in b.ts. That's the difference.