From ce142df97104dd37a4d616f799b1f196a55a1730 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Fri, 6 Aug 2021 03:39:03 +0700 Subject: [PATCH] move to github actions --- .appveyor.yml | 28 ---------- .github/workflows/coverage.yml | 16 ++++++ .github/workflows/darwin.yml | 24 ++++++++ .github/workflows/linux.yml | 31 +++++++++++ .github/workflows/windows.yml | 23 ++++++++ .travis.yml | 89 ------------------------------ CMakeLists.txt | 10 ++++ README.md | 24 ++++---- headers/flat.hpp/flat_multimap.hpp | 6 +- headers/flat.hpp/flat_multiset.hpp | 6 +- untests/CMakeLists.txt | 9 ++- untests/doctest/doctest.hpp | 4 +- untests/flat_map_tests.cpp | 2 +- untests/flat_multimap_tests.cpp | 2 +- untests/flat_multiset_tests.cpp | 4 +- untests/flat_set_tests.cpp | 4 +- 16 files changed, 136 insertions(+), 146 deletions(-) delete mode 100644 .appveyor.yml create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/darwin.yml create mode 100644 .github/workflows/linux.yml create mode 100644 .github/workflows/windows.yml delete mode 100644 .travis.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 2130e34..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -image: - - Visual Studio 2017 - - Visual Studio 2019 - -platform: - - x86 - - x64 - -configuration: - - Release - -for: - -- - matrix: - only: - - platform: x86 - configuration: Release - build_script: - - .ci\build_windows_x86.bat - -- - matrix: - only: - - platform: x64 - configuration: Release - build_script: - - .ci\build_windows_x64.bat diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..09e95e1 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,16 @@ +name: coverage + +on: [push, pull_request] + +jobs: + build: + runs-on: macos-10.15 + name: "coverage" + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install lcov by Homebrew + run: brew install lcov + - name: Build && Test && Upload + run: .ci/build_coverage.sh diff --git a/.github/workflows/darwin.yml b/.github/workflows/darwin.yml new file mode 100644 index 0000000..07e86ea --- /dev/null +++ b/.github/workflows/darwin.yml @@ -0,0 +1,24 @@ +name: darwin + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: + # https://github.com/actions/virtual-environments/tree/main/images/macos + - { os: "macos-10.15", xcode: "10.3" } + - { os: "macos-10.15", xcode: "11.7" } + - { os: "macos-10.15", xcode: "12.4" } + name: "xcode-${{matrix.config.xcode}}" + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Select Xcode + run: sudo xcode-select --switch "/Applications/Xcode_${{matrix.config.xcode}}.app" + - name: Build && Test + run: .ci/build_darwin.sh diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..c785bc7 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,31 @@ +name: linux + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: + # https://github.com/actions/virtual-environments/tree/main/images/linux + - { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" } + - { os: "ubuntu-20.04", cc: "gcc-8", cxx: "g++-8" } + - { os: "ubuntu-20.04", cc: "gcc-9", cxx: "g++-9" } + - { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" } + - { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" } + - { os: "ubuntu-20.04", cc: "clang-8", cxx: "clang++-8" } + - { os: "ubuntu-20.04", cc: "clang-9", cxx: "clang++-9" } + - { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" } + name: "${{matrix.config.cxx}}" + steps: + - name: Setup + run: sudo apt-get -y install "${{matrix.config.cc}}" "${{matrix.config.cxx}}" + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Build && Test + run: .ci/build_linux.sh + env: { CC: "${{matrix.config.cc}}", CXX: "${{matrix.config.cxx}}" } diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..1486034 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,23 @@ +name: windows + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: + # https://github.com/actions/virtual-environments/tree/main/images/win + - { os: "windows-2016", vs: "Visual Studio 2017", arch: "x86" } + - { os: "windows-2016", vs: "Visual Studio 2017", arch: "x64" } + - { os: "windows-2019", vs: "Visual Studio 2019", arch: "x86" } + - { os: "windows-2019", vs: "Visual Studio 2019", arch: "x64" } + name: "${{matrix.config.vs}} ${{matrix.config.arch}}" + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Build && Test + run: .ci\build_windows_${{matrix.config.arch}}.bat diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 43462e1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,89 +0,0 @@ -git: - depth: false - quiet: true - -language: cpp - -jobs: - include: - - # - # linux (g++) - # - - - os: linux - dist: bionic - stage: linux - name: g++-7 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-7"] } } - env: CC=gcc-7 CXX=g++-7 - script: .ci/build_linux.sh - - - os: linux - dist: bionic - stage: linux - name: g++-8 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["g++-8"] } } - env: CC=gcc-8 CXX=g++-8 - script: .ci/build_linux.sh - - # - # linux (clang++) - # - - - os: linux - dist: bionic - stage: linux - name: clang++-5.0 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-5.0"] } } - env: CC=clang-5.0 CXX=clang++-5.0 - script: .ci/build_linux.sh - - - os: linux - dist: bionic - stage: linux - name: clang++-6.0 - addons: { apt: { sources: ["ubuntu-toolchain-r-test"], packages: ["clang-6.0"] } } - env: CC=clang-6.0 CXX=clang++-6.0 - script: .ci/build_linux.sh - - # - # darwin - # - - - os: osx - osx_image: xcode10 - stage: darwin - name: xcode10 - script: .ci/build_darwin.sh - - - os: osx - osx_image: xcode11 - stage: darwin - name: xcode11 - script: .ci/build_darwin.sh - - # - # windows - # - - - os: windows - stage: windows - name: x86 - script: .ci/build_windows_x86.bat - - - os: windows - stage: windows - name: x64 - script: .ci/build_windows_x64.bat - - # - # coverage - # - - - os: osx - osx_image: xcode10 - stage: coverage - name: coverage - addons: { homebrew: { packages: ["lcov"], update: true } } - script: .ci/build_coverage.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 479acc3..5368d8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.8 FATAL_ERROR) if(NOT DEFINED PROJECT_NAME) set(BUILD_AS_STANDALONE ON) +else() + set(BUILD_AS_STANDALONE OFF) endif() project(flat.hpp) @@ -11,6 +13,14 @@ add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE headers) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) +target_compile_options(${PROJECT_NAME} + INTERFACE + $<$,$>: + -Wno-c++98-compat-pedantic + -Wno-padded + -Wno-shadow + -Wno-unknown-warning-option>) + if(BUILD_AS_STANDALONE) option(BUILD_WITH_UNBENCH "Build with benchmarks" OFF) if(BUILD_WITH_UNBENCH) diff --git a/README.md b/README.md index 8a288cc..b9969b3 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,26 @@ > Library of flat vector-like based associative containers -[![travis][badge.travis]][travis] -[![appveyor][badge.appveyor]][appveyor] +[![linux][badge.linux]][linux] +[![darwin][badge.darwin]][darwin] +[![windows][badge.windows]][windows] [![codecov][badge.codecov]][codecov] [![language][badge.language]][language] [![license][badge.license]][license] -[![paypal][badge.paypal]][paypal] -[badge.travis]: https://img.shields.io/travis/BlackMATov/flat.hpp/main.svg?logo=travis -[badge.appveyor]: https://img.shields.io/appveyor/ci/BlackMATov/flat-hpp/main.svg?logo=appveyor -[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/flat.hpp/main.svg?logo=codecov -[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow.svg -[badge.license]: https://img.shields.io/badge/license-MIT-blue.svg -[badge.paypal]: https://img.shields.io/badge/donate-PayPal-orange.svg?logo=paypal&colorA=00457C +[badge.darwin]: https://img.shields.io/github/workflow/status/BlackMATov/flat.hpp/darwin/main?label=Xcode&logo=xcode +[badge.linux]: https://img.shields.io/github/workflow/status/BlackMATov/flat.hpp/linux/main?label=GCC%2FClang&logo=linux +[badge.windows]: https://img.shields.io/github/workflow/status/BlackMATov/flat.hpp/windows/main?label=Visual%20Studio&logo=visual-studio +[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/flat.hpp/main?logo=codecov +[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow +[badge.license]: https://img.shields.io/badge/license-MIT-blue -[travis]: https://travis-ci.org/BlackMATov/flat.hpp -[appveyor]: https://ci.appveyor.com/project/BlackMATov/flat-hpp +[darwin]: https://github.com/BlackMATov/flat.hpp/actions?query=workflow%3Adarwin +[linux]: https://github.com/BlackMATov/flat.hpp/actions?query=workflow%3Alinux +[windows]: https://github.com/BlackMATov/flat.hpp/actions?query=workflow%3Awindows [codecov]: https://codecov.io/gh/BlackMATov/flat.hpp [language]: https://en.wikipedia.org/wiki/C%2B%2B17 [license]: https://en.wikipedia.org/wiki/MIT_License -[paypal]: https://www.paypal.me/matov [flat]: https://github.com/BlackMATov/flat.hpp diff --git a/headers/flat.hpp/flat_multimap.hpp b/headers/flat.hpp/flat_multimap.hpp index f9fdb3c..3c12a60 100644 --- a/headers/flat.hpp/flat_multimap.hpp +++ b/headers/flat.hpp/flat_multimap.hpp @@ -392,7 +392,7 @@ namespace flat_hpp size_type erase(const key_type& key) { const auto p = equal_range(key); - size_type r = std::distance(p.first, p.second); + size_type r = static_cast(std::distance(p.first, p.second)); erase(p.first, p.second); return r; } @@ -410,7 +410,7 @@ namespace flat_hpp size_type count(const key_type& key) const { const auto p = equal_range(key); - return std::distance(p.first, p.second); + return static_cast(std::distance(p.first, p.second)); } template < typename K > @@ -419,7 +419,7 @@ namespace flat_hpp size_type> count(const K& key) const { const auto p = equal_range(key); - return std::distance(p.first, p.second); + return static_cast(std::distance(p.first, p.second)); } iterator find(const key_type& key) { diff --git a/headers/flat.hpp/flat_multiset.hpp b/headers/flat.hpp/flat_multiset.hpp index 0b232ab..91aa81f 100644 --- a/headers/flat.hpp/flat_multiset.hpp +++ b/headers/flat.hpp/flat_multiset.hpp @@ -320,7 +320,7 @@ namespace flat_hpp size_type erase(const key_type& key) { const auto p = equal_range(key); - size_type r = std::distance(p.first, p.second); + size_type r = static_cast(std::distance(p.first, p.second)); erase(p.first, p.second); return r; } @@ -338,7 +338,7 @@ namespace flat_hpp size_type count(const key_type& key) const { const auto p = equal_range(key); - return std::distance(p.first, p.second); + return static_cast(std::distance(p.first, p.second)); } template < typename K > @@ -347,7 +347,7 @@ namespace flat_hpp size_type> count(const K& key) const { const auto p = equal_range(key); - return std::distance(p.first, p.second); + return static_cast(std::distance(p.first, p.second)); } iterator find(const key_type& key) { diff --git a/untests/CMakeLists.txt b/untests/CMakeLists.txt index 609eda6..6e78f6d 100644 --- a/untests/CMakeLists.txt +++ b/untests/CMakeLists.txt @@ -23,9 +23,12 @@ target_link_libraries(${PROJECT_NAME} flat.hpp) target_compile_options(${PROJECT_NAME} PRIVATE $<$: - /W4> + /WX /W4> PRIVATE - $<$,$,$>: - -Wall -Wextra -Wpedantic>) + $<$: + -Werror -Wall -Wextra -Wpedantic> + PRIVATE + $<$,$>: + -Werror -Weverything -Wconversion>) add_test(${PROJECT_NAME} ${PROJECT_NAME}) diff --git a/untests/doctest/doctest.hpp b/untests/doctest/doctest.hpp index c1fc7ee..cf95de5 100644 --- a/untests/doctest/doctest.hpp +++ b/untests/doctest/doctest.hpp @@ -4,8 +4,8 @@ #define STATIC_REQUIRE(...)\ static_assert(__VA_ARGS__, #__VA_ARGS__);\ - REQUIRE(__VA_ARGS__); + REQUIRE(__VA_ARGS__) #define STATIC_REQUIRE_FALSE(...)\ static_assert(!(__VA_ARGS__), "!(" #__VA_ARGS__ ")");\ - REQUIRE(!(__VA_ARGS__)); + REQUIRE(!(__VA_ARGS__)) diff --git a/untests/flat_map_tests.cpp b/untests/flat_map_tests.cpp index 8b5b9ad..79c537f 100644 --- a/untests/flat_map_tests.cpp +++ b/untests/flat_map_tests.cpp @@ -36,7 +36,7 @@ namespace }; template < typename T > - void swap(dummy_less2&, dummy_less2&) noexcept { + [[maybe_unused]] void swap(dummy_less2&, dummy_less2&) noexcept { } template < typename T > diff --git a/untests/flat_multimap_tests.cpp b/untests/flat_multimap_tests.cpp index 038559d..c2fc4b7 100644 --- a/untests/flat_multimap_tests.cpp +++ b/untests/flat_multimap_tests.cpp @@ -36,7 +36,7 @@ namespace }; template < typename T > - void swap(dummy_less2&, dummy_less2&) noexcept { + [[maybe_unused]] void swap(dummy_less2&, dummy_less2&) noexcept { } template < typename T > diff --git a/untests/flat_multiset_tests.cpp b/untests/flat_multiset_tests.cpp index cb9471d..aa477e2 100644 --- a/untests/flat_multiset_tests.cpp +++ b/untests/flat_multiset_tests.cpp @@ -36,7 +36,7 @@ namespace }; template < typename T > - void swap(dummy_less2&, dummy_less2&) noexcept { + [[maybe_unused]] void swap(dummy_less2&, dummy_less2&) noexcept { } template < typename T > @@ -511,7 +511,7 @@ TEST_CASE("flat_multiset") { struct my_less { int i; my_less(int i) : i(i) {} - bool operator()(int l, int r) const { + [[maybe_unused]] bool operator()(int l, int r) const { return l < r; } }; diff --git a/untests/flat_set_tests.cpp b/untests/flat_set_tests.cpp index 32fd4db..843f3b2 100644 --- a/untests/flat_set_tests.cpp +++ b/untests/flat_set_tests.cpp @@ -36,7 +36,7 @@ namespace }; template < typename T > - void swap(dummy_less2&, dummy_less2&) noexcept { + [[maybe_unused]] void swap(dummy_less2&, dummy_less2&) noexcept { } template < typename T > @@ -509,7 +509,7 @@ TEST_CASE("flat_set") { struct my_less { int i; my_less(int i) : i(i) {} - bool operator()(int l, int r) const { + [[maybe_unused]] bool operator()(int l, int r) const { return l < r; } };