Skip to content

Commit e29a69f

Browse files
ADD README
1 parent 4763826 commit e29a69f

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# General
2+
![github_actions_gtest_example-Release](https://github.com/bastianhjaeger/github_actions_gtest_example/workflows/github_actions_gtest_example-Release/badge.svg?branch=master)
3+
![github_actions_gtest_example-Debug](https://github.com/bastianhjaeger/github_actions_gtest_example/workflows/github_actions_gtest_example-Debug/badge.svg?branch=master)
4+
5+
Example on how to integrate gtest test into [github actions](https://github.com/features/actions).
6+
7+
8+
9+
While there exist other links in the www on how to use it (which did not work for my setup), this repo quickly shows how to add a workflow / action to github that executes you gtest tests and responses with a simple ok / not-ok to highlight on github.
10+
11+
It is plain and simple, but maybe it helps you.
12+
13+
# Setup Actions
14+
15+
the workflow file you need (e.g. in you repo under `.github/workflows/release.yml`) could look like this
16+
17+
```yaml
18+
name: my-workflow-name
19+
20+
on:
21+
push:
22+
branches: [ master ]
23+
pull_request:
24+
branches: [ master ]
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Install gtest manually
31+
run: sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake CMakeLists.txt && sudo make && sudo cp *.a /usr/lib && sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a && sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a
32+
- uses: actions/checkout@v1
33+
- name: configure
34+
run: mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Werror" ..
35+
- name: make
36+
run: cd build && make
37+
- name: Run Test
38+
run: /home/runner/work/github_actions_gtest_example/github_actions_gtest_example/build/test/github_actions_gtest_example.test
39+
```
40+
41+
The important part is the *"Install gtest manually"* section. This is the plain and simple way to add it.
42+
43+
# Result
44+
45+
After some time (depending on you project and test complexity) you see the results like this:
46+
47+
<img src="doc/actions_build_example_01.png" alt="actions_build_example_01" style="zoom:50%;" />
48+
49+
<img src="doc/actions_build_example_02_detail.png" alt="actions_build_example_02_detail" style="zoom:50%;" />
50+
51+
<img src="doc/actions_build_example_03_overview.png" alt="actions_build_example_03_overview" style="zoom:50%;" />
52+
53+
54+
# Build local
55+
```bash
56+
git clone git@github.com:bastianhjaeger/github_actions_gtest_example.git
57+
cd github_actions_gtest_example
58+
mkdir build && cd build
59+
cmake -DCMAKE_BUILD_TYPE=Release ..
60+
make -j8
61+
```

doc/actions_build_example_01.png

91.8 KB
Loading
55.8 KB
Loading
50.7 KB
Loading

0 commit comments

Comments
 (0)