Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: update GHA to read builtin-baseline from vcpkg.json #403

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions .github/workflows/analysis-codeql.yml

This file was deleted.

24 changes: 18 additions & 6 deletions .github/workflows/analysis-reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -39,13 +39,13 @@ jobs:
uses: reviewdog/[email protected]

- 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

Expand All @@ -61,14 +61,14 @@ jobs:
uses: reviewdog/[email protected]

- 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


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -135,3 +135,15 @@ jobs:
uses: reviewdog/[email protected]
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
79 changes: 27 additions & 52 deletions .github/workflows/analysis-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
if: ${{ github.event_name == 'push' }}
with:
fetch-depth: 0

- name: Install Linux Dependencies
run: >
Expand All @@ -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 "name=vcpkgGitCommitId::$vcpkgCommitId" >> $env:GITHUB_OUTPUT

- 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' }}
Expand All @@ -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' }}
Expand All @@ -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
11 changes: 9 additions & 2 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
3 changes: 2 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"name": "glew",
"platform": "windows | osx"
}
]
],
"builtin-baseline":"0e67f312e831b4b897c7f492cf1e2858522c6e18"
}