feat(gha): Test 22/43722/1
authorPeter Mikus <[email protected]>
Fri, 19 Sep 2025 04:25:12 +0000 (06:25 +0200)
committerPeter Mikus <[email protected]>
Fri, 19 Sep 2025 04:25:12 +0000 (06:25 +0200)
Signed-off-by: Peter Mikus <[email protected]>
Change-Id: I282582a106239a5a76fb2ba5ddd2b2f30a729e72

.github/scripts/setup_executor_env.sh [new file with mode: 0755]
.github/workflows/gerrit-csit-tox-verify.yml

diff --git a/.github/scripts/setup_executor_env.sh b/.github/scripts/setup_executor_env.sh
new file mode 100755 (executable)
index 0000000..649a50b
--- /dev/null
@@ -0,0 +1,182 @@
+#!/bin/bash
+
+# Copyright (c) 2025 Cisco and/or its affiliates.
+# 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.
+
+# Strict mode
+set -euo pipefail
+IFS=$' \t\n'
+
+trap 'ec=$?; echo "[ERROR] setup_executor_env.sh failed at line $LINENO with exit code $ec" >&2' ERR
+
+# Load OS metadata
+if [ -r /etc/os-release ]; then
+  # shellcheck disable=SC1091
+  . /etc/os-release
+  OS_ID="${ID:-unknown}"
+  OS_VERSION_ID="${VERSION_ID:-unknown}"
+else
+  OS_ID="unknown"
+  OS_VERSION_ID="unknown"
+fi
+OS_ARCH=$(uname -m)
+
+file_delimiter="----- %< -----"
+long_line="************************************************************************"
+# Original downloads cache (may be ephemeral inside container)
+downloads_cache="/root/Downloads"
+
+GITHUB_RUNNER="${RUNNER_NAME:-Unknown}"
+GITHUB_WORKFLOW="${GITHUB_WORKFLOW:-Unknown}"
+GITHUB_RUN_ID="${GITHUB_RUN_ID:-Unknown}"
+
+# Toggle envs (can be overridden from workflow)
+: "${PERF_PROBE:=1}"            # 1 to collect perf snapshots
+: "${VERBOSE_PACKAGES:=1}"      # 1 to list installed OS packages
+: "${VERBOSE_PY:=1}"            # 1 to list python packages
+: "${CCACHE_MAXSIZE:=20G}"      # Max ccache size
+: "${CCACHE_COMPILERCHECK:=content}" # Safer compiler change detection
+
+log_line() { echo "$long_line"; }
+
+print_runner_attrs() {
+  log_line
+  echo "GitHub Runner Attributes:"
+  echo "OS: ${OS_ID}-${OS_VERSION_ID}"
+  echo "Arch: ${OS_ARCH}"
+  echo "GitHub Runner: ${GITHUB_RUNNER}"
+  echo "GitHub Workflow: ${GITHUB_WORKFLOW}"
+  echo "GitHub Run ID: ${GITHUB_RUN_ID}"
+  echo "Runner Hostname: $(hostname)"
+}
+
+collect_perf_snapshots() {
+  [ "${PERF_PROBE}" = "1" ] || { echo "PERF_PROBE disabled"; return 0; }
+  log_line
+  echo "Collecting lightweight performance snapshots"
+  perf_trials=2
+  perf_interval=1
+  # Determine SYSSTAT path (retain legacy logic)
+  if [ "${OS_ID}" = "ubuntu" ] || [ "${OS_ID}" = "debian" ]; then
+    SYSSTAT_PATH="/var/log/sysstat"
+  elif [ "${OS_ID}" = "centos" ]; then
+    if [ "${OS_VERSION_ID}" = "7" ]; then
+      SYSSTAT_PATH="/var/log/sa/sa02"
+    else
+      SYSSTAT_PATH="/var/log/sa"
+    fi
+  else
+    SYSSTAT_PATH="/var/log"
+  fi
+  echo "Virtual memory stat"; vmstat ${perf_interval} ${perf_trials} 2>/dev/null || echo "vmstat not available"
+  echo "CPU time breakdowns per CPU"; mpstat -P ALL ${perf_interval} ${perf_trials} 2>/dev/null || echo "mpstat not available"
+  echo "Per-process summary"; pidstat ${perf_interval} ${perf_trials} 2>/dev/null || echo "pidstat not available"
+  echo "Block device stats"; iostat -xz ${perf_interval} ${perf_trials} 2>/dev/null || echo "iostat not available"
+  echo "Memory utilization"; free -m 2>/dev/null || echo "free not available"
+  echo "Network interface throughput"; sar -n DEV -o "${SYSSTAT_PATH}" ${perf_interval} ${perf_trials} 2>/dev/null || echo "sar not available"
+  echo "TCP metrics"; sar -n TCP,ETCP -o "${SYSSTAT_PATH}" ${perf_interval} ${perf_trials} 2>/dev/null || echo "sar not available"
+}
+
+show_os_packages() {
+  [ "${VERBOSE_PACKAGES}" = "1" ] || { echo "Skipping OS package list (VERBOSE_PACKAGES=0)"; return 0; }
+  log_line
+  echo "Executor package list:"
+  if [ "${OS_ID}" = "ubuntu" ] || [ "${OS_ID}" = "debian" ]; then
+    dpkg-query -W -f='${binary:Package}\t${Version}\n' | column -t || true
+  elif [ "${OS_ID}" = "centos" ]; then
+    yum list installed || true
+  else
+    echo "Unsupported OS for package listing"
+  fi
+}
+
+show_python_packages() {
+  [ "${VERBOSE_PY}" = "1" ] || { echo "Skipping Python package list (VERBOSE_PY=0)"; return 0; }
+  log_line
+  echo "Python3 package list:"
+  pip3 list 2>/dev/null | column -t || true
+}
+
+show_downloads_cache() {
+  log_line
+  echo "Executor Downloads cache '${downloads_cache}':"
+  ls -lh "${downloads_cache}" || true
+}
+
+show_resolver() {
+  log_line
+  echo "DNS nameserver config in '/etc/resolv.conf':"
+  # Mask potential search domains if needed; currently print full
+  cat /etc/resolv.conf || true
+}
+
+setup_ccache() {
+  log_line
+  if command -v ccache >/dev/null 2>&1; then
+    # Ensure CCACHE_DIR is set and exists
+    if [ -z "${CCACHE_DIR:-}" ]; then
+      # Derive a default if not provided (caller may pass one via env)
+      CCACHE_DIR="/scratch/ccache/${OS_ID}-${OS_VERSION_ID}-${OS_ARCH}"
+      export CCACHE_DIR
+    fi
+    if [ ! -d "${CCACHE_DIR}" ]; then
+      echo "Creating CCACHE_DIR='${CCACHE_DIR}'"
+      if ! mkdir -p "${CCACHE_DIR}" 2>/dev/null; then
+        echo "Failed to create CCACHE_DIR; disabling ccache"
+        export CCACHE_DISABLE=1
+      fi
+    fi
+    if [ -z "${CCACHE_DISABLE:-}" ]; then
+      export CCACHE_MAXSIZE CCACHE_COMPILERCHECK
+      echo "ccache enabled: dir='${CCACHE_DIR}' max='${CCACHE_MAXSIZE}' compilercheck='${CCACHE_COMPILERCHECK}'"
+      echo "Initial ccache stats:"; ccache -s || true
+    else
+      echo "ccache explicitly disabled (CCACHE_DISABLE='${CCACHE_DISABLE}')"
+    fi
+  else
+    echo "WARNING: ccache is not installed (will proceed without caching)"
+    export CCACHE_DISABLE=1
+  fi
+}
+
+prepare_workspace_cache() {
+  # Update cache directory for GitHub Actions (for other tooling reuse)
+  downloads_cache="${GITHUB_WORKSPACE:-/github/workspace}/.cache"
+  mkdir -p "${downloads_cache}" 2>/dev/null || true
+  log_line
+}
+
+show_github_env() {
+  log_line
+  echo "GitHub Actions Environment:"
+  echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE:-Not set}"
+  echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY:-Not set}"
+  echo "GITHUB_REF: ${GITHUB_REF:-Not set}"
+  echo "GITHUB_SHA: ${GITHUB_SHA:-Not set}"
+  echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME:-Not set}"
+  log_line
+}
+
+# Execution sequence
+print_runner_attrs
+collect_perf_snapshots
+show_os_packages
+show_python_packages
+show_downloads_cache
+show_resolver
+setup_ccache
+prepare_workspace_cache
+show_github_env
+
+# Success footer
+echo "Executor environment setup complete."
index 2ee881f..bf81aff 100644 (file)
@@ -1,3 +1,4 @@
+---
 name: CSIT Tox
 
 # yamllint disable-line rule:truthy
@@ -69,6 +70,21 @@ jobs:
         builder_type: [prod]
 
     steps:
+      - name: Clear votes
+        uses: lfit/[email protected]
+        with:
+          host: ${{ vars.GERRIT_SERVER }}
+          username: ${{ vars.GERRIT_SSH_REQUIRED_USER }}
+          key: ${{ secrets.GERRIT_SSH_REQUIRED_PRIVKEY }}
+          known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
+          gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
+          gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
+          vote-type: clear
+          comment-only: true
+
+      - name: Allow replication
+        run: sleep 10s
+
       - name: Gerrit Checkout
         # yamllint disable-line rule:line-length
         uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
@@ -82,10 +98,9 @@ jobs:
 
       - name: Setup Environment
         run: |
-          .ci/scripts/vpp/setup_executor_env.sh
+          .github/scripts/setup_executor_env.sh
 
       - name: Run tox
-        shell: bash
         run: |
           set -exuo pipefail
           source ./resources/libraries/bash/entry/tox.sh
\ No newline at end of file