forked from IntelLabs/vdms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 Add CI using Github Actions (IntelLabs#37)
* Modifications needed for CI using Github actions * remove .gitlab-ci.yml
- Loading branch information
Showing
5 changed files
with
192 additions
and
63 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
name: Compare C++ Coverage | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master and develop branch | ||
on: | ||
pull_request: | ||
types: [ opened, edited, synchronize, reopened ] | ||
branches: | ||
- develop | ||
- master | ||
|
||
# Environment variables | ||
env: | ||
GITHUB_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
coverage_job: | ||
name: Coverage Test | ||
|
||
# The type of runner that the job will run on | ||
runs-on: self-hosted | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
include: | ||
- coverage_type: Source | ||
container_name: coverage_cpp_source_${GITHUB_PULL_REQUEST_NUMBER} | ||
container_output: coverage_cpp_source_output | ||
container_tag: "vdms:source_coverage" | ||
output_name: source_coverage | ||
report_name: source_coverage_report | ||
branch_ref: ${{ github.event.pull_request.head.sha }} | ||
- coverage_type: Target | ||
container_name: coverage_cpp_target_${GITHUB_PULL_REQUEST_NUMBER} | ||
container_output: coverage_cpp_target_output | ||
container_tag: "vdms:target_coverage" | ||
output_name: target_coverage | ||
report_name: target_coverage_report | ||
branch_ref: ${{ github.event.pull_request.base.ref }} | ||
|
||
outputs: | ||
source_coverage: ${{ steps.report_coverage.outputs.source_coverage}} | ||
target_coverage: ${{ steps.report_coverage.outputs.target_coverage}} | ||
# source_coverage_report: ${{ steps.report_coverage.outputs.source_coverage_report}} | ||
# target_coverage_report: ${{ steps.report_coverage.outputs.target_coverage_report}} | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Clean workspace if git module is found | ||
run: git submodule status || rm -rf "$GITHUB_WORKSPACE"/* "$GITHUB_WORKSPACE"/.gi* | ||
|
||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- name: Checkout ${{ matrix.coverage_type }} Branch | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
ref: ${{ matrix.branch_ref }} | ||
|
||
- name: Build and Run Docker Container | ||
run: | | ||
set -x | ||
docker stop $(docker ps -aqf "name=${{ matrix.container_name }}") || true | ||
docker rm $(docker ps -aqf "name=${{ matrix.container_name }}") || true | ||
docker build --build-arg MAVEN_OPTS='-Dhttps.proxyHost=proxy-chain.intel.com -Dhttps.proxyPort=912 -Dhttps.nonProxyHosts="localhost|127.0.0.1"' \ | ||
-f docker/check-in/Dockerfile -t ${{ matrix.container_tag }} . | ||
docker run -d --name ${{ matrix.container_name }} ${{ matrix.container_tag }} | ||
- name: Get ${{ matrix.coverage_type }} Coverage | ||
shell: bash | ||
run: | | ||
set -x | ||
mkdir -p coverage | ||
echo "${{ matrix.container_name }}" | ||
# Make sure coverage script is available | ||
if [ ! -f docker/check-in/run_coverage.sh ]; then | ||
docker exec ${{ matrix.container_name }} bash -c "touch /run_coverage.sh && echo 'cd /vdms/tests && chmod +x run_tests.sh && ./run_tests.sh' >> /run_coverage.sh && chmod +x /run_coverage.sh && mkdir -p /vdms/tests/coverage_report" | ||
docker exec ${{ matrix.container_name }} bash -c "echo 'gcovr -k --root /vdms -e /vdms/src/pmgd -e /vdms/build/CMakeFiles -f "/vdms/client/.*\.cc" -f "/vdms/ext/.*\.cc" -f "/vdms/src/.*\.cc" -f src/SearchExpression.cc --exclude-unreachable-branches --xml-pretty --xml=/vdms/tests/coverage_report/c_coverage_report.xml --txt=/vdms/tests/coverage_report/c_coverage_report.txt' >> /run_coverage.sh && echo "echo 'DONE'" >> /run_coverage.sh" | ||
docker exec ${{ matrix.container_name }} bash -c "echo 'cat /vdms/tests/coverage_report/c_coverage_report.txt' >> /run_coverage.sh" | ||
fi | ||
docker exec ${{ matrix.container_name }} bash -c "./run_coverage.sh" | ||
docker cp $(docker ps -a | grep ${{ matrix.container_name }} | awk '{print $1}'):/vdms/tests/coverage_report/c_coverage_report.txt coverage/c_coverage_report_target.txt | ||
# report="$(<coverage/c_coverage_report_target.txt)" | ||
# report="${report//'%'/'%25'}" | ||
# report="${report//$'\n'/'%0A'}" | ||
# report="${report//$'\r'/'%0D'}" | ||
# echo "coverage_report="$report"" >> $GITHUB_ENV | ||
docker cp $(docker ps -a | grep ${{ matrix.container_name }} | awk '{print $1}'):/vdms/tests/coverage_report/c_coverage_report.xml coverage/c_coverage_report_target.xml | ||
echo "coverage_value=$(cat coverage/c_coverage_report_target.xml | grep -oP 'coverage line-rate="([-+]?\d*\.\d+|\d+)"' | grep -oP "[-+]?\d*\.\d+|\d+" | awk '{print $1*100}')" >> $GITHUB_ENV | ||
docker ps -aqf "name=${{ matrix.container_name }}" | xargs docker stop | ||
docker ps -aqf "name=${{ matrix.container_name }}" | xargs docker rm | ||
- name: Report ${{ matrix.coverage_type }} Coverage | ||
id: report_coverage | ||
run: | | ||
set -x | ||
if [[ -z $coverage_value ]] | ||
then | ||
exit 1 | ||
fi | ||
echo "${{ matrix.coverage_type }} Coverage: ${coverage_value}" | ||
echo "::set-output name=${{ matrix.output_name }}::${coverage_value}" | ||
# echo "::set-output name=${{ matrix.report_name }}::${coverage_report}" | ||
compare_coverage: | ||
name: Compare Reported Coverage | ||
|
||
# The type of runner that the job will run on | ||
runs-on: self-hosted | ||
needs: coverage_job | ||
steps: | ||
- name: Comment Coverage | ||
if: (github.event_name == 'pull_request') | ||
uses: actions/github-script@v3 | ||
with: | ||
# \n\n\nTarget Report: ${{ needs.coverage_job.outputs.target_coverage_report }}\n\n\nSource Report: ${{ needs.coverage_job.outputs.source_coverage_report }}' | ||
script: | | ||
github.issues.createComment({ | ||
issue_number: ${{ github.event.number }}, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'Target Coverage: ${{ needs.coverage_job.outputs.target_coverage }}%\n\n\nSource Coverage: ${{ needs.coverage_job.outputs.source_coverage }}%' | ||
}) | ||
- name: Compare Coverage | ||
run: | | ||
echo "Source Coverage: ${{needs.coverage_job.outputs.source_coverage}}" | ||
echo "Target Coverage: ${{needs.coverage_job.outputs.target_coverage}}" | ||
if ${{ needs.coverage_job.outputs.target_coverage > needs.coverage_job.outputs.source_coverage }} | ||
then | ||
echo 'Coverage below target' | ||
exit 1 | ||
else | ||
echo "Coverage threshold met!" | ||
fi |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cd /vdms/tests | ||
|
||
chmod +x run_tests.sh | ||
./run_tests.sh | ||
|
||
# -k | ||
# -e /vdms/src/pmgd -e "/vdms/.*\.h" \ | ||
# -f /vdms/client -f /vdms/ext -f /vdms/include -f /vdms/src \ | ||
# gcovr -d --root /vdms \ | ||
# -f /vdms/include \ | ||
# -f /vdms/src \ | ||
# -e /vdms/src/pmgd \ | ||
|
||
gcovr -k --root /vdms \ | ||
-e /vdms/src/pmgd -e /vdms/build/CMakeFiles \ | ||
-f "/vdms/client/.*\.cc" -f "/vdms/ext/.*\.cc" -f "/vdms/src/.*\.cc" \ | ||
-f src/SearchExpression.cc \ | ||
--exclude-unreachable-branches \ | ||
--txt=/vdms/tests/coverage_report/c_coverage_report.txt \ | ||
--xml-pretty --xml=/vdms/tests/coverage_report/c_coverage_report.xml | ||
|
||
echo "DONE" | ||
|
||
cat /vdms/tests/coverage_report/c_coverage_report.txt |
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