Merge pull request #662 from CrowCpp/coveralls-gha

added proper coveralls submission workflow
This commit is contained in:
Farook Al-Sammarraie 2023-06-16 13:14:26 +00:00 committed by GitHub
commit 1918beb0b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 17 deletions

View File

@ -1,4 +1,4 @@
name: Build and test (cmake based build)
name: Build and test
#on: push
on:
@ -10,7 +10,7 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
#COVERALLS_PULL_REQUEST: ${{ github.event.number }}
COVERALLS_PULL_REQUEST: ${{ github.event.number }}
#COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
jobs:
@ -45,20 +45,21 @@ jobs:
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash
shell: bash
- name: Configure CMake
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$RUNNER_OS" == "Windows" ]; then
cmake \
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DCROW_FEATURES="ssl;compression" \
-DCROW_AMALGAMATE=ON \
-B build
else
else
cmake -B build
fi
shell: bash
- name: Build
# Build your program with the given configuration
run: cmake --build build --config ${{env.BUILD_TYPE}}
@ -70,18 +71,27 @@ jobs:
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --output-on-failure -C ${{env.BUILD_TYPE}}
#- name: Coverage Report
# if: matrix.os == 'ubuntu-latest'
# run: |
# export CI_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
# echo "CI_BRANCH=$CI_BRANCH" >> $GITHUB_ENV && \
# export TRAVIS_JOB_ID=$GITHUB_RUN_NUMBER && \
# git clone https://github.com/CrowCpp/cpp-coveralls.git && \
# cd cpp-coveralls && \
# pip3 install . --no-input && \
# cd .. && \
# coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp
# shell: bash
- name: Generate coverage report
if: matrix.os == 'ubuntu-latest'
run: |
export CI_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
echo "CI_BRANCH=$CI_BRANCH" >> $GITHUB_ENV && \
export TRAVIS_JOB_ID=$GITHUB_RUN_NUMBER && \
git clone https://github.com/CrowCpp/cpp-coveralls.git && \
cd cpp-coveralls && \
pip3 install . --no-input && \
cd .. && \
coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp --dump coveralls.json
shell: bash
- name: Save report
uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
with:
name: coveralls.json
path: coveralls.json
#- name: Package
# working-directory: ${{github.workspace}}/build

47
.github/workflows/submit_coverage.yml vendored Normal file
View File

@ -0,0 +1,47 @@
name: Submit coverage
# read-write repo token
# access to secrets
on:
workflow_run:
workflows: [Build and test]
types: [completed]
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
jobs:
upload:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Download artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: coveralls.json
- name: 'Prepare dependencies'
run: |
sudo apt-get update && \
sudo apt-get install -yq \
jq \
curl
shell: bash
- name: 'Generate full report'
run: |
cat coveralls.json | jq --arg repo_token $COVERALLS_REPO_TOKEN '. += {repo_token: $repo_token}' > coveralls_full.json
shell: bash
- name: 'Upload final report'
run: |
curl --request POST \
--url https://coveralls.io/api/v1/jobs \
--header 'Content-Type: multipart/form-data' \
--form json_file=@./coveralls_full.json
shell: bash