gitpod icon indicating copy to clipboard operation
gitpod copied to clipboard

Add ability to cache arbitrary directories across workspaces

Open mrsimonemms opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe

I run an extensive suite of pre-commit hooks on my default projects (example). These take quite some time to install every time I start a new workspace, somewhere in the region of 2-5 minutes. As pre-commit, by design, blocks git commit it means that I'm often waiting around if I have a quick change to make.

Describe the behaviour you'd like

Allow caching of arbitrary directories in the .gitpod.yml file. In both GitHub and GitLab, I'm able to cache things so the install is only about 20 seconds.

The cache could follow the GitLab syntax:

cache:
  paths:
    - /path/to/cache

To further emulate the GitLab behaviour, anything cached in the default branch should be available in default branch and all branches, and anything cached in a branch should only be available to the same branch name.

Eg:

  • cache directory on main should be available to main and feat/some-branch
  • anything cached by feat/some-other-branch, that should only be available to feat/some-other-branch

Describe alternatives you've considered

Additional context

mrsimonemms avatar Sep 24 '23 16:09 mrsimonemms

Hi @mrsimonemms! 👋

Using a custom dockerfile might be the best way to optimize this.

.gitpod.Dockerfile contents:

FROM gitpod/workspace-full

RUN sudo pip3 install pre-commit

ARG onetime_cache_dir="/tmp/.workdir"
RUN mkdir -p "${onetime_cache_dir}"
COPY --chown=gitpod:gitpod . "${onetime_cache_dir}"

RUN cd "${onetime_cache_dir}" \
  && pre-commit install --install-hooks -t pre-commit -t commit-msg
Customized for https://github.com/mrsimonemms/new
FROM gitpod/workspace-full

RUN curl -sfL gpm.simonemms.com | bash \
  && sudo pip3 install pre-commit cookieninja cruft

ARG onetime_cache_dir="/tmp/.workdir"
RUN mkdir -p "${onetime_cache_dir}"
COPY --chown=gitpod:gitpod . "${onetime_cache_dir}"

RUN cd "${onetime_cache_dir}" \
  && pre-commit install --install-hooks -t pre-commit -t commit-msg

.gitpod.yml contents:

image:
  file: .gitpod.Dockerfile

tasks:
  - name: Setup
    init: |
      pre-commit install --install-hooks -t pre-commit -t commit-msg
Customized for https://github.com/mrsimonemms/new
image:
  file: .gitpod.Dockerfile

tasks:
  - name: Setup
    init: pre-commit install --install-hooks -t pre-commit -t commit-msg && exit 0

vscode:
  extensions:
    - donjayamanne.git-extension-pack
    - EditorConfig.EditorConfig
    - waderyan.gitblame
    - GitHub.vscode-github-actions
    - ms-vscode.makefile-tools

With this setup it was almost instant, took no longer than a second to run the pre-commit command in the init task.

axonasif avatar Sep 28 '23 15:09 axonasif

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 23 '24 15:05 github-actions[bot]