From d1c19ddb91d7d3e8faee3e80bf3d06bba11c00c3 Mon Sep 17 00:00:00 2001 From: Kalyan Sriram Date: Sat, 9 Oct 2021 03:55:52 -0700 Subject: [PATCH] Migrate from Travis-CI to GitHub Actions (#8) --- .github/workflows/main.yml | 96 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 79 ------------------------------- 2 files changed, 96 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0483483 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,96 @@ +name: Main Workflow + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + toolchain: ['clang', 'gcc'] + build_type: ['Debug', 'Release', 'MinSizeRel'] + include: + - toolchain: gcc + c-compiler: gcc + cxx-compiler: g++ + - toolchain: clang + c-compiler: clang-11 + cxx-compiler: clang++-11 + + steps: + - uses: actions/checkout@v2 + + - name: Install Dependencies + run: sudo apt install gcc-multilib g++-multilib clang-tidy-9 clang-format-9 + + - name: Configure CMake + run: cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_COMPILER=${{ matrix.c-compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }} tests + + - name: Build + working-directory: ${{github.workspace}}/build + run: make VERBOSE=1 + + - name: Test + working-directory: ${{github.workspace}}/build + run: make test + + sonarcloud: + env: + SONAR_SCANNER_VERSION: 4.6.1.2450 + SONAR_SERVER_URL: "https://sonarcloud.io" + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + CC: gcc-9 + CXX: g++-9 + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Dependencies + run: sudo apt install g++-9 g++-9-multilib gcc-9-multilib + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + + - name: Download and set up sonar-scanner + env: + SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip + run: | + mkdir -p $HOME/.sonar + curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} + unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH + + - name: Download and set up build-wrapper + env: + BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip + run: | + curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} + unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ + echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH + + - name: Run build-wrapper + run: | + cmake tests -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=1 + build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make all + make test + gcov-10 --preserve-paths --long-file-names $(find CMakeFiles/test_private_cov.dir -name '*.gcno') + + - name: Run sonar-scanner + run: | + sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" --define sonar.login=${{ secrets.SONAR_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3804d57..0000000 --- a/.travis.yml +++ /dev/null @@ -1,79 +0,0 @@ -dist: xenial -env: - - CTEST_OUTPUT_ON_FAILURE=1 - -matrix: - include: - # -------------------- GCC + SonarCloud -------------------- - - language: cpp - addons: - sonarcloud: - organization: pavel-kirienko - token: - secure: "IrmNvn9Blg3u/4VlX87qAvukl3deX847tfUAqNrkz3Tu8YW8u+fnitt6J/2gtnhW+cy57CM/wkWU2BIvIjRINbWLJle1KlnB4isdrmRu8Nhk57+uww/w4599UIiAjo6m50Fa7lvVAMR5wR+ZkD4SV7NDDAR6R/gqEqwuIyyXh9mrvCVgQyt+inQPgg4vG6bLPg9TXXXQ/U9+5LgKgCEyV703slzznv2oZJMzcbzT1fdnkcW2veIKTSByB1BqyKseabUZ3qgEGzozk7jV4lp3sRjfVu75F5bTOtB40f6fcOCVlk0FR26HtnFOylXzQ4uCJoNyHWz60gGmYpBi8dgY4wEN/ShsWG4bm0DPaR9EICQagVBCKk1GqGZ3FCBhRTvKtNL0jMFxb05YFDHRlGijEXhGKdmEKextMb4Q7SI4GjRzYuFOmzHIkJnLZPNmQgZa9qZlTGYXXupYAqxUhDi5euyeInaXd+uLWSajoLiCyKioXMOYb69LnswttWkhjjHa+a7OOI1pw/Tf6mzztNZ/l19m9ap85aiC+ysKc1+zakNXyECqezPMdJUuDdiB+OKhXlW8wAGni07VhulKxALbqop86owNkQI85dArSpKX4vrzwhx5ZnNSvvNQL9iFZsQgxD7WI9dLa4RG2FoIMoal86eZvXnePXOtWpLWJy+kaV4=" - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-9 - - g++-9-multilib - - gcc-9-multilib - - linux-libc-dev:i386 - script: - # DEBUG - - CC=gcc-9 && CXX=g++-9 && cmake tests -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=1 - - build-wrapper-linux-x86-64 --out-dir sonar-dump make all # The build wrapper comes from Sonar Cloud. - - make test - # TODO: COMBINE COVERAGE FROM ALL EXECUTABLES! - - find CMakeFiles/test_general_cov.dir/ -name 'o1heap.c.*' -type f -print -exec mv -f {} . \; - - gcov-9 o1heap/o1heap.c --object-file o1heap*gcda --object-file o1heap*gcno - - # RELEASE - - CC=gcc-9 && CXX=g++-9 && cmake tests -DCMAKE_BUILD_TYPE=Release -DNO_STATIC_ANALYSIS=1 - - make all VERBOSE=1 && make test - - # ANALYSIS - - sonar-scanner - - # -------------------- Clang 9 -------------------- - - language: cpp - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: # Install a newer GCC because https://stackoverflow.com/a/51512150/1007777. - - g++-9 - - g++-9-multilib - - gcc-9-multilib - - linux-libc-dev:i386 - - libc6-dev-i386 - - libstdc++-7-dev:i386 - script: - # Set up the toolchain. - - wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 9 - - sudo apt install clang-tidy-9 clang-format-9 - - clang++-9 -E -x c++ - -v < /dev/null # Print the Clang configuration for troubleshooting purposes. - - # DEBUG - - cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=Debug - - make VERBOSE=1 && make test - - # RELEASE - - cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=Release - - make VERBOSE=1 && make test - - # RELWITHDEBINFO - - cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=RelWithDebInfo - - make VERBOSE=1 && make test - - # MINSIZEREL - - cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=MinSizeRel - - make VERBOSE=1 && make test - - # Format check - - make format VERBOSE=1 - - 'modified="$(git status --porcelain --untracked-files=no)"' - - 'if [ -n "$modified" ]; then echo "Run scripts/format.sh to reformat the code."; exit 1; fi' - -git: - depth: false # Disable shallow clone because it is incompatible with SonarCloud