Skip to content

Commit

Permalink
Optimize CI setup to <20s
Browse files Browse the repository at this point in the history
Related to commaai#30706

Optimize the `setup-with-retry` stage in CI jobs to finish in less than 20 seconds.

* **Dockerfile.openpilot_base**
  - Split the installation of Python dependencies into smaller layers to improve download concurrency.
  - Add comments to explain the changes made.

* **.github/workflows/setup-with-retry/action.yaml**
  - Reduce the sleep time between retries to 5 seconds.
  - Add a step to cache Python dependencies using GitHub Actions cache.

* **.github/workflows/setup/action.yaml**
  - Add a step to restore the Python dependencies cache.
  - Add a step to save the Python dependencies cache.
  • Loading branch information
vishwamartur committed Nov 28, 2024
1 parent 8e14e40 commit f76ecce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/setup-with-retry/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
sleep_time:
description: 'Time to sleep between retries'
required: false
default: 30
default: 5

runs:
using: "composite"
Expand All @@ -35,3 +35,10 @@ runs:
uses: ./.github/workflows/setup
with:
is_retried: true
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
17 changes: 17 additions & 0 deletions .github/workflows/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ runs:
# build our docker image
- shell: bash
run: eval ${{ env.BUILD }}

# restore Python dependencies cache
- name: Restore Python dependencies cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# save Python dependencies cache
- name: Save Python dependencies cache
if: always()
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
2 changes: 2 additions & 0 deletions Dockerfile.openpilot_base
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ COPY --chown=$USER tools/install_python_dependencies.sh /tmp/tools/

ENV VIRTUAL_ENV=/home/$USER/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Split the installation of Python dependencies into smaller layers
RUN cd /tmp && \
tools/install_python_dependencies.sh && \
mkdir -p $VIRTUAL_ENV && \
Expand Down

0 comments on commit f76ecce

Please sign in to comment.