Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed Installing NPM packages #491

Closed
haydenrust opened this issue Oct 29, 2024 · 4 comments
Closed

Failed Installing NPM packages #491

haydenrust opened this issue Oct 29, 2024 · 4 comments
Assignees

Comments

@haydenrust
Copy link

The orb does not work as expected

  • what version of the orb are you currently using?
    cypress-io/cypress@3

  • paste the circle.yml file if possible or at least the relevant portion

# Redrock Circle CI 2.1 Configuration File
#
# Job defaults
defaults: &defaults
  docker:
    # CircleCI maintains a library of pre-built images
    # documented at https://circleci.com/docs/2.0/circleci-images/
    - image: quay.io/pantheon-public/build-tools-ci:8.x-php8.2

  # Set working directory
  working_directory: ~/build

  # Environment settings
  environment:
    # Set environment time zone
    TZ: '/usr/share/zoneinfo/America/Denver'

    # The variables below usually do not need to be modified
    #
    #======================================================================================================================================
    # Circle CI 2.0 does not yet expand environment variables so they have to beg manually EXPORTed
    # Once environment variables can be expanded the variables below can be uncommented and the EXPORTs in set-up-globals.sh can be removed
    # See: https://discuss.circleci.com/t/unclear-how-to-work-with-user-variables-circleci-provided-env-variables/12810/11
    # See: https://discuss.circleci.com/t/environment-variable-expansion-in-workin-directory/11322
    # See: https://discuss.circleci.com/t/circle-2-0-global-environment-variables/8681
    #======================================================================================================================================
    #
    # See declare-variables.sh for more environment variables

    NOTIFY: './redrock/.circleci/redrock-deployment-scripts/composer-scripts/github/add-commit-comment {project} {sha} "Created multidev environment [{site}#{env}]({dashboard-url})." {site-url}'

# Use CircleCI 2.1
version: 2.1
orbs:
  # "cypress-io/cypress@3" installs the latest published
  # version "s.x.y" of the orb. We recommend you then use
  # the strict explicit version "cypress-io/[email protected]"
  # to lock the version and prevent unexpected CI changes
  cypress: cypress-io/cypress@3

#  python: circleci/[email protected]
jobs:
  # Install build dependencies and clone Redrock repository
  build:
    <<: *defaults
    steps:
      - checkout

      - attach_workspace:
          at: ~/build
      - run:
          name: Git clone 'redrock' master branch and copy files
          command: |
            git clone https://github.com/clearlink/redrock ../redrock
            rm -f ../redrock/pantheon.upstream.yml
            cp -Rf ../redrock/* ~/build
            cp -Rf ../redrock/.circleci/* ~/build/.circleci
      - run:
          name: Declare Redrock environment variables
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/declare-variables.sh
      - restore_cache:
          name: Restoring Composer cache
          keys:
            - composer-cache-{{ checksum "composer.json" }}
      - run:
          name: Installing Composer assets
          command: |
            composer config --global --auth http-basic.repo.packagist.com token $PACKAGIST_TOKEN
            composer -n build-assets
            composer install
      # Will eventually need these for upgrading to Composer 2
      #                   composer config --no-plugins allow-plugins.composer/installers true
      #                   composer config --no-plugins allow-plugins.johnpbloch/wordpress-core-installer true
      - save_cache:
          name: Saving Composer cache
          key: composer-cache-{{ checksum "composer.json" }}
          paths:
            - ~/.composer/cache
            - ~/build/vendor
      - restore_cache:
          name: Restoring node_modules cache
          keys:
            - node_modules-cache-{{ checksum "package.json" }}
      - run:
          name: Installing Node modules from package.json
          command: |
            echo "registry=https://npm.clearlink.com/" > ~/.npmrc
            npm install --python=python2.7
      - save_cache:
          name: Saving node_modules cache
          key: node_modules-cache-{{ checksum "package.json" }}
          paths:
            - ~/build/node_modules
      - run:
          name: Install redrock-devtools
          command: |
            npm install redrock-devtools -g
      - run:
          name: Building with redrock-devtools
          command: |
            redrock build
      - run:
          name: Remove husky
          command: |
            rm -rf .husky
      - run:
          name: Copying Bifrost child theme
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/copy-child-theme.sh
      - run:
          name: Inject WordPress application configuration settings
          command: |
            echo "define( 'PLL_COOKIE', false );"  >> ./config/application.php
            echo "define( 'WP_ROCKET_KEY', '$WP_ROCKET_KEY');" >> ./config/application.php
            echo "define( 'WP_ROCKET_EMAIL', '$WP_ROCKET_EMAIL' );"  >> ./config/application.php
            sed -i "s/'WP_CACHE', false/'WP_CACHE', TRUE/g" ./config/application.php
      - run:
          name: Creating symbolic links for Pantheon filesystem
          command: |
            rm -Rf web/app/uploads
            cd web/app
            ln -s ../../../files uploads
            ln -s ../../../files/cache cache
            ln -s ../../../files/cache/wp-rocket-config wp-rocket-config
            ln -s ../../../files/cache/advanced-cache.php advanced-cache.php
            mkdir -p ../../../files/cache/wp-rocket-config
            sed -i 's|/../../..'\'' . '\''/app/public/app|/../../web/app|g' ../../vendor/composer/autoload_static.php
            sed -i 's|/config/application.php|/app/config/application.php|g' ../wp-config.php
            ln -s ../../../files/private/wflogs wflogs
            ln -s ../../../files/private/wordfence-waf.php ../wp/wordfence-waf.php
            ln -s ../../../files/private/.user.ini ../.user.ini
      - run:
          name: Cleanup build Workspace
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/cleanup-pantheon.sh
      - run:
          name: Logging into Terminus with machine token
          command: |
            terminus --version
            terminus auth:login -n --machine-token="$TERMINUS_TOKEN"
      - run:
          name: Deploying to Pantheon development environment
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/deploy-pantheon-multidev.sh
          no_output_timeout: 1200
      - persist_to_workspace:
          # Must be relative path from working_directory
          root: .
          # Must be relative path from root
          paths:
            - .circleci
            - config
            - vendor
            - public
          # The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
          resource_class: large
  test:
    <<: *defaults
    docker:
      - image: ataylorme/docker-node-advanced-wordpress-on-pantheon:lighthouse
    steps:
      - checkout

      - run:
          name: Declare Redrock environment variables
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/declare-variables.sh

      - run:
          name: Lighthouse performance tests
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/lighthouse-performance-test.sh

      - store_artifacts:
          path: /tmp/artifacts
          destination: artifacts

  #  After approval push the site live on Pantheon using Terminus
  live:
    <<: *defaults
    steps:
      - checkout

      - attach_workspace:
          at: ~/build

      - run:
          name: Declare Redrock environment variables
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/declare-variables.sh

      - run:
          name: Logging into Terminus with machine token
          command: |
            terminus --version
            terminus auth:login -n --machine-token="$TERMINUS_TOKEN"

      - run:
          name: Deploying to Pantheon LIVE environment
          command: ~/build/.circleci/redrock-deployment-scripts/scripts/deploy-pantheon-live.sh

workflows:
  version: 2      
  build_and_test:
    jobs:
      # Install build dependencies
      - build:
          context: clearlink-global
      - cypress/run # "run" job comes from "cypress" orb
      - approval:
          context: clearlink-global
          type: approval
          requires:
            - build
          filters:
            branches:
              only:
                - master
      #  After approval push the site live on Pantheon using Terminus
      - live:
          context: clearlink-global
          requires:
            - approval

  • describe what you think should happen
    I expect my cypress test pipe to successfully pass
  • describe what happens
    cypress pipe fails stating "The npm ci command can only install with an existing package-lock.json blah blah blah"
image
@MikeMcC399
Copy link
Collaborator

@haydenrust

Have you considered committing a package-lock.json file to your repository, which cypress/run could use to install npm package dependencies? The error message you posted already suggests what you need to do:

npm error The npm ci command can only install with an existing package-lock.json or
npm error npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm error later to generate a package-lock.json file, then try again.

@haydenrust
Copy link
Author

@MikeMcC399 Thanks for the suggestion, but that isnt an option for us. The package.json and lock files are built on the fly in one of our circle jobs. Is there a way to tell cypress/run to wait for previous jobs to finish first? I tried finding something like that on the docs, but didnt see anything like that. Thanks!

@MikeMcC399
Copy link
Collaborator

@haydenrust

Thanks for the suggestion, but that isnt an option for us. The package.json and lock files are built on the fly in one of our circle jobs. Is there a way to tell cypress/run to wait for previous jobs to finish first? I tried finding something like that on the docs, but didnt see anything like that. Thanks!

That is more of a CircleCI topic than a Cypress one.

See CircleCI > Workflow orchestration > Sequential job execution for instance.

@haydenrust
Copy link
Author

@MikeMcC399 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants