From d3711f0a5e437d3f8ef21c9064e0f5c2852068c0 Mon Sep 17 00:00:00 2001 From: Beats Date: Sun, 5 Feb 2023 19:29:37 -0400 Subject: [PATCH 1/3] update build vcpkg --- .github/workflows/analysis-codeql.yml | 77 --------------------- .github/workflows/analysis-reviewdog.yml | 24 +++++-- .github/workflows/analysis-sonarcloud.yml | 83 ++++++++--------------- .github/workflows/build-ubuntu.yml | 11 ++- .github/workflows/build-windows.yml | 12 +++- Dockerfile | 9 ++- vcpkg.json | 3 +- 7 files changed, 75 insertions(+), 144 deletions(-) delete mode 100644 .github/workflows/analysis-codeql.yml diff --git a/.github/workflows/analysis-codeql.yml b/.github/workflows/analysis-codeql.yml deleted file mode 100644 index 2d1c77f2bd..0000000000 --- a/.github/workflows/analysis-codeql.yml +++ /dev/null @@ -1,77 +0,0 @@ ---- -name: Analysis - CodeQL - -on: - push: - paths: - - 'src/**' - - '**.py' - -env: - CMAKE_BUILD_PARALLEL_LEVEL: 2 - MAKEFLAGS: '-j 2' - NODE_OPTIONS: ' --max-old-space-size=8192 ' - -jobs: - codeql: - name: CodeQL - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04] - language: ['cpp', 'python'] - include: - - language: cpp - buildtype: linux-release - - steps: - - name: Checkout repository - uses: actions/checkout@main - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Install Linux Dependencies - if: ${{ matrix.language == 'cpp' }} - run: > - sudo apt-get update && sudo apt-get install ccache libglew-dev libx11-dev linux-headers-$(uname -r) - - - name: Switch to gcc-11 - if: ${{ matrix.language == 'cpp' }} - run: | - sudo apt install gcc-11 g++-11 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 - sudo update-alternatives --set gcc /usr/bin/gcc-11 - - - name: CCache - uses: hendrikmuhs/ccache-action@main - with: - max-size: "1G" - key: ccache-${{ matrix.os }}-${{ matrix.buildtype }} - restore-keys: | - ccache-${{ matrix.os }} - - - name: Restore artifacts, or setup vcpkg (do not install any package) - if: ${{ matrix.language == 'cpp' }} - uses: lukka/run-vcpkg@main - with: - vcpkgGitURL: "https://github.com/opentibiabr/vcpkg.git" - vcpkgGitCommitId: 8974d642d47efd578e0da3223b4101c5d59aebcf - - - name: Get latest CMake and ninja - if: ${{ matrix.language == 'cpp' }} - uses: lukka/get-cmake@main - - - name: Run CMake - if: ${{ matrix.language == 'cpp' }} - uses: lukka/run-cmake@main - with: - configurePreset: ${{ matrix.buildtype }} - buildPreset: ${{ matrix.buildtype }} - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/analysis-reviewdog.yml b/.github/workflows/analysis-reviewdog.yml index c257743d62..3213874415 100644 --- a/.github/workflows/analysis-reviewdog.yml +++ b/.github/workflows/analysis-reviewdog.yml @@ -23,7 +23,7 @@ jobs: env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd $GITHUB_WORKSPACE + cd "$GITHUB_WORKSPACE" cppcheck --version reviewdog -reporter=github-pr-check -runners=cppcheck @@ -39,13 +39,13 @@ jobs: uses: reviewdog/action-setup@v1.0.3 - name: Setup Lua/Luacheck - run: sudo apt-get update && sudo apt-get install -y lua5.1 liblua5.1-0-dev lua-check + run: sudo apt-get update && sudo apt-get install -y libluajit-5.1-dev lua-check - name: luac env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd $GITHUB_WORKSPACE + cd "$GITHUB_WORKSPACE" luac -v reviewdog -reporter=github-pr-check -runners=luac @@ -61,14 +61,14 @@ jobs: uses: reviewdog/action-setup@v1.0.3 - name: Setup Lua/Luacheck - run: sudo apt-get update && sudo apt-get install -y lua5.1 liblua5.1-0-dev lua-check + run: sudo apt-get update && sudo apt-get install -y libluajit-5.1-dev lua-check - name: luacheck env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | luacheck --version - cd $GITHUB_WORKSPACE + cd "$GITHUB_WORKSPACE" reviewdog -reporter=github-pr-check -runners=luacheck @@ -105,7 +105,7 @@ jobs: env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - cd $GITHUB_WORKSPACE + cd "$GITHUB_WORKSPACE" xmllint --version reviewdog -reporter=github-pr-check -runners=xmllint @@ -135,3 +135,15 @@ jobs: uses: reviewdog/action-hadolint@v1.33.0 with: reporter: github-pr-check + + actionlint: + runs-on: ubuntu-latest + steps: + + - name: Check out code + uses: actions/checkout@main + + - name: actionlint + uses: reviewdog/action-actionlint@v1 + with: + reporter: github-pr-check \ No newline at end of file diff --git a/.github/workflows/analysis-sonarcloud.yml b/.github/workflows/analysis-sonarcloud.yml index 1881bd9047..c38db2b083 100644 --- a/.github/workflows/analysis-sonarcloud.yml +++ b/.github/workflows/analysis-sonarcloud.yml @@ -13,24 +13,24 @@ env: CMAKE_BUILD_PARALLEL_LEVEL: 2 MAKEFLAGS: '-j 2' NUMBER_OF_PROCESSORS: 2 - SONAR_SCANNER_VERSION: 4.7.0.2747 - SONAR_SERVER_URL: "https://sonarcloud.io" - BUILD_WRAPPER_OUT_DIR: bw-output jobs: sonarcloud: name: SonarCloud - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@main + - uses: actions/checkout@v3 if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} with: + fetch-depth: 0 ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - uses: actions/checkout@main + - uses: actions/checkout@v3 if: ${{ github.event_name == 'push' }} + with: + fetch-depth: 0 - name: Install Linux Dependencies run: > @@ -47,63 +47,46 @@ jobs: uses: actions/cache@main with: path: $HOME/.ccache - key: ccache-${{ runner.os}}-${{ matrix.buildtype }}-${{ hashFiles('**/src') }} + key: ccache-${{ runner.os }}-${{ hashFiles('**/src') }} restore-keys: | - ccache-${{ runner.os}}-${{ matrix.buildtype }}- ccache-${{ runner.os}}- - name: Sonar cache uses: actions/cache@main with: path: $HOME/.cfamily - key: sonar-${{ runner.os}}-${{ matrix.buildtype }}-${{ hashFiles('**/src') }} + key: sonar-${{ runner.os}}-${{ hashFiles('**/src') }} restore-keys: | - sonar-${{ runner.os}}-${{ matrix.buildtype }}- sonar-${{ runner.os}}- - name: Cache SonarCloud packages uses: actions/cache@main with: path: $HOME/.sonar/cache - key: sonar-${{ runner.os}}-${{ matrix.buildtype }}-${{ hashFiles('**/src') }} + key: sonar-${{ runner.os}}-${{ hashFiles('**/src') }} restore-keys: | - sonar-${{ runner.os}}-${{ matrix.buildtype }}- sonar-${{ runner.os}}- - - name: Restore artifacts, or setup vcpkg (do not install any package) + - name: Restore artifacts and install vcpkg + id: vcpkg-step + run: | + vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') + echo "vcpkg commit ID: $vcpkgCommitId" + echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + + - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main with: - vcpkgGitURL: "https://github.com/opentibiabr/vcpkg.git" - vcpkgGitCommitId: 8974d642d47efd578e0da3223b4101c5d59aebcf + vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" + vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }} - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 + - name: Install sonar-scanner + uses: SonarSource/sonarcloud-github-c-cpp@v1 - - 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 + - name: Generate compilation database run: | mkdir -p build - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DOPTIONS_ENABLE_CCACHE=ON -S . -B build - build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build + cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DOPTIONS_ENABLE_CCACHE=ON -S . -B build - name: Run PR sonar-scanner if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} @@ -112,14 +95,13 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | sonar-scanner \ - --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" \ - --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \ --define sonar.cfamily.threads="${{ env.NUMBER_OF_PROCESSORS }}" \ --define sonar.cfamily.cache.enabled=true \ - --define sonar.cfamily.cache.path=$HOME/.cfamily \ + --define sonar.cfamily.cache.path="$HOME/.cfamily" \ + --define sonar.cfamily.compile-commands=build/compile_commands.json \ --define sonar.pullrequest.key=${{ github.event.pull_request.number }} \ - --define sonar.pullrequest.branch=${{ github.head_ref }} \ - --define sonar.pullrequest.base=${{ github.base_ref }} + --define sonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} \ + --define sonar.pullrequest.base=${{ github.event.pull_request.base_ref }} - name: Run sonar-scanner if: ${{ github.event_name == 'push' }} @@ -128,14 +110,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} run: | sonar-scanner \ - --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" \ - --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \ --define sonar.cfamily.threads="${{ env.NUMBER_OF_PROCESSORS }}" \ --define sonar.cfamily.cache.enabled=true \ - --define sonar.cfamily.cache.path=$HOME/.cfamily - - - name: SonarQube Quality Gate check - uses: sonarsource/sonarqube-quality-gate-action@master - timeout-minutes: 5 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + --define sonar.cfamily.cache.path="$HOME/.cfamily" \ + --define sonar.cfamily.compile-commands=build/compile_commands.json diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index e7edfc2729..2c4d49c4c8 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -51,10 +51,17 @@ jobs: ccache-${{ matrix.os }} - name: Restore artifacts and install vcpkg + id: vcpkg-step + run: | + vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') + echo "vcpkg commit ID: $vcpkgCommitId" + echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + + - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main with: - vcpkgGitURL: "https://github.com/opentibiabr/vcpkg.git" - vcpkgGitCommitId: 8974d642d47efd578e0da3223b4101c5d59aebcf + vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" + vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }} - name: Get latest CMake and ninja uses: lukka/get-cmake@main diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index c715a1ccb2..ae8a83839f 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -40,10 +40,18 @@ jobs: ccache-${{ matrix.os }} - name: Restore artifacts and install vcpkg + id: vcpkg-step + run: | + $json=Get-Content vcpkg.json -Raw | ConvertFrom-Json + $vcpkgCommitId=$json.'builtin-baseline' + Write-Host "vcpkg commit ID: $vcpkgCommitId" + echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + + - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main with: - vcpkgGitURL: "https://github.com/opentibiabr/vcpkg.git" - vcpkgGitCommitId: 8974d642d47efd578e0da3223b4101c5d59aebcf + vcpkgGitURL: "https://github.com/microsoft/vcpkg.git" + vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }} - name: Get latest CMake and ninja uses: lukka/get-cmake@main diff --git a/Dockerfile b/Dockerfile index ac10ac07aa..5fcc6ad737 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean && apt-get autoclean WORKDIR /opt -RUN git clone https://github.com/microsoft/vcpkg -RUN ./vcpkg/bootstrap-vcpkg.sh +COPY vcpkg.json /opt +RUN vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') \ + && echo "vcpkg commit ID: $vcpkgCommitId" \ + && git clone https://github.com/Microsoft/vcpkg.git \ + && cd vcpkg \ + && git checkout $vcpkgCommitId \ + && ./bootstrap-vcpkg.sh WORKDIR /opt/vcpkg COPY vcpkg.json /opt/vcpkg/ diff --git a/vcpkg.json b/vcpkg.json index ce2f2b87dc..c956977f08 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -27,5 +27,6 @@ "name": "glew", "platform": "windows | osx" } - ] + ], + "builtin-baseline":"0e67f312e831b4b897c7f492cf1e2858522c6e18" } From 33bfa70d965005018ae62ad0e06319e09b7a8adc Mon Sep 17 00:00:00 2001 From: Beats Date: Mon, 6 Feb 2023 00:02:56 -0400 Subject: [PATCH 2/3] up --- .github/workflows/analysis-reviewdog.yml | 2 +- .github/workflows/analysis-sonarcloud.yml | 6 +++--- .github/workflows/build-ubuntu.yml | 2 +- .github/workflows/build-windows.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analysis-reviewdog.yml b/.github/workflows/analysis-reviewdog.yml index 3213874415..3fdbd6eb0b 100644 --- a/.github/workflows/analysis-reviewdog.yml +++ b/.github/workflows/analysis-reviewdog.yml @@ -146,4 +146,4 @@ jobs: - name: actionlint uses: reviewdog/action-actionlint@v1 with: - reporter: github-pr-check \ No newline at end of file + reporter: github-pr-check diff --git a/.github/workflows/analysis-sonarcloud.yml b/.github/workflows/analysis-sonarcloud.yml index c38db2b083..deab4ac3a0 100644 --- a/.github/workflows/analysis-sonarcloud.yml +++ b/.github/workflows/analysis-sonarcloud.yml @@ -20,14 +20,14 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@main if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }} with: fetch-depth: 0 ref: ${{github.event.pull_request.head.ref}} repository: ${{github.event.pull_request.head.repo.full_name}} - - uses: actions/checkout@v3 + - uses: actions/checkout@main if: ${{ github.event_name == 'push' }} with: fetch-depth: 0 @@ -72,7 +72,7 @@ jobs: run: | vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') echo "vcpkg commit ID: $vcpkgCommitId" - echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + echo "name=vcpkgGitCommitId::$vcpkgCommitId" >> $env:GITHUB_OUTPUT - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 2c4d49c4c8..ea1bb1a829 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -55,7 +55,7 @@ jobs: run: | vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') echo "vcpkg commit ID: $vcpkgCommitId" - echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + echo "name=vcpkgGitCommitId::$vcpkgCommitId" >> $env:GITHUB_OUTPUT - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index ae8a83839f..0210ed7d0e 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -45,7 +45,7 @@ jobs: $json=Get-Content vcpkg.json -Raw | ConvertFrom-Json $vcpkgCommitId=$json.'builtin-baseline' Write-Host "vcpkg commit ID: $vcpkgCommitId" - echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" + echo "name=vcpkgGitCommitId::$vcpkgCommitId" >> $env:GITHUB_OUTPUT - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main From ad03eb559f0d5110ee6a09a3ccd30ff9ee0f677d Mon Sep 17 00:00:00 2001 From: Beats Date: Mon, 6 Feb 2023 00:31:42 -0400 Subject: [PATCH 3/3] up --- .github/workflows/build-ubuntu.yml | 2 +- .github/workflows/build-windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index ea1bb1a829..2c4d49c4c8 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -55,7 +55,7 @@ jobs: run: | vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ') echo "vcpkg commit ID: $vcpkgCommitId" - echo "name=vcpkgGitCommitId::$vcpkgCommitId" >> $env:GITHUB_OUTPUT + echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 0210ed7d0e..ae8a83839f 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -45,7 +45,7 @@ jobs: $json=Get-Content vcpkg.json -Raw | ConvertFrom-Json $vcpkgCommitId=$json.'builtin-baseline' Write-Host "vcpkg commit ID: $vcpkgCommitId" - echo "name=vcpkgGitCommitId::$vcpkgCommitId" >> $env:GITHUB_OUTPUT + echo "::set-output name=vcpkgGitCommitId::$vcpkgCommitId" - name: Get vcpkg commit id from vcpkg.json uses: lukka/run-vcpkg@main