Skip to content
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
86 changes: 48 additions & 38 deletions .github/workflows/analysis-sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: Analysis - SonarCloud

on:
Expand All @@ -12,72 +11,78 @@ env:
VCPKG_BUILD_TYPE: release
CMAKE_BUILD_PARALLEL_LEVEL: 2
MAKEFLAGS: '-j 2'
NUMBER_OF_PROCESSORS: 2

jobs:
sonarcloud:
name: SonarCloud
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' }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'push' && github.ref || github.event.pull_request.head.ref }}
repository: ${{ github.event_name == 'push' && github.repository || github.event.pull_request.head.repo.full_name }}

- name: Install Linux Dependencies
run: >
sudo apt-get update && sudo apt-get install ccache libglew-dev libx11-dev linux-headers-$(uname -r)
run: |
sudo apt-get update
sudo apt-get install -y ccache libglew-dev libx11-dev linux-headers-$(uname -r)

- name: Switch to gcc-11
- name: Switch to GCC 11
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 apt install -y 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
id: ccache
uses: actions/cache@main
- name: Detect CPU core count
id: cpu-count
run: echo "count=$(nproc)" >> "$GITHUB_OUTPUT"

- name: Cache CCache
uses: actions/cache@v4
with:
path: $HOME/.ccache
key: ccache-${{ runner.os }}-${{ hashFiles('**/src') }}
key: ccache-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'vcpkg.json', 'src/**/*.cpp', 'src/**/*.h') }}
restore-keys: |
ccache-${{ runner.os}}-
ccache-${{ runner.os }}-

- name: Sonar cache
uses: actions/cache@main
- name: Cache SonarCloud analysis data
uses: actions/cache@v4
with:
path: $HOME/.cfamily
key: sonar-${{ runner.os}}-${{ hashFiles('**/src') }}
key: sonar-cfamily-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'vcpkg.json', 'src/**/*.cpp', 'src/**/*.h') }}
restore-keys: |
sonar-${{ runner.os}}-
sonar-cfamily-${{ runner.os }}-

- name: Cache SonarCloud packages
uses: actions/cache@main
uses: actions/cache@v4
with:
path: $HOME/.sonar/cache
key: sonar-${{ runner.os}}-${{ hashFiles('**/src') }}
key: sonar-packages-${{ runner.os }}
restore-keys: |
sonar-${{ runner.os}}-
sonar-packages-${{ runner.os }}-

- name: Restore artifacts and install vcpkg
- name: Extract vcpkg commit ID
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
echo "vcpkgGitCommitId=$vcpkgCommitId" >> "$GITHUB_OUTPUT"

- name: Cache vcpkg installed packages
uses: actions/cache@v4
with:
path: build/vcpkg_installed
key: vcpkg-installed-${{ runner.os }}-${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }}
restore-keys: |
vcpkg-installed-${{ runner.os }}-

- name: Get vcpkg commit id from vcpkg.json
uses: lukka/run-vcpkg@main
- name: Setup vcpkg with baseline
uses: lukka/run-vcpkg@v11
with:
vcpkgGitURL: "https://github.com/microsoft/vcpkg.git"
vcpkgGitCommitId: ${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }}
vcpkgJsonIgnores: "['**/vcpkg/**', '**/browser/overlay-ports/**']"

Expand All @@ -87,7 +92,12 @@ jobs:
- name: Generate compilation database
run: |
mkdir -p build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DOPTIONS_ENABLE_CCACHE=ON -DSPEED_UP_BUILD_UNITY=OFF -S . -B build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DOPTIONS_ENABLE_CCACHE=ON \
-DSPEED_UP_BUILD_UNITY=OFF \
-S . -B build

- name: Run PR sonar-scanner
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
Expand All @@ -97,13 +107,13 @@ jobs:
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
sonar-scanner \
--define sonar.cfamily.threads="${{ env.NUMBER_OF_PROCESSORS }}" \
--define sonar.cfamily.threads=${{ steps.cpu-count.outputs.count }} \
--define sonar.cfamily.cache.enabled=true \
--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=$BRANCH \
--define sonar.pullrequest.base=${{ github.event.pull_request.base_ref }}
--define sonar.pullrequest.base=${{ github.event.pull_request.base.ref }}

- name: Run sonar-scanner
if: ${{ github.event_name == 'push' }}
Expand All @@ -112,7 +122,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
--define sonar.cfamily.threads="${{ env.NUMBER_OF_PROCESSORS }}" \
--define sonar.cfamily.threads=${{ steps.cpu-count.outputs.count }} \
--define sonar.cfamily.cache.enabled=true \
--define sonar.cfamily.cache.path="$HOME/.cfamily" \
--define sonar.cfamily.compile-commands=build/compile_commands.json
50 changes: 34 additions & 16 deletions .github/workflows/build-browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,40 @@ name: Build - Emscripten
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "src/**"
- ".github/workflows/build-emscripten.yml"
push:
paths:
- "src/**"
- ".github/workflows/build-emscripten.yml"
branches:
- main

jobs:
job:
cancel-runs:
if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@main
with:
access_token: ${{ github.token }}

build:
name: ${{ matrix.buildtype }}
runs-on: ubuntu-latest

concurrency:
group: otclient-emscripten-${{ github.workflow }}-${{ github.ref }}-${{ matrix.buildtype }}
cancel-in-progress: true

strategy:
fail-fast: false
matrix:
buildtype: [emscripten-release, emscripten-debug]
buildtype: [emscripten-debug]
include:
- buildtype: emscripten-release
cmake_build_type: Release
- buildtype: emscripten-debug
cmake_build_type: Debug

Expand All @@ -37,13 +55,17 @@ jobs:
vcpkgCommitId=$(grep '.builtin-baseline' vcpkg.json | awk -F: '{print $2}' | tr -d '," ')
echo "vcpkgGitCommitId=$vcpkgCommitId" >> $GITHUB_OUTPUT

- name: Cache vcpkg binary artifacts
- name: Cache full vcpkg artifacts
uses: actions/cache@v4
with:
path: ~/.cache/vcpkg/archives
key: vcpkg-binary-cache-${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }}-${{ matrix.buildtype }}
path: |
~/.cache/vcpkg/archives
${{ github.workspace }}/vcpkg/installed
${{ github.workspace }}/vcpkg/buildtrees
${{ github.workspace }}/vcpkg/downloads
key: vcpkg-${{ matrix.buildtype }}-${{ steps.hash.outputs.hash }}
restore-keys: |
vcpkg-binary-cache-${{ steps.vcpkg-step.outputs.vcpkgGitCommitId }}-
vcpkg-${{ matrix.buildtype }}-

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
Expand All @@ -53,13 +75,9 @@ jobs:
- name: Install CMake and Ninja
uses: lukka/get-cmake@v3.31.6

- name: Cache CMake build directory
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/build-${{ matrix.buildtype }}
key: cmake-cache-${{ github.sha }}-${{ matrix.buildtype }}
restore-keys: |
cmake-cache-${{ github.sha }}-${{ matrix.buildtype }}-
- name: Compute vcpkg hash
id: hash
run: echo "hash=$(sha256sum vcpkg.json | cut -d' ' -f1)" >> $GITHUB_OUTPUT

- name: Configure CMake
run: |
Expand All @@ -85,4 +103,4 @@ jobs:
with:
name: otclient-${{ matrix.buildtype }}-${{ github.sha }}
path: ${{ github.workspace }}/build-${{ matrix.buildtype }}/bin/
retention-days: 30
retention-days: 30
33 changes: 28 additions & 5 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
---
name: Build - Docker

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "Dockerfile"
- ".dockerignore"
- ".github/workflows/build-docker.yml"
- "src/**"
push:
branches: [ $default-branch ]
paths:
- "Dockerfile"
- ".dockerignore"
- ".github/workflows/build-docker.yml"
- "src/**"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
cancel-runs:
if: github.event_name == 'pull_request' && github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@main
with:
access_token: ${{ github.token }}

docker:
name: Docker Build & Push
runs-on: ubuntu-latest

concurrency:
group: otclient-docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

steps:
- name: Checkout
uses: actions/checkout@main
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -30,15 +55,13 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
- name: Build and push Docker image with cache
uses: docker/build-push-action@v5
with:
context: .
Expand Down
Loading
Loading