Skip to content

Commit

Permalink
chore: speed up pre-commit initialization
Browse files Browse the repository at this point in the history
The pre-commit "environments" (dependencies) now get installed during image build rather than devcontainer start. This shaves a minute off the start time on my machine.
  • Loading branch information
afeld committed Jun 13, 2022
1 parent e193198 commit 2df60cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ RUN pip install -r docs/requirements.txt

COPY tests/pytest/requirements.txt tests/pytest/requirements.txt
RUN pip install -r tests/pytest/requirements.txt

# install pre-commit environments in throwaway Git repository
# https://stackoverflow.com/a/68758943
COPY .pre-commit-config.yaml .
RUN git init . && \
pre-commit install-hooks && \
rm -rf .git
7 changes: 2 additions & 5 deletions .devcontainer/postAttach.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/usr/bin/env bash
set -eu

# initialize hook environments
pre-commit install --install-hooks --overwrite

# manage commit-msg hooks
pre-commit install --hook-type commit-msg
# initialize pre-commit
pre-commit install --overwrite

# install cypress
cd tests/cypress && npm install && npx cypress install
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
default_install_hook_types:
- pre-commit
- commit-msg
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v1.2.0
Expand Down

0 comments on commit 2df60cb

Please sign in to comment.