Skip to content

Update coverage script (#431) #39

Update coverage script (#431)

Update coverage script (#431) #39

Workflow file for this run

name: Post Merge
on:
push:
branches: [ "main-ci-test" ]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"
jobs:
update_code_coverage_threshold:
name: Generate Code Coverage
runs-on: ubuntu-latest
steps:
- name: read threshold file into environment variable
run: |
git init
git clone https://github.com/rdkcentral/Ripple.git
cd Ripple
git fetch
git checkout locked_actions_branch
LOWER_COVERAGE_THRESHOLD=$(cat ./ci/coverage_threshold.txt | cut -d ' ' -f1)
echo "LOWER_COVERAGE_THRESHOLD=$LOWER_COVERAGE_THRESHOLD" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo llvm-cov --cobertura --output-path coverage.cobertura.xml
- uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: ${{ env.LOWER_COVERAGE_THRESHOLD }}
- run: |
CURRENT_COVERAGE=$(grep '<coverage' coverage.cobertura.xml | grep -o 'line-rate="[0-9.]\+"' | grep -o '[0-9.]\+')
CURRENT_COVERAGE=$(printf %.0f $(echo "$CURRENT_COVERAGE*100" | bc))
CURRENT_LOWER_THRESHOLD=$(echo "$CURRENT_COVERAGE-2" | bc)
CURRENT_UPPER_THRESHOLD=$(echo "$CURRENT_COVERAGE+2" | bc)
echo "CURRENT_LOWER_THRESHOLD=$CURRENT_LOWER_THRESHOLD" >> $GITHUB_ENV
echo "$CURRENT_LOWER_THRESHOLD $CURRENT_UPPER_THRESHOLD" > ./ci/coverage_threshold_temp.txt
- name: update threshold and push changes
if: ${{ fromJSON(env.CURRENT_LOWER_THRESHOLD) > fromJSON(env.LOWER_COVERAGE_THRESHOLD) }}
run: |
rm ./ci/coverage_threshold.txt
cp ./ci/coverage_threshold_temp.txt ./ci/coverage_threshold.txt
git clone https://github.com/rdkcentral/Ripple.git
cd Ripple
git fetch
git checkout locked_actions_branch
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add ../ci/coverage_threshold.txt
git commit -m "chore: git bot update threshold"
ls
git push origin head:locked_actions_branch
continue-on-error: true