Skip to content

Commit 2e2c0cb

Browse files
authored
Enable CI. (#477)
* Enable PR wokrflows. * Fix syntax. * add .github path to trigger workflow * Add googletest to .gitmodules * Add root path in workflow triggering * remove paths to test * Fix paths in submodules init * fix path in dockerfile * Move and modify files. * Fix syntax * Fix context paths * Small fixes in workflows * fixes in weekly cached images * Small fixes and check if docker and covieroty workflow ill be triggered * Fixes for Coverity workflow. * revert change in dockerfile and c file * Change triggering * Add empty line * Add codewoners, contributing and code of conduct. * modify readme * final fixes * change Security.md anme * change codewoners * Add executive permissions for sripts * Add more workflows
1 parent 212da44 commit 2e2c0cb

26 files changed

+3389
-77
lines changed

.github/CODEOWNERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
LICENSE @pmalatyn
2+
CONTRIBUTING.md @pmalatyn
3+
CODE_OF_CONDUCT.md @pmalatyn
4+
SECURITY.md @pmalatyn
5+
README.md @tbujewsk
6+
## dlstreamer worfklows ##
7+
/.github/workflows/* @tbujewsk @nszczygl9 @dmichalo @yangjianfeng1208
8+
## dlstreamer repo ##
9+
* @tbujewsk @OskarFiedot @marcin-wadolkowski @nszczygl9 @dmichalo @msmiatac @jmotow @pbartosik @mholowni @qianlongding @BaoHuiling @yunowo @ZiningLi @yangjianfeng1208
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: "Code Style Check"
2+
description: "Reusable action to check C/C++ code style with clang-format"
3+
inputs:
4+
target_dir:
5+
description: "Directory to check for C/C++ files"
6+
required: false
7+
default: "."
8+
name:
9+
description: 'Name for the output artifact'
10+
required: false
11+
default: 'code-style-check-report'
12+
fail-on-findings:
13+
description: "Whether to fail the action if issues are found"
14+
required: false
15+
default: "true"
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install --no-install-recommends -y clang-format curl ca-certificates build-essential
24+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
25+
sudo apt-get install -y nodejs
26+
npm install -g diff2html-cli
27+
shell: bash
28+
29+
- name: Run code style check
30+
id: code-style-check
31+
env:
32+
target_dir: ${{ inputs.target_dir }}
33+
run: |
34+
chmod +x .github/actions/common/code-style/entrypoint.sh
35+
./.github/actions/common/code-style/entrypoint.sh "${target_dir}" || echo "STYLE_ISSUES=true" >> $GITHUB_OUTPUT
36+
shell: bash
37+
38+
- name: Analyze code style results
39+
if: always()
40+
run: |
41+
if [ "${{ steps.code-style-check.outputs.STYLE_ISSUES }}" == "true" ]; then
42+
# Count number of files with style issues
43+
if [ -f "_output/diff.html" ]; then
44+
# Try to count files from diff output
45+
file_count=$(diff -u --recursive "${{ inputs.target_dir }}" "_styled/${{ inputs.target_dir }}" 2>/dev/null | grep -c "^diff -u" || echo "1+")
46+
47+
echo "### Code Style Check Results" >> $GITHUB_STEP_SUMMARY
48+
echo "" >> $GITHUB_STEP_SUMMARY
49+
echo "- ❌ **Status**: Style issues found" >> $GITHUB_STEP_SUMMARY
50+
echo "- 📁 **Files affected**: ${file_count}" >> $GITHUB_STEP_SUMMARY
51+
echo "- 📄 **Detailed report**: Available in artifacts (diff.html)" >> $GITHUB_STEP_SUMMARY
52+
echo "" >> $GITHUB_STEP_SUMMARY
53+
echo "⚠️ **Please review the code-style report artifact and apply clang-format to fix the issues.**" >> $GITHUB_STEP_SUMMARY
54+
echo "" >> $GITHUB_STEP_SUMMARY
55+
echo "💡 **Tip**: Run \`clang-format -i\` on the affected files to automatically fix formatting." >> $GITHUB_STEP_SUMMARY
56+
fi
57+
else
58+
echo "### Code Style Check Results" >> $GITHUB_STEP_SUMMARY
59+
echo "" >> $GITHUB_STEP_SUMMARY
60+
echo "✅ **All code follows the style guidelines!**" >> $GITHUB_STEP_SUMMARY
61+
fi
62+
shell: bash
63+
64+
- name: Upload clang-format report
65+
if: always()
66+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
67+
with:
68+
name: ${{ inputs.name }}
69+
path: _output/diff.html
70+
if-no-files-found: ignore
71+
72+
- name: Fail if code style issues found
73+
if: inputs.fail-on-findings == 'true' && steps.code-style-check.outputs.STYLE_ISSUES == 'true'
74+
shell: bash
75+
run: |
76+
echo "❌ Code style issues found. Failing the job."
77+
exit 1
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# ==============================================================================
3+
# Copyright (C) 2025 Intel Corporation
4+
#
5+
# SPDX-License-Identifier: MIT
6+
# ==============================================================================
7+
#!/bin/bash
8+
set -e
9+
10+
SOURCE="${1:-/sources}"
11+
SOURCE=$(realpath --relative-to=. "$SOURCE" | sed 's:/*$::')
12+
13+
STYLED_DIR="./_styled"
14+
OUTPUT_DIR="./_output"
15+
mkdir -p "$STYLED_DIR" "$OUTPUT_DIR"
16+
17+
mkdir -p "$(dirname "$STYLED_DIR/$SOURCE")"
18+
cp -R "$SOURCE" "$STYLED_DIR/$SOURCE"
19+
20+
find "$STYLED_DIR/$SOURCE" \
21+
\( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hh' -o -name '*.hpp' \) \
22+
-exec sh -c "clang-format style=file -i '{}' 2>&1 | sed '/No such file or directory/d'" \;
23+
24+
output=$(diff -u --recursive "$SOURCE" "$STYLED_DIR/$SOURCE" || true)
25+
26+
if [[ -n "$output" ]]; then
27+
diff2html -F "$OUTPUT_DIR/diff.html" -d word -s "side" -i stdin <<< "$output"
28+
sed -i '37d;38i<h1>Code style diff</h1>' "$OUTPUT_DIR/diff.html"
29+
echo "❌ There are problems with code styles"
30+
exit 1
31+
else
32+
echo "✅ Code styles are fine"
33+
exit 0
34+
fi
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Run Hadolint
2+
description: Lint Dockerfiles using Hadolint
3+
4+
inputs:
5+
dockerfile:
6+
description: Path to Dockerfile
7+
required: true
8+
output-file:
9+
description: Path to output file for lint results
10+
required: true
11+
name:
12+
description: Name for the artifact
13+
required: true
14+
enable-reviewdog:
15+
description: Enable ReviewDog PR comments
16+
required: false
17+
default: "false"
18+
github_token:
19+
description: GitHub token for ReviewDog
20+
required: false
21+
fail-on-findings:
22+
description: "Whether to fail the action if issues are found"
23+
required: false
24+
default: "true"
25+
26+
runs:
27+
using: "composite"
28+
steps:
29+
- name: Install Hadolint
30+
run: |
31+
curl -sSL -o hadolint https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
32+
chmod +x hadolint
33+
sudo mv hadolint /usr/local/bin/
34+
shell: bash
35+
36+
- name: Run Hadolint
37+
id: run-hadolint
38+
env:
39+
dockerfile: ${{ inputs.dockerfile }}
40+
output_file: ${{ inputs.output-file }}
41+
run: |
42+
hadolint ${dockerfile} \
43+
--format tty \
44+
2>&1 | tee ${output_file} || true
45+
if [ ! -f "${output_file}" ]; then
46+
echo "No Dockerfile found or hadolint produced no output" > ${output_file}
47+
fi
48+
shell: bash
49+
50+
- name: Analyze Hadolint results
51+
if: always()
52+
env:
53+
output_file: ${{ inputs.output-file }}
54+
name: ${{ inputs.name }}
55+
run: |
56+
if [ -f "${output_file}" ]; then
57+
# Count issues by severity (hadolint format: DL#### or SC#### followed by colored severity)
58+
# Pattern matches: DL3008 or SC1091 (hadolint and shellcheck codes)
59+
error_count=$(grep -E "(DL|SC)[0-9]+" "${output_file}" 2>/dev/null | grep -i "error" | wc -l | tr -d '[:space:]' || echo "0")
60+
warning_count=$(grep -E "(DL|SC)[0-9]+" "${output_file}" 2>/dev/null | grep -i "warning" | wc -l | tr -d '[:space:]' || echo "0")
61+
info_count=$(grep -E "(DL|SC)[0-9]+" "${output_file}" 2>/dev/null | grep -i "info" | wc -l | tr -d '[:space:]' || echo "0")
62+
style_count=$(grep -E "(DL|SC)[0-9]+" "${output_file}" 2>/dev/null | grep -i "style" | wc -l | tr -d '[:space:]' || echo "0")
63+
# Ensure counts are valid integers, default to 0 if empty
64+
error_count=${error_count:-0}
65+
warning_count=${warning_count:-0}
66+
info_count=${info_count:-0}
67+
style_count=${style_count:-0}
68+
# Additional safety check - ensure numeric (use case to validate)
69+
case "$error_count" in ''|*[!0-9]*) error_count=0 ;; esac || true
70+
case "$warning_count" in ''|*[!0-9]*) warning_count=0 ;; esac || true
71+
case "$info_count" in ''|*[!0-9]*) info_count=0 ;; esac || true
72+
case "$style_count" in ''|*[!0-9]*) style_count=0 ;; esac || true
73+
total=$((error_count + warning_count + info_count + style_count)) || total=0
74+
75+
echo "### Hadolint Results for ${name}" >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
echo "- **Total Issues**: $total" >> $GITHUB_STEP_SUMMARY
78+
79+
if [ "$error_count" -gt 0 ]; then
80+
echo "- ❌ **Errors**: $error_count" >> $GITHUB_STEP_SUMMARY
81+
fi
82+
if [ "$warning_count" -gt 0 ]; then
83+
echo "- ⚠️ **Warnings**: $warning_count" >> $GITHUB_STEP_SUMMARY
84+
fi
85+
if [ "$info_count" -gt 0 ]; then
86+
echo "- ℹ️ **Info**: $info_count" >> $GITHUB_STEP_SUMMARY
87+
fi
88+
if [ "$style_count" -gt 0 ]; then
89+
echo "- 🎨 **Style**: $style_count" >> $GITHUB_STEP_SUMMARY
90+
fi
91+
92+
if [ "$total" -gt 0 ]; then
93+
echo "" >> $GITHUB_STEP_SUMMARY
94+
echo "⚠️ **Please review the Hadolint report artifact and consider fixing the issues.**" >> $GITHUB_STEP_SUMMARY
95+
else
96+
echo "" >> $GITHUB_STEP_SUMMARY
97+
echo "✅ **No issues found!**" >> $GITHUB_STEP_SUMMARY
98+
fi
99+
fi
100+
shell: bash
101+
102+
- name: Upload Hadolint report as artifact
103+
if: always()
104+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
105+
with:
106+
name: hadolint-report-${{ inputs.name }}
107+
path: ${{ inputs.output-file }}
108+
109+
- name: Run ReviewDog (Hadolint)
110+
if: ${{ inputs.enable-reviewdog == 'true' }}
111+
uses: reviewdog/action-hadolint@fc7ee4a9f71e521bc43e370819247b70e5327540 # 1.50.2
112+
with:
113+
github_token: ${{ inputs.github_token }}
114+
reporter: github-pr-review
115+
level: warning
116+
hadolint_flags: ${{ inputs.dockerfile }}
117+
118+
- name: Fail if Hadolint found issues
119+
if: inputs.fail-on-findings == 'true'
120+
shell: bash
121+
env:
122+
output_file: ${{ inputs.output-file }}
123+
run: |
124+
if [ -f "${output_file}" ]; then
125+
issue_count=$(grep -E "(DL|SC)[0-9]+" "${output_file}" 2>/dev/null | wc -l | tr -d '[:space:]' || echo "0")
126+
if [ "$issue_count" -gt 0 ]; then
127+
echo "❌ Hadolint found $issue_count issue(s). Failing the job."
128+
exit 1
129+
fi
130+
fi
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: 'License and Namespace Checker'
2+
description: 'Checks license headers and namespace usage in headers'
3+
inputs:
4+
name:
5+
description: 'Name for the output artifact'
6+
required: false
7+
default: 'license-namespace-check-report'
8+
path:
9+
description: 'Path to the repository root'
10+
required: false
11+
default: '.'
12+
fail-on-findings:
13+
description: "Whether to fail the action if issues are found"
14+
required: false
15+
default: "true"
16+
runs:
17+
using: 'composite'
18+
steps:
19+
- name: Get list of changed files
20+
shell: bash
21+
id: discover-changes
22+
env:
23+
REPO_PATH: ${{ inputs.path }}
24+
run: |
25+
cd "${REPO_PATH}"
26+
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
27+
git fetch origin master:master
28+
echo "Fetched master branch"
29+
fi
30+
changed_files=$(git diff --name-only master...$GITHUB_SHA -- '*.h' '*.hpp' '*.c' '*.cpp' '*.sh' '*.py' '*.txt' | grep -E '.*\.(h|hpp|c|cpp|sh|py|txt)$' || true)
31+
echo "Performed git diff"
32+
if [ -n "$changed_files" ]; then
33+
# Add changed files list to the GITHUB_OUTPUT separated by spaces
34+
echo "changed_files=$(echo $changed_files)" >> $GITHUB_OUTPUT
35+
echo "Changed files:"
36+
echo "$changed_files"
37+
else
38+
# No changed files, explicitly set the exit code to 0
39+
echo "No changed files detected."
40+
exit 0
41+
fi
42+
43+
- name: Check License header and namespace usage in headers
44+
id: license-check
45+
shell: bash
46+
env:
47+
CHANGED_FILES: ${{ steps.discover-changes.outputs.changed_files }}
48+
REPO_PATH: ${{ inputs.path }}
49+
output_file: license-check-report.txt
50+
run: |
51+
if [ -z "${CHANGED_FILES}" ]; then
52+
echo "No new files to scan." | tee "${output_file}"
53+
echo "ISSUES_FOUND=false" >> $GITHUB_OUTPUT
54+
else
55+
if "${GITHUB_ACTION_PATH}/run.sh" "${REPO_PATH}" $CHANGED_FILES 2>&1 | tee "${output_file}"; then
56+
echo "ISSUES_FOUND=false" >> $GITHUB_OUTPUT
57+
else
58+
echo "ISSUES_FOUND=true" >> $GITHUB_OUTPUT
59+
fi
60+
fi
61+
62+
- name: Upload License Check report
63+
if: always()
64+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
65+
with:
66+
name: ${{ inputs.name }}
67+
path: license-check-report.txt
68+
if-no-files-found: warn
69+
70+
- name: Analyze License Check results
71+
if: always()
72+
shell: bash
73+
env:
74+
output_file: license-check-report.txt
75+
run: |
76+
if [ "${{ steps.license-check.outputs.ISSUES_FOUND }}" == "true" ]; then
77+
# Count files with issues
78+
if [ -f "${output_file}" ]; then
79+
error_count=$(grep -c "Error:" "${output_file}" 2>/dev/null || echo "0")
80+
echo "### License & Namespace Check Results" >> $GITHUB_STEP_SUMMARY
81+
echo "" >> $GITHUB_STEP_SUMMARY
82+
echo "- ❌ **Status**: Issues found" >> $GITHUB_STEP_SUMMARY
83+
echo "- 🔍 **Total errors**: ${error_count}" >> $GITHUB_STEP_SUMMARY
84+
echo "" >> $GITHUB_STEP_SUMMARY
85+
echo "📄 **See job logs for detailed error messages.**" >> $GITHUB_STEP_SUMMARY
86+
fi
87+
elif [ "${{ steps.discover-changes.outputs.changed_files }}" != "" ]; then
88+
echo "### License & Namespace Check Results" >> $GITHUB_STEP_SUMMARY
89+
echo "" >> $GITHUB_STEP_SUMMARY
90+
echo "✅ **All checked files have correct license headers and namespace usage!**" >> $GITHUB_STEP_SUMMARY
91+
else
92+
echo "### License & Namespace Check Results" >> $GITHUB_STEP_SUMMARY
93+
echo "" >> $GITHUB_STEP_SUMMARY
94+
echo "ℹ️ **No relevant files changed - check skipped**" >> $GITHUB_STEP_SUMMARY
95+
fi
96+
97+
- name: Fail if license/namespace issues found
98+
if: inputs.fail-on-findings == 'true' && steps.license-check.outputs.ISSUES_FOUND == 'true'
99+
shell: bash
100+
run: |
101+
echo "❌ License or namespace issues found. Failing the job."
102+
exit 1
103+
104+
- name: Clean up
105+
if: always()
106+
shell: bash
107+
run: |
108+
rm -f license-check-report.txt

0 commit comments

Comments
 (0)