Treating warnings as errors because process.env.CI = true

Hey,

since about 2 days now our working github action fails with “Treating warnings as errors because process.env.CI = true.” because the webpack build returns a few size warnings. I tried to simply circumvent this for now by setting CI to false but I cannot figure out how. It does not work if I set it inside the workflow via

- name: npm test:ci
      run: npm run test:ci
      env:
         CI: false

or if I include it in the npm command directly.

What am I doing wrong?

kind regards

8 Likes

can you try setting 

CI: ""
4 Likes

Hey, and thanks for the suggestion.

Unfortunately it did not resolve the situation. Just to be sure I added the CI env variable to the job as well as to the step in the workflow file. I also printed the env object to see what was in there as part of the job.

- name: Dump GitHub env object
        env:
          ENV_CONTEXT: ${{ toJson(env) }}
        run: echo "$ENV_CONTEXT"

This is what I got:

{
  "CI": ""
}

I must be missing something obvious…

Wait, I think it actually worked. Huh, that’s interesting - why is empty string working but false is not?

Thanks a lot, @ericsciple 

Glad someone else ran into this, I thought I was going crazy when all my deploys quit working.

4 Likes

My best guess is the downstream tool may check for the existence of the variable (not empty) or might check for “0” instead of “false” or something

Seems to be exactly the issue

https://github.com/facebook/create-react-app/blob/1cbc6f7db62f78747cb6ca41450099181139325e/packages/react-scripts/scripts/build.js#L198-L211 

if (
        process.env.CI &&
        (typeof process.env.CI !== 'string' ||
          process.env.CI.toLowerCase() !== 'false') &&
        messages.warnings.length
      ) {
        console.log(
          chalk.yellow(
            '\nTreating warnings as errors because process.env.CI = true.\n' +
              'Most CI servers set it automatically.\n'
          )
        );
        return reject(new Error(messages.warnings.join('\n\n')));
      }
2 Likes

So what changed ? Did github start setting the CI variable ? is there an annoucement ? It’s not mentionned in https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables

Cheers,

Jon

3 Likes

Regarding the “false” value, maybe OP had old react-scripts ? Fixed in 2017: https://github.com/facebook/create-react-app/commit/5b38c5439d9f078cbb65e3f9c6ae86cb6f9d7097

With recent react-scripts, using the following works:

env:
  CI: false
3 Likes