Skip to content

Initial github actions for automated build & security scans #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/actions/setup-tools/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Setup Tools'
description: 'Sets up required tools'

inputs:
go:
description: "Run setup-go action if true"
required: false
default: "true"
trivy:
description: "Install Trivy if true"
required: false
default: "true"

runs:
using: "composite"
steps:
- name: Setup Go
if: "${{ inputs.go == 'true' }}"
uses: actions/setup-go@v5

- name: Install Trivy
if: "${{ inputs.trivy == 'true' }}"
shell: bash
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin

- name: Set EDV_VERSION to the current git version for this actions run
shell: bash
run: |
# Print the most recent commit
echo "Most recent commit:"
git log -1

if [[ $(git log | grep commit | wc -l) -lt 10 ]]; then
echo "Commit history is squashed, EDV_VERSION will be wrong. Calling action should checkout code with fetch-depth:0"
exit 1
fi

# Version based on commits since the most recent tag
# If the current commit is a tag, use that tag
# If not, use <most recent tag>-<num commits since tag>-<short commit hash>
# i.e. v1-11-gdc6c0bd
EDV_VERSION="$(git describe --tags --always)"

echo "EDV_VERSION=$EDV_VERSION"
echo "EDV_VERSION=$EDV_VERSION" >> $GITHUB_ENV

- name: Set EDV_HOME to the checked-out edge-desktop-virtualization source code
shell: bash
run: |
echo "EDV_HOME=$(pwd)" >> $GITHUB_ENV
129 changes: 129 additions & 0 deletions .github/workflows/device_plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: "Device Plugin: Build, Trivy & ClamAV Scan"
run-name: "Workflow (by @${{ github.actor }} via ${{ github.event_name }})"

# Only run at most 1 workflow concurrently per PR, unlimited for branches
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- "*"

jobs:
device-plugins-for-kubernetes:
permissions:
contents: read
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0 # All history, not just latest commit
ref: ${{ github.event.pull_request.head.sha }} # Check out the actual commit, not a fake merge commit

- name: Setup Tools & Common Variables
uses: ./.github/actions/setup-tools

- name: Build the device plugin and docker image
working-directory: device-plugins-for-kubernetes
run: |
./build.sh --ver "$EDV_VERSION" --repo "localhost:5000"

- name: Build device plugin release tarball
working-directory: device-plugins-for-kubernetes
run: |
mkdir device-plugin-artifacts
cd device-plugin-artifacts

docker image pull busybox:latest
docker image tag busybox:latest localhost:5000/busybox:latest
docker image save -o busybox.tar localhost:5000/busybox:latest

docker image save -o device-plugin.tar "localhost:5000/mf-device-plugin:$EDV_VERSION"

cp -a ../deploy/manifests/maverikflats-device-plugin.yaml device-plugin.yaml

tar czf intel-idv-device-plugin-$EDV_VERSION.tar.gz busybox.tar device-plugin.tar device-plugin.yaml

ls -hal

- name: Upload device plugin release tarball
uses: actions/upload-artifact@v4
with:
name: device-plugin artifacts
path: |
device-plugins-for-kubernetes/device-plugin-artifacts/intel-idv-device-plugin-${{ env.EDV_VERSION }}.tar.gz

- name: trivy repo scan
shell: bash
working-directory: device-plugins-for-kubernetes
run: |
trivy --version
which trivy
trivy image --download-db-only
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl

# Use the downloaded template
trivy fs . --format template --template "@trivy-html.tpl" -o "trivy_code_scan_core.html"

- name: Upload trivy reports
uses: actions/upload-artifact@v4
with:
name: trivy-code-scan-results-core
path: |
device-plugins-for-kubernetes/trivy_code_scan_core.html

- name: Trivy Image Scan
continue-on-error: true
shell: bash
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
trivy image "localhost:5000/mf-device-plugin:$EDV_VERSION" --ignore-unfixed --format template --template "@trivy-html.tpl" -o device-plugins-for-kubernetes/trivy_image_scan_core-backend.html
trivy image --quiet --format spdx-json --output device-plugins-for-kubernetes/trivy_image_scan_core-backend.spdx.json "localhost:5000/mf-device-plugin:$EDV_VERSION"

- name: Upload Trivy Image Report
uses: actions/upload-artifact@v4
with:
name: Trivy image scan report-core
path: |
device-plugins-for-kubernetes/trivy_image_scan_core-backend.html
device-plugins-for-kubernetes/trivy_image_scan_core-backend.spdx.json

- name: ClamAV Antivirus Scan
continue-on-error: true
shell: bash
run: |
echo "Starting ClamAV scan on device-plugins-for-kubernetes/..."

docker run --rm \
--mount type=bind,source=./device-plugins-for-kubernetes/,target=/scandir \
clamav/clamav:stable \
clamscan --recursive --log=/scandir/clamav-scan-report.log \
/scandir

SCAN_EXIT_CODE=$?
sudo chown $USER:$USER device-plugins-for-kubernetes/clamav-scan-report.log 2>/dev/null || true

if [ $SCAN_EXIT_CODE -ne 0 ]; then
echo "ClamAV scan failed or found issues"
exit 1
fi

- name: Upload Antivirus Report
if: always()
uses: actions/upload-artifact@v4
with:
name: antivirus-report-core
path: device-plugins-for-kubernetes/clamav-scan-report.log
105 changes: 105 additions & 0 deletions .github/workflows/device_plugin_coverity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: "Device Plugin: Coverity Scan"
run-name: "Workflow (by @${{ github.actor }} via ${{ github.event_name }})"

on:
# Allow this to also be manually scheduled against a specific branch
workflow_dispatch:
inputs:
branch:
description: 'Branch to run on'
required: true
default: 'main'
schedule:
# Run at 01:35 UTC every day
# Chosen arbitrarily and could be moved - 01:30 UTC is generally after workday ends in US and before it starts in India
- cron: "35 1 * * *"
push:
tags:
- "*"

permissions: read-all

jobs:
coverity:
name: Coverity

runs-on: ubuntu-24.04
defaults:
run:
shell: bash -noprofile --norc -eo pipefail {0}

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0 # All history, not just latest commit
ref: ${{ github.event.pull_request.head.sha }} # Check out the actual commit, not a fake merge commit

- name: Setup Tools & Common Variables
uses: ./.github/actions/setup-tools

- name: Load coverity from cache
id: cache-coverity
uses: actions/cache@v4
env:
cache-name: cache-coverity
with:
path: $HOME/coverity
# Update coverity each month
key: coverity-$(date +%Y%m)

- name: Debug COVERITY_TOKEN
run: |
if [ -z "$COVERITY_TOKEN" ]; then
echo "COVERITY_TOKEN is not set"
exit 1
else
echo "COVERITY_TOKEN is set"
fi
env:
COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }}

- name: Download coverity
if: ${{ steps.cache-coverity.outputs.cache-hit != 'true' }}
env:
COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }}
run: |
cd $HOME
wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_TOKEN&project=open-edge-platform%2Fedge-desktop-virtualization" -O coverity.tgz
tar zxf coverity.tgz
mv -T cov-analysis-linux64-* coverity

- name: Add coverity to PATH
run: |
echo "$HOME/coverity/bin" >> $GITHUB_PATH

- name: Show coverity version
run: |
coverity --version

- name: Run coverity build
working-directory: device-plugins-for-kubernetes
run: |
cov-build --dir $HOME/cov-int ./build.sh --ver "$EDV_VERSION" --repo "localhost"

- name: Create coverity results tarball
run: |
cd $HOME
tail cov-int/build-log.txt
tar zcf cov-int.tgz cov-int

- name: Create coverity build
env:
COVERITY_TOKEN: ${{ secrets.COVERITY_TOKEN }}
run: |
cd $HOME
ls -hal cov-int.tgz
echo "NOTE: If size above is > 500 MB, this will fail and need to be restructured to use the more advanced coverity API"

curl --form token=$COVERITY_TOKEN \
--form email=byron.marohn@intel.com \
--form file=@cov-int.tgz \
--form version="$EDV_VERSION" \
--form description="Coverity build for edge-desktop-virtualization@$EDV_VERSION" \
https://scan.coverity.com/builds?project=open-edge-platform%2Fedge-desktop-virtualization
Loading
Loading