Skip to content

Commit

Permalink
Fix push-images workflow failing due to low disk space. (#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayVas authored Feb 23, 2024
1 parent d38fcf3 commit a946189
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 12 deletions.
37 changes: 37 additions & 0 deletions .github/actions/mount-scratch-disk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2024 The Cross-Media Measurement Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Mount scratch disk
description: >
Create a bind mount for scratch disk space.
Note that this is a hack to utilize the currently largely unused space at
/mnt. This is relying on undocumented behavior that may change.
inputs:
mount-path:
description: Path to mount scratch disk
required: true
runs:
using: composite
steps:
- shell: bash
env:
MOUNT_PATH: ${{ inputs.mount-path }}
run: |
dir_name="$(printf '%s' "$MOUNT_PATH" | sha256sum | cut -d ' ' -f 1)"
source_path="/mnt/${dir_name}"
mkdir -p "$MOUNT_PATH"
sudo mkdir -p "${source_path}"
sudo chown 'runner:runner' "${source_path}"
sudo mount --bind "${source_path}" "$MOUNT_PATH"
16 changes: 5 additions & 11 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,12 @@ jobs:
repo_cache_path="$(bazelisk info repository_cache)"
echo "repo-cache-path=${repo_cache_path}" >> $GITHUB_OUTPUT
# This is a hack to utilize the undocumented relatively large empty
# scratch disk mounted at /mnt. It's currently needed to work around
# bazel-contrib/rules_oci#439 as that's what is pushing our usage over the
# limit. The alternative is to use a runner with more disk space.
# Hack to work around disk space consumed by bazel-contrib/rules_oci#439.
# The alternative is to use a runner with more disk space.
- name: Mount scratch disk
env:
BAZEL_CACHE_PATH: ${{ steps.get-cache-params.outputs.cache-path }}
run: |
mkdir -p "$BAZEL_CACHE_PATH"
sudo mkdir -p /mnt/bazel-cache
sudo chown 'runner:runner' /mnt/bazel-cache
sudo mount --bind /mnt/bazel-cache "$BAZEL_CACHE_PATH"
uses: ./.github/actions/mount-scratch-disk
with:
mount-path: ${{ steps.get-cache-params.outputs.cache-path }}

- name: Restore repository cache
uses: actions/cache/restore@v4
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/push-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:
image-tag: ${{ steps.get-image-tag.outputs.image-tag }}
permissions:
id-token: write
packages: write
env:
CONTAINER_REGISTRY: ghcr.io
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: ./.github/actions/free-disk-space

Expand Down Expand Up @@ -72,6 +73,16 @@ jobs:
repo_cache_path="$(bazelisk info repository_cache)"
echo "repo-cache-path=${repo_cache_path}" >> $GITHUB_OUTPUT
cache_path="$(bazelisk info output_base)"
echo "cache-path=${cache_path}" >> $GITHUB_OUTPUT
# Hack to work around disk space consumed by bazel-contrib/rules_oci#439.
# The alternative is to use a runner with more disk space.
- name: Mount scratch disk
uses: ./.github/actions/mount-scratch-disk
with:
mount-path: ${{ steps.get-cache-params.outputs.cache-path }}

- name: Restore repository cache
uses: actions/cache/restore@v4
with:
Expand Down

0 comments on commit a946189

Please sign in to comment.