diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 8bf9a87e..66cf8213 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -7,30 +7,31 @@ on: jobs: build_job: - runs-on: ubuntu-22.04 - name: Build on ${{ matrix.target.arch }} / ${{ matrix.target.distro }} / ${{ matrix.config.name }} / date-polyfill ${{ matrix.target.date-polyfill}} + runs-on: ubuntu-24.04 + name: Build on ${{ matrix.target.arch }} / ${{ matrix.config.name }} / date-polyfill ${{ matrix.target.date-polyfill}} strategy: matrix: target: - - { arch: armv6, distro: alpine_latest, date-polyfill: 'ON' } - - { arch: armv7, distro: alpine_latest, date-polyfill: 'ON' } - - { arch: aarch64, distro: alpine_latest, date-polyfill: 'ON' } - - { arch: aarch64, distro: alpine_latest, date-polyfill: 'OFF' } - - { arch: riscv64, distro: alpine_latest, date-polyfill: 'ON' } - - { arch: s390x, distro: alpine_latest, date-polyfill: 'ON' } - - { arch: s390x, distro: alpine_latest, date-polyfill: 'OFF' } - - { arch: ppc64le, distro: alpine_latest, date-polyfill: 'ON' } - - { arch: ppc64le, distro: alpine_latest, date-polyfill: 'OFF' } + # - { arch: armv7, date-polyfill: 'ON' } + - { arch: aarch64, date-polyfill: 'ON' } + - { arch: aarch64, date-polyfill: 'OFF'} + - { arch: riscv64, date-polyfill: 'ON' } + - { arch: s390x, date-polyfill: 'ON' } + - { arch: s390x, date-polyfill: 'OFF' } + - { arch: ppc64le, date-polyfill: 'ON' } + - { arch: ppc64le, date-polyfill: 'OFF' } config: - { name: Debug } - { name: Release } - + steps: - - name: Checkout code - uses: actions/checkout@v4 - + - name: Install binfmt-support + run: | + sudo apt-get update + sudo apt-get install binfmt-support + - name: Get current date id: date uses: Kaven-Universe/github-action-current-date-time@v1 @@ -40,89 +41,81 @@ jobs: - name: Cache builds uses: actions/cache@v4 with: - key: ${{matrix.target.arch}}_${{matrix.target.distro}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache-${{ steps.date.outputs.time }} - path: ccache_cache + key: ${{matrix.target.arch}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache-${{ steps.date.outputs.time }} + path: ${{ github.workspace }}/.ccache restore-keys: | - ${{matrix.target.arch}}_${{matrix.target.distro}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache- + ${{matrix.target.arch}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache- - - uses: uraimo/run-on-arch-action@v2 - name: Build artifact - id: build + - name: Set up Alpine Linux for ${{ matrix.target.arch }} + uses: jirutka/setup-alpine@v1 + id: alpine-target with: - arch: ${{matrix.target.arch}} - distro: ${{matrix.target.distro}} + branch: v3.20 + arch: ${{ matrix.target.arch }} + packages: > + ccache + cmake + date-dev + doctest-dev + g++ + git + linux-headers + make + musl-dev + samurai + tzdata + shell-name: alpine.sh + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Configuring sparrow + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: cmake -G Ninja -Bbuild + -DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} + -DUSE_DATE_POLYFILL=${{matrix.target.date-polyfill}} + -DBUILD_TESTS:BOOL=ON + -DBUILD_EXAMPLES:BOOL=ON + -DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache + -DCMAKE_C_COMPILER_LAUNCHER=ccache + -B build - # Not required, but speeds up builds - githubToken: ${{github.token}} + shell: alpine.sh {0} - setup: | - mkdir -p "${PWD}/artifacts" - mkdir -p "${PWD}/ccache_cache" + - name: Building sparrow library + run: cmake --build build --config ${{matrix.config.name}} --target sparrow + shell: alpine.sh {0} - # Mount the artifacts directory as /artifacts - # Mount the ccache_cache directory as /ccache_cache - dockerRunArgs: | - --volume "${PWD}/artifacts:/artifacts" --volume "${PWD}/ccache_cache:/ccache_cache" + - name: Building sparrow tests + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: cmake --build build --config ${{matrix.config.name}} --target test_sparrow_lib + shell: alpine.sh {0} - # The shell to run commands with in the container - shell: /bin/sh + - name: Running sparrow examples + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: cmake --build build --config ${{matrix.config.name}} --target run_examples + shell: alpine.sh {0} - # Install some dependencies in the container. This speeds up builds if - # you are also using githubToken. Any dependencies installed here will - # be part of the container image that gets cached, so subsequent - # builds don't have to re-install them. The image layer is cached - # publicly in your project's package repository, so it is vital that - # no secrets are present in the container state or logs. - install: | - case "${{matrix.target.distro}}" in - ubuntu*|bookworm) - apt-get update -q -y - apt-get install -q -y git cmake make doctest-dev libhowardhinnant-date-dev tzdata g++ ninja-build build-essential ccache - ;; - fedora*) - dnf -y update - dnf -y groupinstall "Development Tools" - dnf -y install git which cmake make doctest-devel date date-devel tzdata gcc-c++ ninja-build ccache - ;; - alpine*) - apk update - apk add git cmake make doctest-dev date-dev tzdata g++ samurai ccache linux-headers musl-dev - ;; - esac + - name: Running sparrow tests + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: cmake --build build --config ${{matrix.config.name}} --target run_tests_with_junit_report + shell: alpine.sh {0} - run: | - CCACHE_DIR=/ccache_cache - export CCACHE_DIR - export CCACHE_MAXSIZE=1G - CC=gcc - export CC - CXX=g++ - export CXX - echo "Configuring sparrow" - cmake -G Ninja -Bbuild \ - -DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} \ - -DUSE_DATE_POLYFILL=${{matrix.target.date-polyfill}} \ - -DBUILD_TESTS=ON \ - -DBUILD_EXAMPLES=ON \ - -DUSE_LARGE_INT_PLACEHOLDERS=ON \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING - cd build - echo "Building sparrow library" - cmake --build . --config ${{matrix.config.name}} --target sparrow - echo "Building sparrow tests" - cmake --build . --config ${{matrix.config.name}} --target test_sparrow_lib - echo "Running sparrow examples" - cmake --build . --config ${{matrix.config.name}} --target run_examples - echo "Running sparrow tests" - cmake --build . --config ${{matrix.config.name}} --target run_tests_with_junit_report - ccache --show-stats + - name: CCache stat + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + run: ccache --show-stats + shell: alpine.sh {0} - name: Upload test results uses: actions/upload-artifact@v4 if: success() || failure() with: - name: test_sparrow_lib_report_Linux_${{matrix.target.distro}}_${{matrix.target.arch}}_${{matrix.config.name}}_date-polyfill_${{matrix.target.date-polyfill}} + name: test_sparrow_lib_report_Linux_${{matrix.target.arch}}_${{matrix.config.name}}_date-polyfill_${{matrix.target.date-polyfill}} path: ./**/test*.xml if-no-files-found: error diff --git a/CMakeLists.txt b/CMakeLists.txt index 48f73dc5..868921a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,6 +284,7 @@ if(ENABLE_COVERAGE) endif() if (BUILD_TESTS) + message(STATUS "🧪 Create tests targets") enable_testing() add_subdirectory(test) endif () diff --git a/include/sparrow/utils/large_int.hpp b/include/sparrow/utils/large_int.hpp index d039cca9..bc5d45aa 100644 --- a/include/sparrow/utils/large_int.hpp +++ b/include/sparrow/utils/large_int.hpp @@ -101,7 +101,7 @@ namespace sparrow } while (n > 0) { - str += '0' + std::int8_t(n % 10); + str.push_back(static_cast('0' + std::int8_t(n % 10))); n /= 10; }