ci(gha): Tune Tox workflow 47/43747/2
authorPeter Mikus <[email protected]>
Thu, 25 Sep 2025 05:42:59 +0000 (07:42 +0200)
committerPeter Mikus <[email protected]>
Thu, 25 Sep 2025 05:46:41 +0000 (05:46 +0000)
Signed-off-by: Peter Mikus <[email protected]>
Change-Id: Ifc98ad7811b1ea254219cd2f7bd334c9e3ebba69

.ci/setup_executor_env.sh [deleted file]
.github/actions/setup_executor_env/README.md [new file with mode: 0644]
.github/actions/setup_executor_env/action.yml [new file with mode: 0644]
.github/workflows/gerrit-csit-tox-verify.yml

diff --git a/.ci/setup_executor_env.sh b/.ci/setup_executor_env.sh
deleted file mode 100755 (executable)
index ba29381..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-#!/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)
-: "${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)"
-}
-
-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
-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."
diff --git a/.github/actions/setup_executor_env/README.md b/.github/actions/setup_executor_env/README.md
new file mode 100644 (file)
index 0000000..77da6bc
--- /dev/null
@@ -0,0 +1,24 @@
+# 🛠️ Setup Executor Environment
+
+Action to setup FD.io Nomad executor environment inside a GitHub action/workflow
+
+## setup_executor_env
+
+## Usage Example
+
+```yaml
+- name: "Setup Environment"
+  uses: fdio/csit/.github/actions/setup_executor_env@master
+```
+
+<!-- markdownlint-enable MD013 -->
+
+## Outputs
+
+The action has no outputs, but does provide summary step information when
+invoked.
+
+## Requirements/Dependencies
+
+The git command-line tool must be available in the environment for the action
+to succeed.
\ No newline at end of file
diff --git a/.github/actions/setup_executor_env/action.yml b/.github/actions/setup_executor_env/action.yml
new file mode 100644 (file)
index 0000000..7b8d526
--- /dev/null
@@ -0,0 +1,94 @@
+---
+name: "🛠️ Setup Executor Environment"
+description: |
+  This GitHub Action prepares FD.io executor environment.
+
+runs:
+  using: "composite"
+  steps:
+    - name: "GitHub Runner Attributes"
+      id: attributes
+      shell: bash
+      run: |
+        . /etc/os-release
+        OS_ARCH=$(uname -m)
+
+        echo "OS: ${ID:-unknown}-${VERSION_ID:-unknown}"
+        echo "Arch: ${OS_ARCH}"
+        echo "GitHub Runner: ${RUNNER_NAME:-Unknown}"
+        echo "GitHub Workflow: ${GITHUB_WORKFLOW:-Unknown}"
+        echo "GitHub Run ID: ${GITHUB_RUN_ID:-Unknown}"
+        echo "Runner Hostname: $(hostname)"
+
+    - name: "GitHub Actions Environment"
+      id: environment
+      shell: bash
+      run: |
+        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}"
+
+    - name: "Show Python Packages"
+      id: python_packages
+      shell: bash
+      run: |
+        pip3 list 2>/dev/null | column -t || true
+
+    - name: "Show OS Packages"
+      id: os_packages
+      shell: bash
+      run: |
+        . /etc/os-release
+
+        if [ "${ID}" = "ubuntu" ] || [ "${ID}" = "debian" ]; then
+          dpkg-query -W -f='${binary:Package}\t${Version}\n' | column -t || true
+        elif [ "${ID}" = "centos" ]; then
+          yum list installed || true
+        else
+          echo "Unsupported OS for package listing"
+        fi
+
+    - name: "Setup ccache"
+      id: ccache_packages
+      shell: bash
+      run: |
+        . /etc/os-release
+        OS_ARCH=$(uname -m)
+        downloads_cache="/root/Downloads"
+
+        # Toggle envs (can be overridden from workflow)
+        : "${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
+
+        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/${ID}-${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
+
+        downloads_cache="${GITHUB_WORKSPACE:-/github/workspace}/.cache"
+        mkdir -p "${downloads_cache}" 2>/dev/null || true
\ No newline at end of file
index d8970f5..b89deaf 100644 (file)
@@ -41,6 +41,11 @@ on:
         description: "Gerrit refspec of change"
         required: true
         type: string
+      TARGET_REPO:
+        # yamllint disable-line rule:line-length
+        description: "The target GitHub repository needing the required workflow"
+        required: true
+        type: string
 
 concurrency:
   # yamllint disable-line rule:line-length
@@ -79,11 +84,16 @@ jobs:
           ref: refs/heads/${{ github.event.inputs.GERRIT_BRANCH }}
 
       - name: Setup Environment
-        run: |
-          ls -al .ci
-          .ci/setup_executor_env.sh
+        uses: fdio/csit/.github/actions/setup_executor_env@master
 
       - name: Run tox
         run: |
-          set -exuo pipefail
           source ./resources/libraries/bash/entry/tox.sh
+
+      - name: Archive Logs
+        if: always()
+        uses: actions/upload-artifact@v4
+        with:
+          name: ${{ github.job }}-${{ matrix.os }}-${{ matrix.executor_arch }}-logs
+          path: archives/
+          if-no-files-found: "ignore"
\ No newline at end of file