Migrate daily staleness tests to GHA

PiperOrigin-RevId: 507022987
pull/11814/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent f48c668e0d
commit 8dc14f688c
  1. 30
      .github/workflows/staleness_check.yml
  2. 2
      .github/workflows/staleness_refresh.yml
  3. 10
      WORKSPACE
  4. 19
      build_defs/upb.patch
  5. 64
      kokoro/linux/bazel.sh
  6. 18
      kokoro/linux/staleness/release.cfg

@ -0,0 +1,30 @@
name: Staleness tests
on:
schedule:
# Run daily at 10 AM UTC (2 AM PDT)
- cron: 0 10 * * *
permissions: {}
jobs:
test:
strategy:
fail-fast: false
matrix:
branch: [main, 22.x]
os: [{ name: Linux, value: ubuntu-latest}]
name: ${{ matrix.os.name }} ${{ matrix.branch}}
runs-on: ${{ matrix.os.value }}
steps:
- name: Checkout ${{ matrix.branch }}
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ matrix.branch}}
- name: Run all staleness tests
uses: ./.github/actions/bazel
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: staleness_check/${{ matrix.branch}}_${{ matrix.os.value }}
bash: bazel query 'attr(tags, "staleness_test", //...)' | xargs bazel test $BAZEL_FLAGS

@ -1,4 +1,4 @@
name: Auto-generate checked-in files
name: Auto-generate stale checked-in files
on:
push:

@ -113,6 +113,16 @@ install_deps()
load("@utf8_range//:workspace_deps.bzl", "utf8_range_deps")
utf8_range_deps()
http_archive(
name = "rules_fuzzing",
sha256 = "d9002dd3cd6437017f08593124fdd1b13b3473c7b929ceb0e60d317cb9346118",
strip_prefix = "rules_fuzzing-0.3.2",
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.3.2.zip"],
)
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
rules_fuzzing_dependencies()
bind(
name = "python_headers",
actual = "@system_python//:python_headers",

@ -9,3 +9,22 @@
# end:github_only
def _upbc(stage):
--- cmake/build_defs.bzl
+++ cmake/build_defs.bzl
@@ -25,7 +25,7 @@
"""Bazel support functions related to CMake support."""
-def staleness_test(name, outs, generated_pattern, target_files = None, **kwargs):
+def staleness_test(name, outs, generated_pattern, target_files = None, tags = [], **kwargs):
"""Tests that checked-in file(s) match the contents of generated file(s).
The resulting test will verify that all output files exist and have the
@@ -72,5 +72,6 @@ def staleness_test(name, outs, generated_pattern, target_files = None, **kwargs)
deps = [
Label("//cmake:staleness_test_lib"),
],
+ tags = ["staleness_test"] + tags,
**kwargs
)

@ -1,64 +0,0 @@
#!/bin/bash
set -ex
if [[ -z "${CONTAINER_IMAGE}" ]]; then
CONTAINER_IMAGE=us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-aec4d74f2eb6938fc53ef7d9a79a4bf2da24abc1
fi
cd $(dirname $0)/../..
GIT_REPO_ROOT=`pwd`
ENVS=()
# Check for specific versions pinned to the docker image. In these cases we
# want to forward the environment variable to tests, so that they can verify
# that the correct version is being picked up by Bazel.
ENVS+=("--test_env=KOKORO_JAVA_VERSION")
ENVS+=("--test_env=KOKORO_PYTHON_VERSION")
ENVS+=("--test_env=KOKORO_RUBY_VERSION")
if [ -n "$BAZEL_ENV" ]; then
for env in $BAZEL_ENV; do
ENVS+="--action_env=${env}"
done
fi
# Setup GAR for docker images.
gcloud components update --quiet
gcloud auth configure-docker us-docker.pkg.dev --quiet
function run {
local CONFIG=$1
local BAZEL_CONFIG=$2
tmpfile=$(mktemp -u)
rm -rf $GIT_REPO_ROOT/bazel-out $GIT_REPO_ROOT/bazel-bin
rm -rf $GIT_REPO_ROOT/logs
docker run \
--cidfile $tmpfile \
--cap-add=SYS_PTRACE \
-v $GIT_REPO_ROOT:/workspace \
$CONTAINER_IMAGE \
test \
$(${GIT_REPO_ROOT}/kokoro/common/bazel_flags.sh) \
${ENVS[@]} \
$PLATFORM_CONFIG \
$BAZEL_CONFIG \
$BAZEL_EXTRA_FLAGS \
$BAZEL_TARGETS
# Save logs for Kokoro
docker cp \
`cat $tmpfile`:/workspace/logs $KOKORO_ARTIFACTS_DIR/$CONFIG
}
if [ -n "$BAZEL_CONFIGS" ]; then
for config in $BAZEL_CONFIGS; do
run $config "--config=$config"
done
else
run
fi

@ -1,18 +0,0 @@
# We run our staleness tests as release-type jobs only. They are not really
# part of the release process, but the release job type allows us to run the
# tests on a schedule only (not presubmit or postsubmit).
# Location of the build script in repository
build_file: "protobuf/kokoro/linux/bazel.sh"
timeout_mins: 15
env_vars {
key: "BAZEL_TARGETS"
value: "//src:cmake_lists_staleness_test"
}
action {
define_artifacts {
regex: "**/sponge_log.*"
}
}
Loading…
Cancel
Save