question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failures for test and lint runs in CI with shared cache

See original GitHub issue

Current Behavior

Using Jenkins as CI engine. Using shared Nx cache directory (/home/node/cache/nx) in CI:

sed -i 's|./cache/nx|/home/node/cache/nx|' nx.json

With this setup running test and lint in distributed setup (very similar to one provided in Nrwl example):

# lint
npx nx run-many --target=lint --projects=redacted-40-projects-here --parallel

# test
npx nx run-many --target=test --projects=redacted-40-projects-here --parallel

Getting same errors on seemingly random projects. Failed projects change when re-running same CI jobs, but never fail when running without shared cache and never fail locally (with or without you cache).

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at parseJsonWithComments (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/utils/fileutils.js:44:17)
    at Object.readJsonFile (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/utils/fileutils.js:40:12)
    at Object.readCache (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/core/nx-deps/nx-deps-cache.js:36:67)
    at Object.createProjectGraph (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:13:232)
    at Object.<anonymous> (/home/jenkins/agent/workspace/redacted/node_modules/@nrwl/workspace/src/command-line/run-many.js:17:46)
    at Generator.next (<anonymous>)
    at fulfilled (/home/jenkins/agent/workspace/redacted/node_modules/tslib/tslib.js:111:62)
> nx run redacted:lint 

Linting "redacted"...
Error while loading rule '@nrwl/nx/enforce-module-boundaries': Unexpected end of JSON input
Occurred while linting /home/jenkins/agent/workspace/redacted/libs/redacted/src/index.ts

Expected Behavior

It should be possible to set shared cache in CI environment without getting jobs failed.

Steps to Reproduce

It might be difficult to recreate whole environment so the issue would be reproducible as it is not clear what causes it. Please share any ideas what could be attempted to narrow down the root cause of this and I will give them a try.

Failure Logs

See under “Current Behaviour”.

Environment

The report is from local development environment, but it is same Node.js version as on CI:

>  NX  Report complete - copy this into the issue template

  Node : 14.15.4
  OS   : darwin x64
  npm  : 6.14.11
  
  nx : Not Found
  @nrwl/angular : 11.1.1
  @nrwl/cli : 11.1.1
  @nrwl/cypress : 11.1.1
  @nrwl/devkit : 11.1.1
  @nrwl/eslint-plugin-nx : 11.1.1
  @nrwl/express : Not Found
  @nrwl/jest : 11.1.1
  @nrwl/linter : 11.1.1
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.1.1
  @nrwl/web : Not Found
  @nrwl/workspace : 11.1.1
  typescript : 4.0.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
minijuscommented, Jan 22, 2021

@vsavkin It was me that created the PR that attempts to fix it, but it will definitely not address the linting issue. Could we have the issues open till it is confirmed?

1reaction
minijuscommented, Jan 19, 2021

readJsonFilecould be wrapped to try/catch for readCache: https://github.com/nrwl/nx/blob/2c7fa421eba594acf029fa44c0e19b093b9c01cb/packages/workspace/src/core/nx-deps/nx-deps-cache.ts#L58

This should solve issue with test target runs, but lint runs seems to fail in other way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caching in GitLab CI/CD
To share a cache across all branches and all jobs, use the same key for everything: ... It only works if the execution...
Read more >
GitLab CI: Cache and Artifacts explained by example
We improved Pipeline and make it reproducible. There are two drawbacks left. First, the cache is shared. Every job will pull the cache...
Read more >
Caching Dependencies - CircleCI
This document is a guide to caching dependencies in CircleCI pipelines. ... and benefits of a chosen strategy, and tips for avoiding problems...
Read more >
Using lint-staged, husky, and pre-commit hooks to fail fast and ...
Context switching kills productivity. Needlessly failed CI checks drag us between contexts after we have assumed our work is done.
Read more >
A Complete Guide to Linting Go Programs - freshman.tech
golangci-lint run may spot some problems with the default settings ... wrapcheck, wsl test: exhaustivestruct, paralleltest, testpackage, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found