Update Bazel Cache #92
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Bazel Cache | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '0 */3 * * *' | |
| jobs: | |
| update-cvd-test-bazel-cache: | |
| if: ${{ github.repository_owner == 'google' }} | |
| runs-on: ubuntu-22.04-4core | |
| container: | |
| image: debian@sha256:9258a75a7e4323c9e5562b361effc84ee747920116d8adfc98a465a5cdc9150e # debian:bookworm-20250407 (amd64) | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 # aka v2 | |
| - name: Setup apt | |
| run: apt update -y && apt upgrade -y | |
| - name: Install dependencies | |
| run: apt install -y git clang libcurl4-openssl-dev clang-tidy libtinfo5 xxd cmake liblzma-dev libvpx-dev libopus-dev libaom-dev autoconf libtool yq | |
| - name: Install bazel | |
| run: bash tools/buildutils/installbazel.sh | |
| - name: Load cache config | |
| run: | | |
| cat .config/cache-config.env >> $GITHUB_ENV | |
| echo "JOB_HASH=$(yq .jobs[\"run-cvd-unit-tests\"] .github/workflows/presubmit.yaml | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | |
| - name: Generate cache key prefix | |
| run: echo "CACHE_KEY_PREFIX=${{ runner.os }}-${{ runner.arch }}-bazel-disk-cache-${{ env.CACHE_VERSION }}-unit-test-${{ env.JOB_HASH }}" >> $GITHUB_ENV | |
| - name: Mount Bazel cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: "~/bazel-disk-cache" | |
| key: ${{ format('{0}-{1}-{2}-{3}', env.CACHE_KEY_PREFIX, github.ref_name, github.sha, github.event_name) }} | |
| restore-keys: | | |
| ${{ github.event_name == 'push' && format('{0}-{1}-', env.CACHE_KEY_PREFIX, github.ref_name) || '' }} | |
| ${{ github.event_name == 'push' && format('{0}-main-', env.CACHE_KEY_PREFIX) || '' }} | |
| ${{ github.event_name == 'push' && format('{0}-', env.CACHE_KEY_PREFIX) || '' }} | |
| - name: Run unit tests | |
| run: cd base/cvd && bazel test --disk_cache=$HOME/bazel-disk-cache --sandbox_writable_path=$HOME --test_output=errors ... | |
| update-debian-package-bazel-cache: | |
| if: ${{ github.repository_owner == 'google' }} | |
| runs-on: ubuntu-22.04-4core | |
| container: | |
| image: debian@sha256:9258a75a7e4323c9e5562b361effc84ee747920116d8adfc98a465a5cdc9150e # debian:bookworm-20250407 (amd64) | |
| steps: | |
| - name: Check for dockerenv file | |
| run: (ls /.dockerenv && echo 'Found dockerenv') || (echo 'No dockerenv') | |
| - name: setup apt | |
| run: apt update -y && apt upgrade -y | |
| - name: install dependencies | |
| run: apt install -y git devscripts config-package-dev debhelper-compat golang protobuf-compiler yq | |
| - name: go version | |
| run: go version | |
| - name: checkout repository | |
| uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 # aka v2 | |
| with: | |
| path: "android-cuttlefish" | |
| - name: install bazel | |
| run: bash android-cuttlefish/tools/buildutils/installbazel.sh | |
| - name: Load cache config | |
| run: | | |
| cat android-cuttlefish/.config/cache-config.env >> $GITHUB_ENV | |
| echo "JOB_HASH=$(yq .jobs[\"build-debian-package\"] android-cuttlefish/.github/workflows/presubmit.yaml | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV | |
| - name: Generate cache key prefix | |
| run: echo "CACHE_KEY_PREFIX=${{ runner.os }}-${{ runner.arch }}-bazel-disk-cache-${{ env.CACHE_VERSION }}-debian-package-${{ env.JOB_HASH }}" >> $GITHUB_ENV | |
| - name: Mount Bazel cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: "~/bazel-disk-cache" | |
| key: ${{ format('{0}-{1}-{2}-{3}', env.CACHE_KEY_PREFIX, github.ref_name, github.sha, github.event_name) }} | |
| restore-keys: | | |
| ${{ github.event_name == 'push' && format('{0}-{1}-', env.CACHE_KEY_PREFIX, github.ref_name) || '' }} | |
| ${{ github.event_name == 'push' && format('{0}-main-', env.CACHE_KEY_PREFIX) || '' }} | |
| ${{ github.event_name == 'push' && format('{0}-', env.CACHE_KEY_PREFIX) || '' }} | |
| - name: install package build dependencies | |
| run: cd android-cuttlefish/base && mk-build-deps -i -t 'apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y' | |
| - name: build base debian package | |
| run: cd android-cuttlefish/base && debuild -e BAZEL_DISK_CACHE_DIR=$HOME/bazel-disk-cache -i -us -uc -b |