Add fixes for rpm and add a flag to disable log collection #124
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Code Analysis | |
on: | |
pull_request: | |
push: | |
paths-ignore: | |
- '.github/**' | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
code-analysis: | |
name: Run all the testcases and analyze the code coverage | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22.0 | |
- name: Set up Git credentials for Go | |
run: | | |
git config --global url."https://${{ secrets.GHCR_TOKEN }}:@github.com/".insteadOf "https://github.com/" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }} | |
- name: Install all dependencies | |
run: go mod tidy | |
- name: Run test cases and generate code coverage | |
run: | | |
output=$(make test_coverage) | |
# Extract coverage percentages using grep and awk | |
coverage_percentages=$(echo "$output" | grep -o 'coverage: [0-9.]*%' | awk '{print $2}' | sed 's/%//g') | |
# Initialize variables for sum and count | |
sum=0 | |
count=0 | |
# Loop through the coverage percentages and calculate sum and count | |
for percentage in $coverage_percentages; do | |
sum=$(awk "BEGIN {print $sum + $percentage}") | |
count=$((count + 1)) | |
done | |
# Calculate the average coverage percentage | |
average=$(awk "BEGIN {print $sum / $count}") | |
echo "Code coverage: $average%" | |
# Check if the code coverage percentage is less than 80 | |
if (( $(awk "BEGIN {print ($average < 80)}") )); then | |
echo "::warning::Code coverage is below 80%" | |
fi |