Skip to content
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
58 changes: 58 additions & 0 deletions .github/workflows/ci-dispatcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI Dispatcher

on:
push:
branches: [ "main", "release", "debug" ]
pull_request:
branches: [ "refactoring","main", "release", "debug" ]
workflow_dispatch:

jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
rust_changed: ${{ steps.filter.outputs.rust }}
doc_changed: ${{ steps.filter.outputs.docs }}
yaml_changed: ${{ steps.filter.outputs.yaml }}
steps:
- uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
filters: |
rust:
- '**/*.rs'
- '**/*.toml'
- 'Cargo.lock'
- 'scripts/**'
docs:
- '**/*.md'
yaml:
- '.github/workflows/*.yml'

run-rust-ci:
needs: detect-changes
if: needs.detect-changes.outputs.rust_changed == 'true'
uses: ./.github/workflows/run-ci.yml

run-doc-lint:
needs: detect-changes
if: needs.detect-changes.outputs.doc_changed == 'true'
uses: ./.github/workflows/run-doc.yml

run-yaml-validation:
needs: detect-changes
if: needs.detect-changes.outputs.yaml_changed == 'true'
uses: ./.github/workflows/run-validate.yml

# Final job for branch protection
ci-summary:
name: CI Complete Summary
runs-on: ubuntu-latest
if: always()
needs:
- run-rust-ci
- run-doc-lint
- run-yaml-validation
steps:
- run: echo "All CI jobs (if triggered) have completed."
25 changes: 25 additions & 0 deletions .github/workflows/run-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Rust CI Core

on:
workflow_call:
workflow_dispatch:

jobs:
rust_ci:
runs-on: ubuntu-latest
container:
image: rust:latest
steps:
- uses: actions/checkout@v4
- name: Install deps
run: ./scripts/installdeps.sh
- name: Build
run: ./scripts/buildNparse.sh
- name: Test
run: ./scripts/testNparse.sh
- name: Lint
run: ./scripts/clippy_check.sh
- name: Format
run: ./scripts/fmt_check.sh
- name: Cargo Deny (License, Advisories, Bans)
run: ./scripts/deny_check.sh
18 changes: 18 additions & 0 deletions .github/workflows/run-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Doc CI

on:
workflow_call:
workflow_dispatch:

jobs:
doc_lint:
runs-on: ubuntu-latest
container:
image: rust:latest
steps:
- uses: actions/checkout@v4
# - name: Install markdownlint
# run: npm install -g markdownlint-cli
# - name: Lint docs
# run: markdownlint '**/*.md'
# test check
16 changes: 16 additions & 0 deletions .github/workflows/run-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Validate Workflow YAML

on:
workflow_call:
workflow_dispatch:

jobs:
validate_yaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate workflows
run: |
for file in .github/workflows/*.yml; do
yq eval '.' "$file" > /dev/null
done
38 changes: 38 additions & 0 deletions scripts/buildNparse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -euo pipefail

LOG_FILE="build_results.log"
TMP_FILE="build_output.txt"
rm -f "$LOG_FILE" "$TMP_FILE"

echo "Running Cargo Build..." | tee -a "$LOG_FILE"

PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")
git config --global --add safe.directory "$PROJECT_ROOT"
cd "$PROJECT_ROOT"

MANIFESTS=(
src/common/Cargo.toml
src/agent/Cargo.toml
src/player/Cargo.toml
src/server/Cargo.toml
src/tools/Cargo.toml
)

FAILED_TOTAL=0

for manifest in "${MANIFESTS[@]}"; do
echo "πŸ“¦ Building $manifest..." | tee -a "$LOG_FILE"
if cargo build -vv --manifest-path="$manifest" | tee "$TMP_FILE"; then
echo "βœ… Build succeeded for $manifest" | tee -a "$LOG_FILE"
else
echo "::error ::Build failed for $manifest!" | tee -a "$LOG_FILE"
FAILED_TOTAL=$((FAILED_TOTAL + 1))
fi
done

if [[ "$FAILED_TOTAL" -gt 0 ]]; then
echo "::error ::Build failed! $FAILED_TOTAL component(s) failed." | tee -a "$LOG_FILE"
exit 1
fi
22 changes: 22 additions & 0 deletions scripts/buildNpushdocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

LOG_FILE="dockerbuild_results.log"

echo "Running Docker Build..." | tee -a $LOG_FILE

#git config --global --add safe.directory /__w/PICCOLO/PICCOLO
git_hash=$(git rev-parse --short "$GITHUB_SHA")
git_branch=${GITHUB_REF#refs/heads/}
docker build -t sdv.lge.com/demo/${git_branch}/piccolo:${git_hash} -f containers/Dockerfile . | tee -a $LOG_FILE
# Is tagging required?
# docker tag sdv.lge.com/demo/${git_branch}/piccolo:${git_hash} sdv.lge.com/demo/${git_branch}/piccolo:latest | tee -a $LOG_FILE
docker push sdv.lge.com/demo/${git_branch}/piccolo:${git_hash} | tee -a $LOG_FILE

if [[ "$FAILED" -gt 0 ]]; then
echo "::error ::Docker build and push failed! Check logs." | tee -a $LOG_FILE
exit 1
fi

echo "Docker pushed successfully!" | tee -a $LOG_FILE
96 changes: 96 additions & 0 deletions scripts/clippy_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash
set -euo pipefail

LOG_FILE="clippy_results.log"
TMP_FILE="clippy_output.txt"
REPORT_FILE="clippy_summary.md"

rm -f "$LOG_FILE" "$TMP_FILE" "$REPORT_FILE"

echo "Running Cargo clippy..." | tee -a "$LOG_FILE"

PROJECT_ROOT=${GITHUB_WORKSPACE:-$(pwd)}
cd "$PROJECT_ROOT"

FAILED_TOTAL=0
PASSED_TOTAL=0
PIDS=()

# Declare manifest paths
COMMON_MANIFEST="src/common/Cargo.toml"
AGENT_MANIFEST="src/agent/Cargo.toml"
TOOLS_MANIFEST="src/tools/Cargo.toml"
APISERVER_MANIFEST="src/server/apiserver/Cargo.toml"
FILTERGATEWAY_MANIFEST="src/player/filtergateway/Cargo.toml"
ACTIONCONTROLLER_MANIFEST="src/player/actioncontroller/Cargo.toml"

# Run and parse test output
run_clippy() {
local manifest="$1"
local label="$2"
local clippy_passed=false

echo "Running Clippy for $label ($manifest)" | tee -a "$LOG_FILE"

if cargo clippy --manifest-path="$manifest" --all-targets --all-features | tee "$TMP_FILE"; then
echo "Clippy for $label passed clean." | tee -a "$LOG_FILE"
clippy_passed=true
else
echo "::error ::Clippy for $label failed! Found warnings/errors. Check logs." | tee -a "$LOG_FILE"
# Capture relevant lines from TMP_FILE if needed for summary, or direct stdout/stderr
# Example: Print only the warnings/errors to log, not the whole verbose output
# grep -E "warning:|error:" "$TMP_FILE" | tee -a "$LOG_FILE"
fi

# Instead of PASSED_TOTAL/FAILED_TOTAL for *lints*, we track job success/failure
if $clippy_passed; then
echo "βœ… Clippy for $label: PASSED" >> "$REPORT_FILE"
else
echo "❌ Clippy for $label: FAILED" >> "$REPORT_FILE"
# Increment a counter for overall script failure
(( FAILED_TOTAL++ )) # FAILED_TOTAL now represents number of manifests that failed clippy
fi
}

# Run common clippy checks
if [[ -f "$COMMON_MANIFEST" ]]; then
run_clippy "$COMMON_MANIFEST" "common"
else
echo "::warning ::$COMMON_MANIFEST not found, skipping..."
fi

# # Run apiserver clippy checks
if [[ -f "$APISERVER_MANIFEST" ]]; then
run_clippy "$APISERVER_MANIFEST" "apiserver"
else
echo "::warning ::$APISERVER_MANIFEST not found, skipping..."
fi

# Run tools clippy checks
if [[ -f "$TOOLS_MANIFEST" ]]; then
run_clippy "$TOOLS_MANIFEST" "tools"
else
echo "::warning ::$TOOLS_MANIFEST not found, skipping..."
fi

# Run agent clippy checks
if [[ -f "$AGENT_MANIFEST" ]]; then
run_clippy "$AGENT_MANIFEST" "agent"
else
echo "::warning ::$AGENT_MANIFEST not found, skipping..."
fi

# Run filtergateway clippy checks
if [[ -f "$FILTERGATEWAY_MANIFEST" ]]; then
run_clippy "$FILTERGATEWAY_MANIFEST" "filtergateway"
else
echo "::warning ::$FILTERGATEWAY_MANIFEST not found, skipping..."
fi

# Run actioncontroller clippy checks
if [[ -f "$ACTIONCONTROLLER_MANIFEST" ]]; then
run_clippy "$ACTIONCONTROLLER_MANIFEST" "actioncontroller"
else
echo "::warning ::$ACTIONCONTROLLER_MANIFEST not found, skipping..."
fi

72 changes: 72 additions & 0 deletions scripts/deny_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash
set -euo pipefail

LOG_FILE="deny_results.log"
TMP_FILE="deny_output.txt"
REPORT_FILE="deny_summary.md"

rm -f "$LOG_FILE" "$TMP_FILE" "$REPORT_FILE"

echo "πŸ” Running Cargo Deny checks..." | tee -a "$LOG_FILE"

PROJECT_ROOT=${GITHUB_WORKSPACE:-$(pwd)}
cd "$PROJECT_ROOT"

FAILED_TOTAL=0
PASSED_TOTAL=0
PIDS=()

# Declare manifest paths
COMMON_MANIFEST="src/common/Cargo.toml"
AGENT_MANIFEST="src/agent/Cargo.toml"
TOOLS_MANIFEST="src/tools/Cargo.toml"
APISERVER_MANIFEST="src/server/apiserver/Cargo.toml"
FILTERGATEWAY_MANIFEST="src/player/filtergateway/Cargo.toml"

# Function to run cargo-deny check
run_deny() {
local manifest="$1"
local label="$2"
local deny_passed=false

echo "🚨 Running deny check for $label ($manifest)" | tee -a "$LOG_FILE"

if cargo deny --manifest-path="$manifest" check 2>&1 | tee "$TMP_FILE"; then
echo "βœ… deny check for $label passed clean." | tee -a "$LOG_FILE"
deny_passed=true
else
echo "::error ::Deny check for $label failed! Issues found." | tee -a "$LOG_FILE"
# Optional: extract relevant issues
grep -E "error:|warning:" "$TMP_FILE" | tee -a "$LOG_FILE"
fi

if $deny_passed; then
echo "βœ… deny check for $label: PASSED" >> "$REPORT_FILE"
(( PASSED_TOTAL++ ))
else
echo "❌ deny check for $label: FAILED" >> "$REPORT_FILE"
(( FAILED_TOTAL++ ))
fi
}

# Run deny check for each manifest
#[[ -f "$COMMON_MANIFEST" ]] && run_deny "$COMMON_MANIFEST" "common" || echo "::warning ::$COMMON_MANIFEST not found, skipping..."
#[[ -f "$AGENT_MANIFEST" ]] && run_deny "$AGENT_MANIFEST" "agent" || echo "::warning ::$AGENT_MANIFEST not found, skipping..."
#[[ -f "$TOOLS_MANIFEST" ]] && run_deny "$TOOLS_MANIFEST" "tools" || echo "::warning ::$TOOLS_MANIFEST not found, skipping..."
[[ -f "$APISERVER_MANIFEST" ]] && run_deny "$APISERVER_MANIFEST" "apiserver" || echo "::warning ::$APISERVER_MANIFEST not found, skipping..."
#[[ -f "$FILTERGATEWAY_MANIFEST" ]]&& run_deny "$FILTERGATEWAY_MANIFEST" "filtergateway" || echo "::warning ::$FILTERGATEWAY_MANIFEST not found, skipping..."

# Final summary
echo -e "\nπŸ“„ Summary:" | tee -a "$LOG_FILE"
cat "$REPORT_FILE" | tee -a "$LOG_FILE"

echo -e "\nπŸ”’ Total Passed: $PASSED_TOTAL" | tee -a "$LOG_FILE"
echo "πŸ”’ Total Failed: $FAILED_TOTAL" | tee -a "$LOG_FILE"

# Fail script if any deny check failed
if [[ "$FAILED_TOTAL" -gt 0 ]]; then
echo "::error ::One or more cargo-deny checks failed."
exit 1
fi

echo "βœ… All cargo-deny checks passed!"
Loading
Loading