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

[wip] try and get the replayapi deps to be cached in GH action #13

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
31 changes: 31 additions & 0 deletions .github/workflows/ghcr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,37 @@ jobs:
run: pipx install poetry
- name: Install Python dependencies using Poetry
run: make install-python-dependencies
- name: Checkout replayapi & devtools
run: |
mkdir -p replay
git -C replay clone --depth=1 https://github.com/replayio-public/replayapi.git
git -C replay clone --depth=1 https://github.com/replayio/devtools.git
REPLAY_DIR="$(cd replay && pwd)"
echo "REPLAY_DIR=$REPLAY_DIR" >> $GITHUB_ENV
- name: Set up NodeJS for replay
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Cache replay yarn dependencies
uses: actions/cache@v4
with:
path: |
./replay/replayapi/node_modules
./replay/devtools/node_modules
key: ${{ runner.os }}-replay-yarn-${{ hashFiles('replay/*/yarn.lock') }}
restore-keys: |
${{ runner.os }}-replay-yarn-
- name: Install replay devtools yarn dependencies
run: |
cd $REPLAY_DIR/devtools
yarn
- name: Install replayapi yarn dependencies
run: |
cd $REPLAY_DIR/replayapi
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
corepack enable
yarn
yarn yalc-all
- name: Create source distribution and Dockerfile
run: poetry run python3 openhands/runtime/utils/runtime_build.py --base_image ${{ matrix.base_image.image }} --build_folder containers/runtime --force_rebuild
- name: Build and push runtime image ${{ matrix.base_image.image }}
Expand Down
10 changes: 10 additions & 0 deletions openhands/runtime/utils/runtime_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ def prep_build_folder(
),
)

# Copy the replay deps
shutil.copytree(
Path(os.environ['REPLAY_DIR'], 'devtools'),
Path(build_folder, 'replay', 'devtools'),
)
shutil.copytree(
Path(os.environ['REPLAY_DIR'], 'replayapi'),
Path(build_folder, 'replay', 'replayapi'),
)

# Copy pyproject.toml and poetry.lock files
for file in ['pyproject.toml', 'poetry.lock']:
src = Path(openhands_source_dir, file)
Expand Down
12 changes: 2 additions & 10 deletions openhands/runtime/utils/runtime_templates/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,8 @@ RUN \
/openhands/micromamba/bin/micromamba run -n openhands poetry run pip install playwright && \
/openhands/micromamba/bin/micromamba run -n openhands poetry run playwright install --with-deps chromium

# Clone replay and make sure the layer is not stale when HEAD changes.
# For now we manually specify a revision as an argument to bust caches when building images.
ARG REPLAYAPI_SHA
ARG EXPECTED_REVISION=59551569f5e3277991175de0a47ea5ea0e69ce95
RUN \
mkdir -p /replay && \
git -C /replay clone https://github.com/replayio-public/replayapi.git && \
cd /replay/replayapi && \
git checkout ${REPLAYAPI_SHA} && \
./scripts/install-deps.sh
# Copy the replayapi code and dependencies
COPY ./replay /replay

# More stuff.
RUN \
Expand Down
Loading