Skip to content

Commit

Permalink
feat: add github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
acking-you committed Nov 30, 2023
1 parent 8e93b80 commit 02b7ab4
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CMake Build Matrix

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
BUILD_TYPE: Release
BUILD_DIR: ${{ github.workspace }}/build

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}

strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows Latest",
os: "windows-latest",
cc: "cl",
cxx: "cl",
}
- {
name: "Ubuntu 22.04 GCC",
os: "ubuntu-22.04",
cc: "gcc",
cxx: "g++",
}
- {
name: "Ubuntu 22.04 Clang",
os: "ubuntu-22.04",
cc: "clang-14",
cxx: "clang++-14",
}
- {
name: "MacOS Latest",
os: "macos-latest",
cc: "clang",
cxx: "clang++",
}
steps:
- uses: actions/checkout@v3

- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
echo github.event_name: ${{ github.event_name }}
- name: Configure CMake
run: >
cmake -B ${{ env.BUILD_DIR }}
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }}
-DCMAKE_C_COMPILER=${{ matrix.config.cc }}
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
-DBUILD_TEST=ON
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ env.BUILD_DIR }} --config ${{env.BUILD_TYPE}}

- name: Check Tests
working-directory: ${{ env.BUILD_DIR }}
run: ctest --build-config ${{ env.BUILD_TYPE }} --rerun-failed --output-on-failure
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
cmake-*

.DS_Store
build
build-*
log
*.log
.idea
log.txt
.vscode

.vs
gh-md-toc.exe
gh-md-toc
auto_clean.sh
5 changes: 3 additions & 2 deletions tests/encode_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include <string>

TEST_SUITE_BEGIN("encode_util");
TEST_CASE("In Unix") { CHECK_EQ(1, 1); }
#ifdef _WIN32
using namespace netpoll;
TEST_SUITE_BEGIN("encode_util");
TEST_CASE("test fromUtf8&toUtf8")
{
const char* u8chars = u8"你好世界";
Expand All @@ -31,5 +32,5 @@ TEST_CASE("test fromNativePath&toNativePath")
CHECK_EQ(windowsNativePath, netpoll::utils::toNativePath(windowsNetPath));
}
}
#endif
TEST_SUITE_END;
#endif
3 changes: 3 additions & 0 deletions tests/lock_free_queue_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <netpoll/util/lockfree_queue.h>

#include <functional>
#include <iostream>
#include <mutex>
#include <string>
#include <thread>
Expand Down Expand Up @@ -71,10 +72,12 @@ TEST_CASE("bench thread-safe queue push in 10 therads")
{
{
Timer tm;
std::cout << "push mutex: ";
push_mutex();
}
{
Timer tm;
std::cout << "push lockfree: ";
push_lockfree();
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/message_buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TEST_CASE("test MessageBuffer")
CHECK_EQ(messageBuffer.readableBytes(), 3);
CHECK_EQ(StringView{messageBuffer.peek(), 3}, "abc");
MessageBuffer buf = std::move(messageBuffer);
CHECK_EQ(messageBuffer.readableBytes(), 0);
CHECK_EQ(messageBuffer.readableBytes(), 0); // NOLINT
CHECK_EQ(buf.readableBytes(), 3);
CHECK_EQ(StringView{buf.peek(), 3}, "abc");
MessageBuffer bufCopy = buf;
Expand Down

0 comments on commit 02b7ab4

Please sign in to comment.