Skip to content

feat(agent): Add flag to not write logs to disk and fix issue with cleaning up old log files #157

feat(agent): Add flag to not write logs to disk and fix issue with cleaning up old log files

feat(agent): Add flag to not write logs to disk and fix issue with cleaning up old log files #157

Workflow file for this run

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
#
# 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.
name: Agent CI
on:
pull_request:
branches:
- main
paths:
- agent/**
- containers/agent.Dockerfile
- .github/workflows/agent-ci.yaml
push:
branches:
- main
tags:
- agent/*
paths:
- agent/**
- containers/agent.Dockerfile
- .github/workflows/agent-ci.yaml
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
compute-metadata:
name: Compute Image Metadata
runs-on: ubuntu-latest
outputs:
git-sha: ${{ steps.meta.outputs.git-sha }}
agent-version: ${{ steps.meta.outputs.agent-version }}
agent-image-tag: ${{ steps.meta.outputs.agent-image-tag }}
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch all tags
run: git fetch --tags --force
- name: Compute metadata
id: meta
run: |
export GIT_SHA=$(git rev-parse --short ${{ github.sha }})
echo "git-sha=${GIT_SHA}" >> $GITHUB_OUTPUT
case ${{ github.ref_type }} in
branch)
# The last tag + current git sha
export AGENT_VERSION=$(git tag --list 'agent*' --sort=-v:refname | head -n 1 | cut -d/ -f2)+${GIT_SHA}
# Convert + to - for docker tag compliance
export AGENT_IMAGE_TAG=$(echo "${AGENT_VERSION}" | tr + -)
TAGS="-t ${REGISTRY@L}/${{ github.repository }}/agent:${GIT_SHA} -t ${REGISTRY@L}/${{ github.repository }}/agent:${AGENT_IMAGE_TAG}"
;;
tag)
# The version part of the tag
export AGENT_VERSION=$(echo "${{ github.ref_name }}" | cut -f 2 -d /)
export AGENT_IMAGE_TAG="${AGENT_VERSION}"
TAGS="-t ${REGISTRY@L}/${{ github.repository }}/agent:${GIT_SHA} -t ${REGISTRY@L}/${{ github.repository }}/agent:${AGENT_VERSION} -t ${REGISTRY@L}/${{ github.repository }}/agent:latest"
;;
*)
echo "Unknown type ${{ github.ref_type }}"
exit 1
;;
esac
echo "agent-version=${AGENT_VERSION}" >> $GITHUB_OUTPUT
echo "agent-image-tag=${AGENT_IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "📦 Agent Version: ${AGENT_VERSION}"
echo "🏷️ Image Tag: ${AGENT_IMAGE_TAG}"
echo "🏷️ All Tags: ${TAGS}"
test:
name: Skyhook Agent Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Run unittests
run: |
cd agent
make test
- name: Generate Summary
uses: test-summary/action@v2
if: always()
with:
paths: "agent/skyhook-agent/test-results.xml"
output: test-summary.md
- name: Display Summary
if: always()
run: |
cat test-summary.md >> $GITHUB_STEP_SUMMARY
build-and-push-agent:
runs-on: ubuntu-latest
needs: [test, compute-metadata] # Don't run the build and push if the unit tests fail
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch all tags
run: git fetch --tags --force
# Uses the `docker/login-action` action to log in to the Container registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Setup for multi-platform
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build the agent container image
id: build
env:
GIT_SHA: ${{ needs.compute-metadata.outputs.git-sha }}
AGENT_VERSION: ${{ needs.compute-metadata.outputs.agent-version }}
TAGS: ${{ needs.compute-metadata.outputs.tags }}
run: |
apt-get update && apt-get install -y make git jq
cd agent
echo "📦 Building agent version: ${AGENT_VERSION}"
echo "🏷️ Tags: ${TAGS}"
export REGISTRY=${REGISTRY@L}
export BUILD_ARGS="--push"
make docker-build-only agent_version=${AGENT_VERSION}
cat metadata.json
echo "digest=$(cat metadata.json | jq -r .\"containerimage.digest\")" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{env.IMAGE_NAME}}/agent
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true
operator-agent-tests:
name: Operator Agent Integration Tests
runs-on: ubuntu-latest
needs: [compute-metadata, build-and-push-agent]
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.5'
cache-dependency-path: operator/go.sum
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create Kubernetes KinD Cluster
uses: helm/kind-action@v1
with:
version: v0.31.0
node_image: kindest/node:v1.35.0
config: operator/config/local-dev/kind-config.yaml
cluster_name: kind
- name: Restore cached Binaries
id: cached-binaries
uses: actions/cache/restore@v4
with:
key: 1.25.5-${{ runner.os }}-${{ runner.arch }}-bin-${{ hashFiles('operator/deps.mk') }}
restore-keys: 1.25.5-${{ runner.os }}-${{ runner.arch }}-bin-
path: |
${{ github.workspace }}/operator/bin
~/.cache/go-build
- name: Install dependencies
if: steps.cached-binaries.outputs.cache-hit != 'true'
run: |
cd operator
make install-deps
- name: Save cached Binaries
if: steps.cached-binaries.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: 1.25.5-${{ runner.os }}-${{ runner.arch }}-bin-${{ hashFiles('operator/deps.mk') }}
path: |
${{ github.workspace }}/operator/bin
~/.cache/go-build
- name: Run operator-agent tests
env:
AGENT_IMAGE: ${{ format('{0}/{1}/agent:{2}', env.REGISTRY, github.repository, needs.compute-metadata.outputs.agent-image-tag) }}
run: |
cd operator
export AGENT_IMAGE="${AGENT_IMAGE,,}"
echo "Testing with agent image: ${AGENT_IMAGE}"
make build-cli
make setup-kind-cluster operator-agent-tests