Skip to content

Commit aa28c3e

Browse files
authored
CTAD rules fix, MSVC build fixes, setting up CI (#7)
* some fixes in CMakeLists * add test ci config. * ci fix attempt. * attempt to add a code coverage job. * attempt to add a code coverage job (2). * attempt to add a code coverage job (3). * attempt to add a code coverage job (4). * attempt to add a code coverage job (5). * attempt to add a code coverage job (6). * attempt to add a code coverage job (7). * attempt to add a code coverage job (8). * attempt to add a code coverage job (9). * attempt to add a code coverage job (10). * attempt to add a code coverage job (11). * attempt to add a code coverage job (12). * attempt to add a code coverage job (13). * attempt to add a code coverage job (14). * attempt to add a code coverage job (15). * attempt to add a code coverage job (16). * attempt to add a code coverage job (17). * attempt to add a code coverage job (18). * attempt to add a code coverage job (19). * attempt to add other ubuntu build jobs. * attempt to add other ubuntu build jobs (2). * attempt to add other ubuntu build jobs (3). * attempt to add other ubuntu build jobs (4). * attempt to add other ubuntu build jobs (5). * attempt to add other ubuntu build jobs (6). * attempt to add macOS builds. * attempt to add windows builds. * MSVS 2019 build fix. * attempt to fix MSVS 2017 build. * Revert "attempt to fix MSVS 2017 build." This reverts commit 9f38929. * attempt to fix MSVS 2017 build (2). * Revert "attempt to fix MSVS 2017 build (2)." This reverts commit 5dc08f2. * attempt to fix MSVS 2017 build (3). * rename workflow. * Add badges to README * cleaning up. * minor code style fix. * Minor README update [skip-ci] * Minor README update skip-ci
1 parent 9c850f3 commit aa28c3e

File tree

8 files changed

+412
-101
lines changed

8 files changed

+412
-101
lines changed

.github/workflows/main.yml

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
name: "CI"
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on:
6+
push:
7+
pull_request:
8+
branches: [master]
9+
10+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11+
jobs:
12+
13+
ubuntu-16-04_gcc-7-5_code-coverage:
14+
name: "Code coverage; Ubuntu 16.04, GCC-7.5"
15+
# The type of runner that the job will run on
16+
runs-on: ubuntu-16.04
17+
18+
# Steps represent a sequence of tasks that will be executed as part of the job
19+
steps:
20+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
21+
- uses: actions/checkout@v2
22+
23+
- name: Build and collect code coverage
24+
run: |
25+
cd build
26+
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 -DCOLLECT_CODE_COVERAGE=OTHER -DGCOV_PATH=gcov-7 ..
27+
cmake --build .
28+
ctest -C Debug --output-on-failure
29+
30+
- name: Upload code coverage
31+
run: |
32+
curl --output .codecov.sh https://codecov.io/bash
33+
bash ./.codecov.sh -Z -x 'gcov-7' || echo 'Codecov did not collect coverage reports'
34+
35+
ubuntu-latest_gcc-8-4_tests-debug:
36+
name: "Tests; Ubuntu latest, GCC-8.4, Debug"
37+
# The type of runner that the job will run on
38+
runs-on: ubuntu-latest
39+
40+
# Steps represent a sequence of tasks that will be executed as part of the job
41+
steps:
42+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
43+
- uses: actions/checkout@v2
44+
45+
- name: Build
46+
run: |
47+
cd build
48+
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ..
49+
cmake --build .
50+
51+
- name: Run tests
52+
run: |
53+
cd build
54+
ctest -C Debug --verbose
55+
56+
ubuntu-latest_gcc-9-3_tests-release:
57+
name: "Tests; Ubuntu latest, GCC-9.3, Release"
58+
# The type of runner that the job will run on
59+
runs-on: ubuntu-latest
60+
61+
# Steps represent a sequence of tasks that will be executed as part of the job
62+
steps:
63+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
64+
- uses: actions/checkout@v2
65+
66+
- name: Build
67+
run: |
68+
cd build
69+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9 ..
70+
cmake --build .
71+
72+
- name: Run tests
73+
run: |
74+
cd build
75+
ctest -C Release --verbose
76+
77+
ubuntu-latest_clang-8_tests-debug:
78+
name: "Tests; Ubuntu latest, Clang-8, Debug"
79+
# The type of runner that the job will run on
80+
runs-on: ubuntu-latest
81+
82+
# Steps represent a sequence of tasks that will be executed as part of the job
83+
steps:
84+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
85+
- uses: actions/checkout@v2
86+
87+
- name: Build
88+
run: |
89+
cd build
90+
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_COMPILER=clang++-8 ..
91+
cmake --build .
92+
93+
- name: Run tests
94+
run: |
95+
cd build
96+
ctest -C Debug --verbose
97+
98+
ubuntu-latest_clang-9_tests-release:
99+
name: "Tests; Ubuntu latest, Clang-9, Release"
100+
# The type of runner that the job will run on
101+
runs-on: ubuntu-latest
102+
103+
# Steps represent a sequence of tasks that will be executed as part of the job
104+
steps:
105+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
106+
- uses: actions/checkout@v2
107+
108+
- name: Build
109+
run: |
110+
cd build
111+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 ..
112+
cmake --build .
113+
114+
- name: Run tests
115+
run: |
116+
cd build
117+
ctest -C Release --verbose
118+
119+
macos-latest_clang_tests-release:
120+
name: "Tests; macOS latest, Clang, Release"
121+
# The type of runner that the job will run on
122+
runs-on: macos-latest
123+
124+
# Steps represent a sequence of tasks that will be executed as part of the job
125+
steps:
126+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
127+
- uses: actions/checkout@v2
128+
129+
- name: Build
130+
run: |
131+
cd build
132+
clang++ --version
133+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
134+
cmake --build .
135+
136+
- name: Run tests
137+
run: |
138+
cd build
139+
ctest -C Release --verbose
140+
141+
macos-latest_clang_tests-debug:
142+
name: "Tests; macOS latest, Clang, Debug"
143+
# The type of runner that the job will run on
144+
runs-on: macos-latest
145+
146+
# Steps represent a sequence of tasks that will be executed as part of the job
147+
steps:
148+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
149+
- uses: actions/checkout@v2
150+
151+
- name: Build
152+
run: |
153+
cd build
154+
clang++ --version
155+
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
156+
cmake --build .
157+
158+
- name: Run tests
159+
run: |
160+
cd build
161+
ctest -C Debug --verbose
162+
163+
windows-server-2016_msvs-2017_tests:
164+
name: "Tests; Windows Server 2016, MSVS 2017, Release+Debug"
165+
# The type of runner that the job will run on
166+
runs-on: windows-2016
167+
168+
# Steps represent a sequence of tasks that will be executed as part of the job
169+
steps:
170+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
171+
- uses: actions/checkout@v2
172+
173+
- name: Configure
174+
run: |
175+
cd build
176+
cmake ..
177+
178+
- name: Build (Debug)
179+
run: |
180+
cd build
181+
cmake --build . --config Debug
182+
183+
- name: Run tests (Debug)
184+
run: |
185+
cd build
186+
ctest -C Debug --verbose
187+
188+
- name: Build (Release)
189+
run: |
190+
cd build
191+
cmake --build . --config Release
192+
193+
- name: Run tests (Release)
194+
run: |
195+
cd build
196+
ctest -C Release --verbose
197+
198+
windows-server-2019_msvs-2019_tests:
199+
name: "Tests; Windows Server 2019, MSVS 2019, Release+Debug"
200+
# The type of runner that the job will run on
201+
runs-on: windows-2019
202+
203+
# Steps represent a sequence of tasks that will be executed as part of the job
204+
steps:
205+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
206+
- uses: actions/checkout@v2
207+
208+
- name: Configure
209+
run: |
210+
cd build
211+
cmake ..
212+
213+
- name: Build (Debug)
214+
run: |
215+
cd build
216+
cmake --build . --config Debug
217+
218+
- name: Run tests (Debug)
219+
run: |
220+
cd build
221+
ctest -C Debug --verbose
222+
223+
- name: Build (Release)
224+
run: |
225+
cd build
226+
cmake --build . --config Release
227+
228+
- name: Run tests (Release)
229+
run: |
230+
cd build
231+
ctest -C Release --verbose

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ set(cpp-stream_INCLUDE_DIR ${_cpp-stream_INCLUDE_DIR} PARENT_SCOPE)
1313

1414
include_directories(${_cpp-stream_INCLUDE_DIR})
1515

16+
# Enable testing for the project
17+
enable_testing()
1618
add_subdirectory(tests)
17-

README.md

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# cpp-stream
1+
# cpp-stream [![GitHub release (latest by date)](https://img.shields.io/github/v/release/NikitkoCent/cpp-stream)](https://github.com/NikitkoCent/cpp-stream/releases/latest) [![Actions Status](https://github.com/NikitkoCent/cpp-stream/workflows/CI/badge.svg)](https://github.com/NikitkoCent/cpp-stream/actions) [![codecov](https://codecov.io/gh/NikitkoCent/cpp-stream/branch/master/graph/badge.svg)](https://codecov.io/gh/NikitkoCent/cpp-stream) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
22
C++17-compatible imitation of [Java 8 Stream API](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html).
33
Elements are processed lazily and with minimum overhead.
44

@@ -35,7 +35,7 @@ int main()
3535
"food"
3636
};
3737

38-
// no copying or moving, string is stored via reference
38+
// no copying or moving, strings are stored via reference
3939
stream::Stream(strings)
4040
| ops::filter([](const char *str) { // select only strings started with 'F' or 'f'
4141
return (str[0] == 'f' || str[0] == 'F');
@@ -44,50 +44,54 @@ int main()
4444
(void)std::transform(str.begin(), str.end(), str.begin(), [](unsigned char ch) { return std::toupper(ch); });
4545
return str;
4646
}) // still nothing will be evaluated
47-
| ops::print_to(std::cout); // there is terminal operation - causes evaluating everything
47+
| ops::print_to(std::cout); // there is the terminal operation - causes evaluating everything
4848

4949
return 0;
5050
}
5151
```
5252
Output:
5353
> FRED'S FRIENDS FRIED FRITOS FOR FRIDAYS FOOD
5454
55-
## Supported terminal operations
56-
* `print_to(ostream)` - prints all elements of the stream to a given output stream `ostream`;
57-
* `reduce(identityFn, accumulatorFn)` - reduces all elements of the stream to 1 similar to the following pseudo-code:
58-
```cpp
59-
stream::Stream s(...);
60-
auto v = identityFn(s.getNext());
61-
while (!s.isEnd())
62-
v = accumulatorFn(v, s.getNext());
63-
return v;
64-
```
65-
* `reduce(accumulatorFn)` - reduces all elements of the stream to 1 similar to the following pseudo-code:
66-
```cpp
67-
stream::Stream s(...);
68-
auto v = s.getNext();
69-
while (!s.isEnd())
70-
v = accumulatorFn(v, s.getNext());
71-
return v;
72-
```
73-
* `nth(n)` - returns `n`th element of the stream;
74-
* `to_vector()` - moves all elements of the origin stream to a `std::vector`.
75-
76-
## Supported non terminal operations
77-
* `skip(n)` - skips n elements of the stream;
78-
* `get(n)` - takes only n first elements from the stream;
79-
* `map(mapFn)` - creates a new stream of results of applying the given functor `mapFn` to every element of the given stream;
80-
* `filter(predicateFn)` - leaves only elements to which applying `predicateFn` functor returns true;
81-
* `group(n)` - creates a new stream of `std::vector`s with `n` elements of the origin stream.
55+
## Features
56+
* Supported terminal operations:
57+
* `print_to(ostream)` - prints all elements of the stream to a given output stream `ostream`;
58+
* `reduce(identityFn, accumulatorFn)` - reduces all elements of the stream to 1 similar to the following pseudo-code:
59+
```cpp
60+
stream::Stream s(...);
61+
auto v = identityFn(s.getNext());
62+
while (!s.isEnd())
63+
v = accumulatorFn(v, s.getNext());
64+
return v;
65+
```
66+
* `reduce(accumulatorFn)` - reduces all elements of the stream to 1 similar to the following pseudo-code:
67+
```cpp
68+
stream::Stream s(...);
69+
auto v = s.getNext();
70+
while (!s.isEnd())
71+
v = accumulatorFn(v, s.getNext());
72+
return v;
73+
```
74+
* `nth(n)` - returns `n`th element of the stream;
75+
* `to_vector()` - moves all elements of the origin stream to a `std::vector`.
76+
77+
* Supported non terminal operations:
78+
* `skip(n)` - skips n elements of the stream;
79+
* `get(n)` - takes only n first elements from the stream;
80+
* `map(mapFn)` - creates a new stream of results of applying the given functor `mapFn` to every element of the given stream;
81+
* `filter(predicateFn)` - leaves only elements to which applying `predicateFn` functor returns true;
82+
* `group(n)` - creates a new stream of `std::vector`s with `n` elements of the origin stream.
8283

8384
## Requirements
8485
* Using the library:
85-
* C++17-compatible compiler and STL
86+
* C++17-compatible compiler and STL. Tested with:
87+
* `GCC 7.5`, `GCC 8.4`, `GCC 9.3`;
88+
* `Clang 8`, `Clang 9`;
89+
* `MSVC 19.16.27041.0 (MSVS 2017)`, `MSVC 19.26.28806.0 (MSVS 2019)`.
8690
* For running tests, you need:
8791
* [git](https://git-scm.com/downloads)
88-
* [CMake](https://cmake.org/download/) >= v3.1
92+
* [CMake](https://cmake.org/download/) >= v3.8.2
8993
* Additionally, if you want to measure code coverage, you need:
90-
* compiler,q
94+
* compiler,
9195
[gcov](https://en.wikipedia.org/wiki/Gcov)
9296
[, optional: [lcov](https://wiki.documentfoundation.org/Development/Lcov)]
9397
compatible with each other

include/stream/detail/stream_impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ namespace stream
282282
{
283283
return end | oldStream.isEnd();
284284
}
285-
286-
return end;
285+
else
286+
{
287+
return end;
288+
}
287289
}
288290
else
289291
{

0 commit comments

Comments
 (0)