Skip to content

Commit f0e3b7a

Browse files
authored
Merge pull request #23 from threeal/main
Version `0.2.0` Release
2 parents a27612a + 8563c4b commit f0e3b7a

File tree

5 files changed

+158
-122
lines changed

5 files changed

+158
-122
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: 'github-actions'
4+
directory: '/'
5+
schedule:
6+
interval: 'daily'

.github/workflows/test.yml

Lines changed: 84 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -3,142 +3,141 @@ on:
33
workflow_dispatch:
44
push:
55
jobs:
6-
use-action:
7-
runs-on: ubuntu-latest
6+
standard-usage:
7+
runs-on: ${{ matrix.os }}-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [windows, ubuntu, macos]
812
steps:
9-
- name: Checkout repository
10-
uses: actions/checkout@v3.2.0
13+
- name: Checkout this repository
14+
uses: actions/checkout@v3.3.0
1115

12-
- name: Build and test example project
13-
run: |
14-
cmake test -B build
15-
cmake --build build
16-
ctest --test-dir build
17-
18-
- name: Use this action
19-
uses: ./
20-
21-
use-action-llvm:
22-
runs-on: ubuntu-latest
23-
steps:
24-
- name: Checkout repository
25-
uses: actions/[email protected]
26-
27-
- name: Install LLVM
28-
run: sudo apt install -y llvm
16+
- name: Configure and build the test project
17+
uses: threeal/[email protected]
18+
with:
19+
source-dir: test
20+
generator: Ninja
21+
cxx-compiler: g++
2922

30-
- name: Build and test example project
31-
run: |
32-
cmake test -B build -DCMAKE_CXX_COMPILER=clang++
33-
cmake --build build
34-
ctest --test-dir build
23+
- name: Test the test project
24+
run: ctest --test-dir build
3525

3626
- name: Use this action
3727
uses: ./
38-
with:
39-
gcov-executable: llvm-cov gcov
4028

41-
use-action-from-different-root:
42-
runs-on: ubuntu-latest
29+
llvm-usage:
30+
runs-on: ${{ matrix.os }}-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
os: [windows, ubuntu, macos]
4335
steps:
44-
- name: Checkout repository
45-
uses: actions/[email protected]
46-
47-
- name: Build and test example project
48-
working-directory: test
49-
run: |
50-
cmake . -B build
51-
cmake --build build
52-
ctest --test-dir build
36+
- name: Checkout this repository
37+
uses: actions/[email protected]
5338

54-
- name: Use this action from build root
55-
id: failed_step
56-
continue-on-error: true
57-
uses: ./
39+
- name: Configure and build the test project
40+
uses: threeal/[email protected]
5841
with:
59-
root: test/build
60-
fail-under-line: 100
42+
source-dir: test
43+
generator: Ninja
44+
c-compiler: clang
45+
cxx-compiler: clang++
6146

62-
- name: Check if previous step is failing
63-
run: ${{ steps.failed_step.outcome == 'failure' && true || false }}
47+
- name: Test the test project
48+
run: ctest --test-dir build
6449

65-
- name: Use this action from build root but without fail threshold
50+
- name: Use this action with llvm-cov as the gcov executable
6651
uses: ./
6752
with:
68-
root: test/build
53+
gcov-executable: ${{ matrix.os == 'macos' && 'xcrun ' || '' }}llvm-cov gcov
54+
55+
exclusion-usage:
56+
runs-on: ${{ matrix.os }}-latest
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
os: [windows, ubuntu, macos]
61+
steps:
62+
- name: Checkout this repository
63+
uses: actions/[email protected]
6964

70-
- name: Use this action from project root
71-
uses: ./
65+
- name: Configure and build the test project
66+
uses: threeal/[email protected]
7267
with:
73-
root: test
74-
fail-under-line: 100
75-
76-
use-action-with-exclusion:
77-
runs-on: ubuntu-latest
78-
steps:
79-
- name: Checkout repository
80-
uses: actions/[email protected]
68+
source-dir: test
69+
build-dir: test/build
70+
generator: Ninja
71+
cxx-compiler: g++
72+
args: -DTEST_EVEN=OFF -DTEST_ODD=OFF
8173

82-
- name: Build and test example project
83-
working-directory: test
84-
run: |
85-
cmake . -B build -DTEST_EVEN=OFF -DTEST_ODD=OFF
86-
cmake --build build
87-
ctest --test-dir build
74+
- name: Test the test project
75+
run: ctest --test-dir test/build
8876

89-
- name: Use this action without exclusion
77+
- name: Use this action without an exclusion
9078
id: failed_step
9179
continue-on-error: true
9280
uses: ./
9381
with:
82+
root: test
9483
fail-under-line: 100
9584

96-
- name: Check if previous step is failing
85+
- name: Check if the previous step did fail
9786
run: ${{ steps.failed_step.outcome == 'failure' && true || false }}
9887

99-
- name: Use this action without exclusion but with lower fail threshold
88+
- name: Use this action without an exclusion but with a lower fail threshold
10089
uses: ./
10190
with:
91+
root: test
10292
fail-under-line: 50
10393

104-
- name: Use this action with exclusion
94+
- name: Use this action with an exclusion
10595
uses: ./
10696
with:
97+
root: test
10798
exclude: test/include/*
10899
fail-under-line: 100
109100

110-
use-action-generate-coveralls:
111-
runs-on: ubuntu-latest
101+
coveralls-usage:
102+
runs-on: ${{ matrix.os }}-latest
103+
strategy:
104+
fail-fast: false
105+
matrix:
106+
os: [windows, ubuntu, macos]
112107
steps:
113-
- name: Checkout repository
114-
uses: actions/[email protected]
108+
- name: Checkout this repository
109+
uses: actions/[email protected]
110+
111+
- name: Configure and build the test project
112+
uses: threeal/[email protected]
113+
with:
114+
source-dir: test
115+
generator: Ninja
116+
cxx-compiler: g++
115117

116-
- name: Build and test example project
117-
run: |
118-
cmake test -B build
119-
cmake --build build
120-
ctest --test-dir build
118+
- name: Test the test project
119+
run: ctest --test-dir build
121120

122-
- name: Use this action to generate Coveralls report
121+
- name: Use this action to generate a Coveralls report
123122
uses: ./
124123
with:
125124
coveralls-out: coveralls.json
126125

127-
- name: Check if Coveralls report exist
126+
- name: Check if that Coveralls report does exist
128127
run: cat coveralls.json
129128

130-
- name: Use this action to generate and send Coveralls report
129+
- name: Use this action to generate and send another Coveralls report
131130
uses: ./
132131
with:
133132
coveralls-send: true
134-
coveralls-repo-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
133+
github-token: ${{ secrets.GITHUB_TOKEN }}
135134

136-
- name: Use this action to generate and send Coveralls report on specified output
135+
- name: Use this action to generate and send another Coveralls report on a specified output
137136
uses: ./
138137
with:
139138
coveralls-out: coveralls-2.json
140139
coveralls-send: true
141-
coveralls-repo-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
140+
github-token: ${{ secrets.GITHUB_TOKEN }}
142141

143-
- name: Check if Coveralls report exist
142+
- name: Check if that Coveralls report does exist
144143
run: cat coveralls-2.json

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,35 @@
44
[![license](https://img.shields.io/github/license/threeal/gcovr-action)](./LICENSE)
55
[![test status](https://img.shields.io/github/actions/workflow/status/threeal/gcovr-action/test.yml?label=test&branch=main)](https://github.com/threeal/gcovr-action/actions/workflows/test.yml)
66

7-
Generate code coverage report for C++ project on [GitHub Actions](https://github.com/features/actions) using [gcovr](https://gcovr.com/en/stable/).
7+
Generate code coverage reports for a C++ project on [GitHub Actions](https://github.com/features/actions) using [gcovr](https://gcovr.com/en/stable/).
8+
9+
## Features
10+
11+
- Generate code coverage reports using [gcovr](https://gcovr.com/en/stable/).
12+
- Generate and send reports in [Coveralls API](https://docs.coveralls.io/api-introduction) format.
13+
- Auto detect and install required dependencies.
14+
- Support coverage report on [GCC](https://gcc.gnu.org/) and [LLVM Clang](https://clang.llvm.org/).
15+
- Support files exclusion and fail if coverage is below a specific thresold.
816

917
## Usage
1018

11-
For more information, see [action.yml](./action.yml) and the [GitHub Actions guide](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions).
19+
For more information, see [action.yml](./action.yml) and [GitHub Actions guide](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions).
1220

1321
### Inputs
1422

15-
> Note: All inputs are optional.
16-
1723
| Name | Value Type | Description |
1824
| --- | --- | --- |
19-
| `root` | Path | The root directory of your source files. Defaults to current directory. File names are reported relative to this root. |
20-
| `gcov-executable` | Executable name with optional arguments | Use a particular gcov executable. Must match the compiler you are using, e.g. `llvm-cov gcov` for [LLVM](https://llvm.org/). See [this](https://docs.coveralls.io/api-introduction). |
25+
| `root` | Path | Root directory of your source files. Defaults to current directory. File names are reported relative to this directory. |
26+
| `gcov-executable` | Executable name with optional arguments | Use a particular [gcov](https://gcc.gnu.org/onlinedocs/gcc/Gcov.html) executable. Must match the compiler you are using, e.g. `llvm-cov gcov` for [LLVM Clang](https://clang.llvm.org/). See [this](https://gcovr.com/en/stable/guide/compiling.html#choosing-the-right-gcov-executable). |
2127
| `exclude` | Regular expression | Exclude source files that match this filter. |
2228
| `fail-under-line` | 0 - 100 | Fail if the total line coverage is less than this value. |
23-
| `coveralls-out` | Path | Output file of generated Coveralls API coverage report. |
24-
| `coveralls-send` | `true` or `false` | Send Coveralls API coverage report to it's endpoint (default: `false`). |
25-
| `coveralls-repo-token` | Token | Coveralls repo token, required for sending Coveralls API coverage report successfully. See [this](https://docs.coveralls.io/api-introduction).
29+
| `coveralls-out` | Path | Output file of the generated [Coveralls API](https://docs.coveralls.io/api-introduction) coverage report. |
30+
| `coveralls-send` | `true` or `false` | Send the generated Coveralls API coverage report to it's endpoint. Defaults to `false`. |
31+
| `github-token` | Token | [GitHub token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication) of your project. Should be set to `secrets.GITHUB_TOKEN`. Required for sending Coveralls API coverage report successfully. |
2632

27-
### Standard Example
33+
> Note: All inputs are optional.
34+
35+
### Examples
2836

2937
```yaml
3038
name: test
@@ -34,44 +42,48 @@ jobs:
3442
test-coverage:
3543
runs-on: ubuntu-latest
3644
steps:
37-
- name: Checkout repository
45+
- name: Check out this repository
3846
uses: actions/[email protected]
3947

40-
- name: Build and test project
48+
- name: Build and test this project
4149
run: |
4250
cmake . -B build
4351
cmake --build build
4452
ctest --test-dir build
4553
46-
- name: Generate code coverage report
54+
- name: Generate a code coverage report
4755
uses: threeal/gcovr-action@latest
4856
```
4957
50-
### Using LLVM
58+
> Note: You can replace `@latest` with any version you like. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
59+
60+
#### Using LLVM Clang
5161

5262
```yaml
53-
- name: Build and test project
63+
- name: Build and test this project
5464
run: |
5565
cmake . -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
5666
cmake --build build
5767
ctest --test-dir build
5868
59-
- name: Generate code coverage report
69+
- name: Generate a code coverage report
6070
uses: threeal/gcovr-action@latest
6171
with:
6272
gcov-executable: llvm-cov gcov
6373
```
6474

65-
### Send to Coveralls
75+
#### Send to Coveralls
6676

6777
```yaml
68-
- name: Generate and send code coverage report to Coveralls
78+
- name: Generate and send a code coverage report to Coveralls
6979
uses: threeal/gcovr-action@latest
7080
with:
7181
coveralls-send: true
72-
coveralls-repo-token: ${{ secrets.COVERALLS_REPO_TOKEN }}
82+
github-token: ${{ secrets.GITHUB_TOKEN }}
7383
```
7484

7585
## License
7686

77-
This project is maintained by [Alfi Maulana](https://github.com/threeal) and licensed under the [MIT License](./LICENSE).
87+
This project is licensed under the terms of the [MIT License](./LICENSE).
88+
89+
Copyright © 2022-2023 [Alfi Maulana](https://github.com/threeal/)

0 commit comments

Comments
 (0)