scullyio / scully

The Static Site Generator for Angular apps
https://scully.io/
MIT License
2.55k stars 257 forks source link

CircleCI build error #1228

Closed TomJWilliams closed 3 years ago

TomJWilliams commented 3 years ago

🐞 Bug report

Description

When building in CircleCI an error is received when attempting to run the command


scully -- --scanRoutes --showGuessError

:thinking: There is a potential this is related to puppeteer in CircleCI. I say this because this error occurs as an unhandled promise rejection when setRawMode of the input stream. I think scully does this after using puppeteer to virtually render but I could be incorrect in this premise.

I have followed the recommended advice in the Running Puppeteer on CircleCI found in the puppeteer troubleshooting documentation.

It is important to note that when running Scully locally against Windows 10 Professional, Scully works flawlessly. This leads me to believe this is either an error when implemented with CircleCI. Or that this is an issue with the container environment used with CircleCI.

Any assistance would be greatly appreciated.

🔬 Minimal Reproduction

Use the below circle ci config and build process

💻Your Environment

CircleCI config


version: 2.1
jobs:
  # The build job
  build:
    working_directory: ~/project
    docker:
      - image: circleci/node:12
    steps:
      # Checkout the code from the branch into the working_directory
      - checkout
      # Log the current branch
      - run:
          name: Show current branch
          command: echo ${CIRCLE_BRANCH}
      # Restore local dependencies from cache
      - restore_cache:
          keys:
          - dependency-cache-{{ checksum "package.json" }}
      # Install project dependencies
      - run:
          name: Install local dependencies
          command: npm install
      # Cache local dependencies if they don't exist
      - save_cache:
          key: project-{{ checksum "package.json" }}
          paths:
              - ./node_modules
      # Lint the source code
      #- run:
      #    name: Linting
      #    command: npm run lint
      # Test the source code
      #- run:
      #    name: Testing
      #    command: npm run test
      # Build project with different configuration based on the current branch
      - run:
          name: Build Angular
          command: |
              if [ "${CIRCLE_BRANCH}" == "circleci-project-setup" ]; then
                  npm run build-prod
              else
                  npm run build-dev
              fi
      # Build static sites with different configuration based on the current branch
      - run:
          name: Build Scully
          command: |
              if [ "${CIRCLE_BRANCH}" == "circleci-project-setup" ]; then
                  npm run scully-build
              else
                  npm run scully
              fi

package.json


{
  "name": "test-blog",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build-prod": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "scully": "scully",
    "scully-build": "scully -- --scanRoutes --showGuessError",
    "scully:serve": "scully serve"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.0.6",
    "@angular/cdk": "^11.0.3",
    "@angular/common": "~10.0.6",
    "@angular/compiler": "~10.0.6",
    "@angular/core": "~10.0.6",
    "@angular/forms": "~10.0.6",
    "@angular/platform-browser": "~10.0.6",
    "@angular/platform-browser-dynamic": "~10.0.6",
    "@angular/router": "~10.0.6",
    "@fortawesome/fontawesome-free": "^5.15.1",
    "@scullyio/init": "^1.0.1",
    "@scullyio/ng-lib": "^1.0.0",
    "@scullyio/scully": "^1.0.0",
    "@types/chart.js": "^2.9.29",
    "angular-bootstrap-md": "^10.1.1",
    "animate.css": "^4.1.1",
    "chart.js": "^2.5.0",
    "hammerjs": "^2.0.8",
    "ngx-disqus": "^2.4.3",
    "node-sass": "^5.0.0",
    "prismjs": "^1.23.0",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1100.5",
    "@angular/cli": "~10.0.5",
    "@angular/compiler-cli": "~10.0.6",
    "@flowaccount/scully-plugin-google-analytics": "0.0.2",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  }
}

Angular Version:


Angular: 10.0.14

Scully Version:


"@scullyio/scully": "^1.0.0",

🔥 Exception or Error



logging with severity "warning"
using plugins from folder "./scully"
 ☺   new Angular build imported
 ☺   Started servers in background
(node:277) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'setRawMode' of null
    at ReadStream.setRawMode (tty.js:75:28)
    at Interface._setRawMode (readline.js:290:16)
    at new Interface (readline.js:250:10)
    at Object.createInterface (readline.js:92:10)
    at /home/circleci/the-enterprise-programmer-web/node_modules/@scullyio/scully/src/lib/utils/scullydot.js:77:31
    at new Promise ()
    at Object.exports.askUser (/home/circleci/the-enterprise-programmer-web/node_modules/@scullyio/scully/src/lib/utils/scullydot.js:72:12)
    at Object.exports.startScully (/home/circleci/the-enterprise-programmer-web/node_modules/@scullyio/scully/src/lib/utils/startup.js:24:42)
    at /home/circleci/the-enterprise-programmer-web/node_modules/@scullyio/scully/src/scully.js:163:29
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:277) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:277) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
SanderElias commented 3 years ago

@TomJWilliams Your problem is likely due to puppeteer/chromium installation issues on circleCI. see some of the docs here: https://developers.google.com/web/tools/puppeteer/troubleshooting#running_puppeteer_on_circleci

TomJWilliams commented 3 years ago

@SanderElias Thanks for the quick reply. I have performed those steps and included their puppeteer orb. I am still receiving the same error.

SanderElias commented 3 years ago

@TomJWilliams Sorry, for the delay. Can you try adding the --noPrompt command line flag?

TomJWilliams commented 3 years ago

@SanderElias I attempted the --noPrompt option and had no additional success. It resulted in the same error message at the same step of the build process in the same line of code.

TomJWilliams commented 3 years ago

@SanderElias I just wanted to thank you for your assistance. I believe this issue has to do with alpine linux specifically. I was able to get the build working with CircleCI using both Ubuntu and also Windows Server. However, when I attempt to run the build on an alpine image despite the fact that the dependency installation completes. It still fails to build with the error provided at the beginning of running this issue. I do not know if you want to add something to the documentation regarding validated containers or not. But again I sincerely appreciate the assistance.

SanderElias commented 3 years ago

@TomJWilliams Thanks for the feedback. I think a FAQ with regards to this would be a welcome PR ;)

TomJWilliams commented 3 years ago

@TomJWilliams Thanks for the feedback. I think a FAQ with regards to this would be a welcome PR ;)

@SanderElias sir I would love to contribute. Ideally if you could tell me where in the FAQ I would be more than happy to add it. I was thinking in the FAQ for the CICD portion. Also I was thinking of creating some docker configurations that could be used for CircleCI that could get people started. However, I can understand if this is more niche because there are many people that would just as quickly use GitHub actions, Azure functions, or many the menagerie of CICD tools.

Simply stated, I would be more than happy to contribute in any way that the community or Hero Devs would like me to.

SanderElias commented 3 years ago

Here is a link. it takes you directly to the gitub editor for the FAQ page. Please take a look at the format we are using and try to keep the same layout. https://github.com/scullyio/scully/edit/main/docs/faq.md?message=docs%3A%20describe%20your%20change...