mirror of https://github.com/CrowCpp/Crow.git
Merge pull request #662 from CrowCpp/coveralls-gha
added proper coveralls submission workflow
This commit is contained in:
commit
1918beb0b8
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue