From ffe9665b77e858bf3edacaaa10fdfd21f9d52653 Mon Sep 17 00:00:00 2001 From: VSuryaprasad-HCL Date: Fri, 10 Jan 2025 10:45:41 +0000 Subject: [PATCH] [pins_workflow] Improve GitHub continuous integration performance. --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++---------- pins_infra_deps.bzl | 16 +++++++++++ 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82a22a0d..cd5d6f7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,29 +5,21 @@ on: branches: [ main ] pull_request: branches: [ main ] + schedule: + # Run daily at midnight to ensure we catch regressions. + # https://crontab.guru/#0_0_*_*_* + - cron: "0 0 * * *" jobs: build: - name: Bazel Build and Test - # We use Ubuntu 20.04 as it comes with GCC v9.3 by default. - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 env: BAZEL_CACHE_USER: github BAZEL_CACHE_PWD: ${{ secrets.BAZEL_CACHE_PWD }} BAZEL_CACHE_URL: pins-bazel-cache.onf.dev:9090 steps: - - uses: actions/checkout@v2 - - - name: Mount bazel cache - uses: actions/cache@v2 - with: - # See https://docs.bazel.build/versions/master/output_directories.html - path: "/tmp/repo-cache" - # See https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows - key: bazel-repo-cache-v1-${{ runner.os }}-${{ hashFiles('**/*_deps.bzl', '.bazelrc', '.bazelversion', 'WORKSPACE.bazel') }} - restore-keys: | - bazel-repo-cache-v1-${{ runner.os }}- + - uses: actions/checkout@v3 - name: Install system dependencies run: ./install_dependencies.sh @@ -39,6 +31,21 @@ jobs: https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-${ARCH} sudo chmod +x /usr/local/bin/bazel + - name: Mount bazel cache + uses: actions/cache/restore@v3 + with: + # See https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows + key: bazel-repo-cache-v3-${{ runner.os }}-${{ hashFiles('**/*_deps.bzl', '.bazelrc', '.bazelversion', 'WORKSPACE.bazel') }} + restore-keys: | + bazel-repo-cache-v3-${{ runner.os }}- + + - name: Save start time + uses: josStorer/get-current-time@v2 + id: start-time + with: + # Unix timestamp -- seconds since 1970. + format: X + # Authentication is enabled for R/W access for builds on main and branch PRs # Unauthenticated reads are allowed for PRs from forks - name: Build and Test @@ -51,3 +58,27 @@ jobs: BAZEL_OPTS+=" --remote_download_minimal" bazel build ${BAZEL_OPTS} //... bazel test ${BAZEL_OPTS} //... + + - name: Save end time + uses: josStorer/get-current-time@v2 + id: end-time + with: + # Unix timestamp -- seconds since 1970. + format: X + + - name: Calculate build duration + run: | + START=${{ steps.start-time.outputs.formattedTime }} + END=${{ steps.end-time.outputs.formattedTime }} + DURATION=$(( $END - $START )) + echo "duration=$DURATION" | tee "$GITHUB_ENV" + + - name: Save bazel cache + uses: actions/cache/save@v3 + # We create a new cache entry if either of the following is true: + # - We are on the master branch. + # - It took more than 5 minutes to build and test. + if: github.ref_name == 'main' || env.duration > 300 + with: + path: "/tmp/repo-cache" + key: bazel-repo-cache-v3-${{ runner.os }}-${{ hashFiles('**/*_deps.bzl', '.bazelrc', '.bazelversion', 'WORKSPACE.bazel') }} diff --git a/pins_infra_deps.bzl b/pins_infra_deps.bzl index ec7d5f13..d1b8b232 100644 --- a/pins_infra_deps.bzl +++ b/pins_infra_deps.bzl @@ -30,6 +30,14 @@ def pins_infra_deps(): "https://github.com/google/boringssl/archive/b8a2bffc598f230484ff48a247526a9820facfc2.tar.gz", ], ) + if not native.existing_rule("com_github_nelhage_rules_boost"): + # This version includes the fix for boost failures due to the xz library issue. + http_archive( + name = "com_github_nelhage_rules_boost", + url = "https://github.com/nelhage/rules_boost/archive/5160325dbdc8c9e499f9d9917d913f35f1785d52.zip", + strip_prefix = "rules_boost-5160325dbdc8c9e499f9d9917d913f35f1785d52", + sha256 = "feb4b1294684c79df7c1e08f1aec5da0da52021e33db59c88edbe86b4d1a017a", + ) if not native.existing_rule("com_github_grpc_grpc"): http_archive( name = "com_github_grpc_grpc", @@ -188,6 +196,14 @@ def pins_infra_deps(): build_file = "@//:bazel/BUILD.jsoncpp.bazel", sha256 = "6da6cdc026fe042599d9fce7b06ff2c128e8dd6b8b751fca91eb022bce310880", ) + if not native.existing_rule("com_github_ivmai_cudd"): + http_archive( + name = "com_github_ivmai_cudd", + build_file = "@//:bazel/BUILD.cudd.bazel", + strip_prefix = "cudd-cudd-3.0.0", + sha256 = "5fe145041c594689e6e7cf4cd623d5f2b7c36261708be8c9a72aed72cf67acce", + urls = ["https://github.com/ivmai/cudd/archive/cudd-3.0.0.tar.gz"], + ) if not native.existing_rule("com_gnu_gmp"): http_archive( name = "com_gnu_gmp",