From 7d3c1d100ea38605bf5d11459f5a678be99fffab Mon Sep 17 00:00:00 2001 From: wb2osz Date: Wed, 23 Mar 2022 18:38:53 -0400 Subject: [PATCH 1/6] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 73 +++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..7134f213 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,73 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ dev ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ dev ] + schedule: + - cron: '25 8 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + - run: | + mkdir build + cd build + cmake -DUNITTEST=1 .. + make + make test + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From 9fd7bf2ee0e6bafbb315d30f2259797de8fd687a Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Thu, 8 Apr 2021 13:09:15 +0200 Subject: [PATCH 2/6] cmake: add support for Visual Studio 2019 --- CMakeLists.txt | 4 ++-- cmake/modules/FindCompiler.cmake | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e710f52..5ed36eab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,8 +157,8 @@ elseif(APPLE) message(STATUS "RPATH support: ${CMAKE_MACOSX_RPATH}") elseif (WIN32) - if(NOT VS2015 AND NOT VS2017) - message(FATAL_ERROR "You must use Microsoft Visual Studio 2015 or 2017 as compiler") + if(NOT VS2015 AND NOT VS2017 AND NOT VS2019) + message(FATAL_ERROR "You must use Microsoft Visual Studio 2015, 2017 or 2019 as compiler") endif() # compile with full multicore diff --git a/cmake/modules/FindCompiler.cmake b/cmake/modules/FindCompiler.cmake index f339a73e..fe036e4b 100644 --- a/cmake/modules/FindCompiler.cmake +++ b/cmake/modules/FindCompiler.cmake @@ -5,7 +5,9 @@ elseif(NOT DEFINED C_GCC AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(C_GCC 1) elseif(NOT DEFINED C_MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(C_MSVC 1) - if(MSVC_VERSION GREATER 1910 AND MSVC_VERSION LESS 1919) + if(MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS_EQUAL 1929) + set(VS2019 ON) + elseif(MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS_EQUAL 1919) set(VS2017 ON) elseif(MSVC_VERSION GREATER 1899 AND MSVC_VERSION LESS 1910) set(VS2015 ON) From 10c688e9d40ab0e1f9bfa6c9a311995d6f44b868 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Thu, 8 Apr 2021 08:41:57 +0200 Subject: [PATCH 3/6] enable github actions (aka continuous integration) basic implementation to enable github actions with: - triggered each push or pull request - built on ubuntu (multiple version), macOS, windows - the binary has debug facilities enabled - ignore any commit/push on the .github folder - run all tests - create an archive with binaries (available for 90 days) - can manually triggered setting custom cmake flags --- .github/workflows/ci.yml | 172 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..9568ccdf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,172 @@ +name: 'build direwolf' + +on: + # permit to manually trigger the CI + workflow_dispatch: + inputs: + cmake_flags: + description: 'Custom CMAKE flags' + required: false + push: + paths-ignore: + - '.github/**' + pull_request: + paths-ignore: + - '.github/**' + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Windows Latest MinGW 64bit', + os: windows-latest, + cc: 'x86_64-w64-mingw32-gcc', + cxx: 'x86_64-w64-mingw32-g++', + ar: 'x86_64-w64-mingw32-ar', + windres: 'x86_64-w64-mingw32-windres', + arch: 'x86_64', + build_type: 'Release', + cmake_extra_flags: '-G "MinGW Makefiles"' + } + - { + name: 'Windows Latest MinGW 32bit', + os: windows-latest, + cc: 'i686-w64-mingw32-gcc', + cxx: 'i686-w64-mingw32-g++', + ar: 'i686-w64-mingw32-ar', + windres: 'i686-w64-mingw32-windres', + arch: 'i686', + build_type: 'Release', + cmake_extra_flags: '-G "MinGW Makefiles"' + } + - { + name: 'macOS latest', + os: macos-latest, + cc: 'clang', + cxx: 'clang++', + arch: 'x86_64', + build_type: 'Release', + cmake_extra_flags: '' + } + - { + name: 'Ubuntu latest Debug', + os: ubuntu-latest, + cc: 'gcc', + cxx: 'g++', + arch: 'x86_64', + build_type: 'Debug', + cmake_extra_flags: '' + } + - { + name: 'Ubuntu 20.04', + os: ubuntu-20.04, + cc: 'gcc', + cxx: 'g++', + arch: 'x86_64', + build_type: 'Release', + cmake_extra_flags: '' + } + - { + name: 'Ubuntu 18.04', + os: ubuntu-18.04, + cc: 'gcc', + cxx: 'g++', + arch: 'x86_64', + build_type: 'Release', + cmake_extra_flags: '' + } + - { + name: 'Ubuntu 16.04', + os: ubuntu-16.04, + cc: 'gcc', + cxx: 'g++', + arch: 'x86_64', + build_type: 'Release', + cmake_extra_flags: '' + } + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 8 + - name: dependency + shell: bash + run: | + # this is not perfect but enought for now + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get update + sudo apt-get install libasound2-dev libudev-dev libhamlib-dev gpsd + elif [ "$RUNNER_OS" == "macOS" ]; then + # just to simplify I use homebrew but + # we can use macports (latest direwolf is already available as port) + brew install portaudio hamlib gpsd + elif [ "$RUNNER_OS" == "Windows" ]; then + # add the folder to PATH + echo "C:\msys64\mingw32\bin" >> $GITHUB_PATH + fi + - name: create build environment + run: | + cmake -E make_directory ${{github.workspace}}/build + - name: configure + shell: bash + working-directory: ${{github.workspace}}/build + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + export CC=${{ matrix.config.cc }} + export CXX=${{ matrix.config.cxx }} + export AR=${{ matrix.config.ar }} + export WINDRES=${{ matrix.config.windres }} + fi + cmake $GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ + -DCMAKE_C_COMPILER=${{ matrix.config.cc }} \ + -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \ + -DCMAKE_CXX_FLAGS="-Werror" -DUNITTEST=1 \ + ${{ matrix.config.cmake_extra_flags }} \ + ${{ github.event.inputs.cmake_flags }} + - name: build + shell: bash + working-directory: ${{github.workspace}}/build + run: | + if [ "$RUNNER_OS" == "Windows" ]; then + export CC=${{ matrix.config.cc }} + export CXX=${{ matrix.config.cxx }} + export AR=${{ matrix.config.ar }} + export WINDRES=${{ matrix.config.windres }} + fi + cmake --build . --config ${{ matrix.config.build_type }} \ + ${{ matrix.config.cmake_extra_flags }} \ + ${{ github.event.inputs.cmake_flags }} + - name: test + continue-on-error: true + shell: bash + working-directory: ${{github.workspace}}/build + run: | + ctest -C ${{ matrix.config.build_type }} \ + --parallel 2 --output-on-failure \ + ${{ matrix.config.cmake_extra_flags }} \ + ${{ github.event.inputs.cmake_flags }} + - name: package + shell: bash + working-directory: ${{github.workspace}}/build + run: | + if [ "$RUNNER_OS" == "Windows" ] || [ "$RUNNER_OS" == "macOS" ]; then + make package + fi + - name: archive binary + uses: actions/upload-artifact@v2 + with: + name: direwolf_${{ matrix.config.os }}_${{ matrix.config.arch }}_${{ github.sha }} + path: | + ${{github.workspace}}/build/direwolf-*.zip + ${{github.workspace}}/build/direwolf.conf + ${{github.workspace}}/build/src/* + ${{github.workspace}}/build/CMakeCache.txt + !${{github.workspace}}/build/src/cmake_install.cmake + !${{github.workspace}}/build/src/CMakeFiles + !${{github.workspace}}/build/src/Makefile From 9dd42833448fbbc6cc650a05537baa3a8d526555 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Fri, 16 Apr 2021 14:57:16 +0200 Subject: [PATCH 4/6] cmake: fix MSVC check --- CMakeLists.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ed36eab..f1c33be8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,15 +157,16 @@ elseif(APPLE) message(STATUS "RPATH support: ${CMAKE_MACOSX_RPATH}") elseif (WIN32) - if(NOT VS2015 AND NOT VS2017 AND NOT VS2019) - message(FATAL_ERROR "You must use Microsoft Visual Studio 2015, 2017 or 2019 as compiler") + if(C_MSVC) + if (NOT VS2015 AND NOT VS2017 AND NOT VS2019) + message(FATAL_ERROR "You must use Microsoft Visual Studio 2015, 2017 or 2019 as compiler") + else() + # compile with full multicore + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CUSTOM_SHELL_BIN "") + endif() endif() - - # compile with full multicore - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") - - set(CUSTOM_SHELL_BIN "") endif() if (C_CLANG OR C_GCC) From b42ad1001bef0d532446633774a9380763a9134d Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Thu, 26 May 2022 07:37:13 +0200 Subject: [PATCH 5/6] github actions: remove ubuntu 18.04; add ubuntu 22.04 --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9568ccdf..95254bfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,8 +63,8 @@ jobs: cmake_extra_flags: '' } - { - name: 'Ubuntu 20.04', - os: ubuntu-20.04, + name: 'Ubuntu 22.04', + os: ubuntu-22.04, cc: 'gcc', cxx: 'g++', arch: 'x86_64', @@ -72,8 +72,8 @@ jobs: cmake_extra_flags: '' } - { - name: 'Ubuntu 18.04', - os: ubuntu-18.04, + name: 'Ubuntu 20.04', + os: ubuntu-20.04, cc: 'gcc', cxx: 'g++', arch: 'x86_64', @@ -81,8 +81,8 @@ jobs: cmake_extra_flags: '' } - { - name: 'Ubuntu 16.04', - os: ubuntu-16.04, + name: 'Ubuntu 18.04', + os: ubuntu-18.04, cc: 'gcc', cxx: 'g++', arch: 'x86_64', From 2a2872d8853014fe6fc2060b2e1883d909633412 Mon Sep 17 00:00:00 2001 From: Davide Gerhard Date: Thu, 26 May 2022 07:46:22 +0200 Subject: [PATCH 6/6] github actions: fix windows ci --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95254bfb..82c129b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,8 @@ jobs: cmake_extra_flags: '-G "MinGW Makefiles"' } - { - name: 'Windows Latest MinGW 32bit', - os: windows-latest, + name: 'Windows 2019 MinGW 32bit', + os: windows-2019, cc: 'i686-w64-mingw32-gcc', cxx: 'i686-w64-mingw32-g++', ar: 'i686-w64-mingw32-ar', @@ -140,7 +140,6 @@ jobs: export WINDRES=${{ matrix.config.windres }} fi cmake --build . --config ${{ matrix.config.build_type }} \ - ${{ matrix.config.cmake_extra_flags }} \ ${{ github.event.inputs.cmake_flags }} - name: test continue-on-error: true @@ -149,7 +148,6 @@ jobs: run: | ctest -C ${{ matrix.config.build_type }} \ --parallel 2 --output-on-failure \ - ${{ matrix.config.cmake_extra_flags }} \ ${{ github.event.inputs.cmake_flags }} - name: package shell: bash