Skip to content

Commit 1918beb

Browse files
authored
Merge pull request #662 from CrowCpp/coveralls-gha
added proper coveralls submission workflow
2 parents 94c0cf2 + bf683e5 commit 1918beb

File tree

2 files changed

+74
-17
lines changed

2 files changed

+74
-17
lines changed

.github/workflows/build_and_test.yml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test (cmake based build)
1+
name: Build and test
22

33
#on: push
44
on:
@@ -10,7 +10,7 @@ on:
1010
env:
1111
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
1212
BUILD_TYPE: Release
13-
#COVERALLS_PULL_REQUEST: ${{ github.event.number }}
13+
COVERALLS_PULL_REQUEST: ${{ github.event.number }}
1414
#COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
1515

1616
jobs:
@@ -45,20 +45,21 @@ jobs:
4545
echo "$RUNNER_OS not supported"
4646
exit 1
4747
fi
48-
shell: bash
48+
shell: bash
4949

5050
- name: Configure CMake
5151
run: |
52-
if [ "$RUNNER_OS" == "Windows" ]; then
52+
if [ "$RUNNER_OS" == "Windows" ]; then
5353
cmake \
5454
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
5555
-DCROW_FEATURES="ssl;compression" \
5656
-DCROW_AMALGAMATE=ON \
5757
-B build
58-
else
58+
else
5959
cmake -B build
6060
fi
6161
shell: bash
62+
6263
- name: Build
6364
# Build your program with the given configuration
6465
run: cmake --build build --config ${{env.BUILD_TYPE}}
@@ -70,18 +71,27 @@ jobs:
7071
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
7172
run: ctest --output-on-failure -C ${{env.BUILD_TYPE}}
7273

73-
#- name: Coverage Report
74-
# if: matrix.os == 'ubuntu-latest'
75-
# run: |
76-
# export CI_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
77-
# echo "CI_BRANCH=$CI_BRANCH" >> $GITHUB_ENV && \
78-
# export TRAVIS_JOB_ID=$GITHUB_RUN_NUMBER && \
79-
# git clone https://github.com/CrowCpp/cpp-coveralls.git && \
80-
# cd cpp-coveralls && \
81-
# pip3 install . --no-input && \
82-
# cd .. && \
83-
# coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp
84-
# shell: bash
74+
- name: Generate coverage report
75+
if: matrix.os == 'ubuntu-latest'
76+
run: |
77+
export CI_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
78+
echo "CI_BRANCH=$CI_BRANCH" >> $GITHUB_ENV && \
79+
export TRAVIS_JOB_ID=$GITHUB_RUN_NUMBER && \
80+
git clone https://github.com/CrowCpp/cpp-coveralls.git && \
81+
cd cpp-coveralls && \
82+
pip3 install . --no-input && \
83+
cd .. && \
84+
coveralls --verbose --exclude-pattern .*/http_parser_merged.h --exclude-pattern .*/TinySHA1.hpp --dump coveralls.json
85+
shell: bash
86+
87+
88+
- name: Save report
89+
uses: actions/upload-artifact@v3
90+
if: matrix.os == 'ubuntu-latest'
91+
with:
92+
name: coveralls.json
93+
path: coveralls.json
94+
8595

8696
#- name: Package
8797
# working-directory: ${{github.workspace}}/build

.github/workflows/submit_coverage.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Submit coverage
2+
3+
# read-write repo token
4+
# access to secrets
5+
on:
6+
workflow_run:
7+
workflows: [Build and test]
8+
types: [completed]
9+
10+
env:
11+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
12+
13+
jobs:
14+
upload:
15+
runs-on: ubuntu-latest
16+
if: >
17+
github.event.workflow_run.event == 'pull_request' &&
18+
github.event.workflow_run.conclusion == 'success'
19+
steps:
20+
- name: Download artifact
21+
uses: dawidd6/action-download-artifact@v2
22+
with:
23+
workflow: ${{ github.event.workflow_run.workflow_id }}
24+
workflow_conclusion: success
25+
name: coveralls.json
26+
27+
28+
- name: 'Prepare dependencies'
29+
run: |
30+
sudo apt-get update && \
31+
sudo apt-get install -yq \
32+
jq \
33+
curl
34+
shell: bash
35+
36+
- name: 'Generate full report'
37+
run: |
38+
cat coveralls.json | jq --arg repo_token $COVERALLS_REPO_TOKEN '. += {repo_token: $repo_token}' > coveralls_full.json
39+
shell: bash
40+
41+
- name: 'Upload final report'
42+
run: |
43+
curl --request POST \
44+
--url https://coveralls.io/api/v1/jobs \
45+
--header 'Content-Type: multipart/form-data' \
46+
--form json_file=@./coveralls_full.json
47+
shell: bash

0 commit comments

Comments
 (0)