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.

Customize paths to cache

See original GitHub issue

Add own paths to the cache

I’m using the cypress orb to test my Nextjs application. A build is required to run the app so it would make it faster to cache the created build (and restore it). In my case it is .next/cache.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kylemhcommented, Dec 17, 2020

Where the recommendation comes from: https://github.com/vercel/next.js/blob/master/errors/no-cache.md

My current CircleCI Config:

version: 2.1

orbs:
  cypress: cypress-io/cypress@1

executors:
  default:
    resource_class: large
    docker:
      - image: cypress/base:14.10.1 # keep in sync with .nvmrc and any other executors

parameters:
  workspace_root:
    type: string
    default: '~/'
  primary_cache_key:
    type: string
    default: 'air/next-{{ .Branch }}-{{ checksum "yarn.lock" }}'
  backup_cache_key:
    type: string
    default: 'air/next-{{ .Branch }}-'
  org_level_cache_key:
    type: string
    default: 'air/next-'

exclude_main: &exclude_main
  filters:
    branches:
      ignore: main

aliases:
  - &attach_workspace
    attach_workspace:
      at: << pipeline.parameters.workspace_root >>

  - &restore_cache
    restore_cache:
      keys:
        - << pipeline.parameters.primary_cache_key >>
        # Fallback in case checksum fails.
        - << pipeline.parameters.backup_cache_key >>
        - << pipeline.parameters.org_level_cache_key >>
  - &yarn_install
    run:
      name: 'Installing dependencies...'
      command: yarn install --non-interactive --frozen-lockfile --cache_folder << pipeline.parameters.workspace_root >>.cache/yarn

  - &create_npmrc
    run:
      name: 'Create .npmrc to set NPM_TOKEN...'
      command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

jobs:
  install_dependencies:
    executor: default
    steps:
      - checkout
      - *attach_workspace
      - *create_npmrc
      - *restore_cache
      - *yarn_install
      - run: node --version
      - run: yarn --version
      - save_cache:
          key: << pipeline.parameters.primary_cache_key >>
          paths:
            - node_modules
            - << pipeline.parameters.workspace_root >>.cache/yarn
            - << pipeline.parameters.workspace_root >>.cache/Cypress

workflows:
  ci:
    jobs:
      - install_dependencies:
          <<: *exclude_main

      - cypress/run:
          <<: *exclude_main
          name: integration_tests
          requires:
            - install_dependencies
          executor: default
          pre-steps:
            - checkout
            - *attach_workspace
            - *restore_cache
            - *yarn_install
          store_artifacts: true
          attach-workspace: true
          record: true # record results on Cypress Dashboard
          parallel: true # split all specs across machines
          parallelism: 4 # use X number of CircleCI machines
          command-prefix: yarn # dont use npx
          group: 'all tests' # name this group "all tests" on the dashboard
          start: 'yarn build && yarn start' # start server before running tests
          wait-on: http://localhost:3000 # wait until server is ready

I’m sure big improvements can happen once webpack 5 is used because of partial builds from cache, but I’m curious how saving a cache may even improve anything…

I would need to build first, send the build over as part of the workspace to the orb steps, and THEN start… right?

1reaction
kylemhcommented, Mar 30, 2022

cuz it’s a legit issue! i guess I think to myself: it may not be your issue any longer, but it’s still a problem for all CircleCI users.

it’s possible it never gets done, but leaving it up here could help ensure it gets done sooner than it might otherwise

Read more comments on GitHub >

github_iconTop Results From Across the Web

Path Customization — paths • renv - GitHub Pages
This file is list of projects currently using the renv cache. With this, renv can crawl projects registered with renv and use that...
Read more >
Specify a Custom Cache Folder and Config Path - WP Rocket
Specify Custom Cache Folder​​ It's possible to specify a custom location by defining the following constants in wp-config. php: WP_ROCKET_CACHE_ ...
Read more >
Customize cache - Cloudflare Docs
Customize cache. Some possible combinations of origin web server settings and Cloudflare Page Rules include: Create a directory for static ...
Read more >
How to create a custom cache path ? · Issue #516 - GitHub
Hi, In my app I want to create a custom cache path and cache file name, How can I do this ?
Read more >
Cache Path - Swift Performance
However you can override this, you can use custom path. Usually you don't need to change it. If you transfer your ...
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