Skip to content

Commit

Permalink
Merge pull request #73 from spotify/sandordargo-patch-1
Browse files Browse the repository at this point in the history
Replace broken pipelines with Github workflows
  • Loading branch information
sandordargo authored Nov 5, 2024
2 parents 00c9b6b + 51c1525 commit e7f02fc
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 89 deletions.
20 changes: 0 additions & 20 deletions .appveyor/build.cmd

This file was deleted.

15 changes: 0 additions & 15 deletions .appveyor/install.cmd

This file was deleted.

13 changes: 0 additions & 13 deletions .appveyor/test.cmd

This file was deleted.

132 changes: 132 additions & 0 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: C++ build and test

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

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

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Release, Debug]

steps:
- uses: actions/checkout@v4

- name: Install Boost (Linux)
if: matrix.os == 'ubuntu-latest'
id: boost
shell: bash
run: sudo apt-get install libboost-all-dev

- name: Install Boost (MacOs)
if: matrix.os == 'macos-latest'
id: boost-macos
shell: bash
run: |
brew install boost
export BOOST_ROOT=$(brew --prefix boost)
echo "boost-root-dir=$BOOST_ROOT" >> "$GITHUB_OUTPUT"
- name: Install vcpkg
if: matrix.os == 'windows-latest'
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git checkout master # Use a specific version if needed
./bootstrap-vcpkg.bat
- name: Install Boost (Windows)
if: matrix.os == 'windows-latest'
run: |
cd vcpkg
.\vcpkg.exe install boost-algorithm boost-assert boost-test boost-system boost-chrono boost-container --triplet x64-windows
- name: Set build directory
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake (Linux)
if: matrix.os == 'ubuntu-latest'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_PREFIX_PATH="${{ steps.boost.outputs.boost-root-dir }}"
-DBOOST_ROOT="${{ steps.boost.outputs.boost-root-dir }}"
-DBoost_DIR="${{ steps.boost.outputs.boost-root-dir }}"
-DBoost_NO_BOOST_CMAKE=ON
-DBoost_NO_SYSTEM_PATHS=ON
-DBoost_USE_STATIC_LIBS=OFF
-DBoost_USE_STATIC_RUNTIME=OFF
-DSPOTIFY_JSON_USE_SSE42=OFF
-S ${{ github.workspace }}
- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake
-DBOOST_ROOT="./vcpkg/installed/x64-windows"
-DBoost_NO_SYSTEM_PATHS=ON
-DBoost_LIBRARY_DIRS="${{ github.workspace }}\vcpkg\installed\x64-windows\lib"
-DBoost_INCLUDE_DIR="${{ github.workspace }}\vcpkg\installed\x64-windows\include"
-DBoost_USE_STATIC_LIBS=OFF
-DSPOTIFY_JSON_USE_SSE42=OFF
-S ${{ github.workspace }}
- name: Configure CMake (MacOs)
if: matrix.os == 'macos-latest'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_PREFIX_PATH="/opt/homebrew/opt/boost"
-DBOOST_ROOT="/opt/homebrew/opt/boost"
-DBoost_NO_BOOST_CMAKE=ON
-DBOOST_LIBRARYDIR="/opt/homebrew/opt/boost/lib"
-DBoost_USE_STATIC_LIBS=OFF
-DBoost_USE_STATIC_RUNTIME=OFF
-S ${{ github.workspace }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test (Linux / MacOS)
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest'
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config ${{ matrix.build_type }} --rerun-failed --output-on-failure

- name: Test (Windows Release)
if: matrix.os == 'windows-latest' && matrix.build_type == 'Release'
working-directory: ${{ steps.strings.outputs.build-output-dir }}
shell: pwsh
run: |
$env:PATH += ";${{ github.workspace }}\vcpkg\installed\x64-windows\bin"
ctest --build-config ${{ matrix.build_type }} --rerun-failed --output-on-failure -V
# Skipped due to timeout issues after all the tests succeeded
# - name: Test (Windows Debug)
# if: matrix.os == 'windows-latest' && matrix.build_type == 'Debug'
# working-directory: ${{ steps.strings.outputs.build-output-dir }}
# shell: pwsh
# run: |
# $env:PATH += ";${{ github.workspace }}\vcpkg\installed\x64-windows\debug\bin"
# ctest --build-config ${{ matrix.build_type }} --output-on-failure -V --timeout 300

- name: Install valgrind (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: sudo apt-get install -qq valgrind

- name: Run valgrind test (Linux)
if: matrix.os == 'ubuntu-latest'
working-directory: ${{ steps.strings.outputs.build-output-dir }}
shell: bash
run: valgrind --leak-check=full ./test/spotify_json_test
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@
# License for the specific language governing permissions and limitations under
# the License.

cmake_minimum_required(VERSION 3.15.0)
cmake_minimum_required(VERSION 3.21.0)
project(spotify-json)

# Set policy for CMP0144 to enable upper-case BOOST_ROOT usage
if (POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()

# Set policy for CMP0167 to rely on BoostConfig.cmake rather than FindBoost
if (POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down Expand Up @@ -139,6 +149,7 @@ if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "
endif()

if(WIN32)
message(STATUS "Building on Windows")
target_compile_options(${json_library_TARGET} PRIVATE "/MT$<$<CONFIG:Debug>:d>")
endif()

Expand Down Expand Up @@ -174,10 +185,6 @@ target_link_libraries(${json_library_TARGET} double-conversion)

option(SPOTIFY_JSON_BUILD_TESTS "Build tests and benchmarks" ON)
if(SPOTIFY_JSON_BUILD_TESTS)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)

find_package(Boost COMPONENTS chrono unit_test_framework system)

if(Boost_FOUND)
Expand Down
36 changes: 0 additions & 36 deletions appveyor.yml

This file was deleted.

0 comments on commit e7f02fc

Please sign in to comment.