-
Notifications
You must be signed in to change notification settings - Fork 5
147 lines (129 loc) · 6.07 KB
/
Copy pathbuild.yml
File metadata and controls
147 lines (129 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
name: Build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
BUILD_TYPE: Release
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
jobs:
build:
name: Build & Test
runs-on: macos-26
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@main
- name: Install dependencies
run: bash ./.github/workflows/scripts/brew.sh
- name: Build C++ Libraries
run: bash ./scripts/build_dep.sh
- name: Select Xcode version
run: sudo xcode-select -switch /Applications/Xcode.app
- name: Run tests
run: >
OTHER_CFLAGS="-fprofile-instr-generate -fcoverage-mapping"
OTHER_CPLUSPLUSFLAGS="-fprofile-instr-generate -fcoverage-mapping"
OTHER_SWIFT_FLAGS="-profile-generate -profile-coverage-mapping"
LLVM_PROFILE_FILE="/tmp/coverage.profraw"
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
xcodebuild
-scheme tests
-destination 'platform=macOS,arch=arm64'
-resultBundlePath TestResult/
-enableCodeCoverage YES
-derivedDataPath "${RUNNER_TEMP}/Build/DerivedData"
-parallelizeTargets
-jobs "$(sysctl -n hw.logicalcpu)"
clean build test
| xcpretty -r junit && exit ${PIPESTATUS[0]}
- name: Convert coverage report to sonarqube format
run: >
bash ./.github/workflows/scripts/xccov-to-sonarqube-generic.sh *.xcresult/ > sonarqube-generic-coverage.xml
- name: Upload coverage report
uses: actions/upload-artifact@v7
with:
name: sonarqube-coverage
path: sonarqube-generic-coverage.xml
retention-days: 1
sonar-scan:
name: SonarCloud Scan
needs: build
runs-on: ubuntu-latest
steps:
# fetch-depth: 0 gives Sonar full git history for blame-based new-code analysis.
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install dependencies
run: sudo apt install -y libssl-dev libpq-dev libcurl4-openssl-dev
# ubuntu-latest (24.04) defaults to GCC 13, whose libstdc++ lacks the
# C++23 <print> header (std::print/std::println). That header was added
# in GCC 14, so install it and make it the default compiler for every
# subsequent step (dependency build, CMake configure, build-wrapper).
- name: Install GCC 14 (for C++23 <print>)
run: |
sudo apt install -y gcc-14 g++-14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
# Ubuntu's apt Boost (1.83 on 24.04) predates Boost.Redis, which was added
# in Boost 1.84, so <boost/redis.hpp> is absent. Install a newer Boost.
# Boost.Redis/Asio are header-only, so we only need the headers plus the
# CMake package config — building just Boost.System generates both quickly.
- name: Install Boost >= 1.84 (for Boost.Redis)
run: |
BOOST_VERSION=1.86.0
BOOST_DIR="boost_${BOOST_VERSION//./_}"
wget -q "https://archives.boost.io/release/${BOOST_VERSION}/source/${BOOST_DIR}.tar.gz"
tar xzf "${BOOST_DIR}.tar.gz"
cd "${BOOST_DIR}"
./bootstrap.sh > /dev/null
# -d0 silences per-action output (otherwise b2 prints one line per
# copied header — ~15k lines just for the header install).
sudo ./b2 install -d0 --prefix=/usr/local --with-system -j"$(nproc)"
- name: Check compiler version, for debugging
run: |
g++ --version
cmake --version
- name: Build C++ Libraries
run: bash ./scripts/build_dep.sh
# SonarQube Server and Cloud (formerly SonarQube and SonarCloud) is a widely used static
# analysis solution for continuous code quality and security inspection.
# This action now supports and is the official entrypoint for scanning C++ projects via GitHub actions.
# https://github.com/SonarSource/sonarqube-scan-action
- name: Install Build Wrapper
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4.2.1
# This step installs the SonarQube build wrapper, which is necessary for analyzing C/C++ projects.
# Lands at ./artifact/sonarqube-generic-coverage.xml so the existing
# sonar.coverageReportPaths argument keeps working unchanged.
- name: Download coverage artifact from build job
uses: actions/download-artifact@v5
with:
name: sonarqube-coverage
path: artifact
# Configures the CMake build system, specifying the source directory and build directory, and setting the build type
- name: Configure CMake
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# Runs the build wrapper to capture build commands and outputs them to the specified directory. Then builds the project using CMake
- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --clean-first
# Performs the SonarQube scan using the scan action. Uses captured build commands for analysis and requires GitHub and SonarQube tokens for authentication
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4.2.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
--define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json"
--define sonar.coverageReportPaths=artifact/sonarqube-generic-coverage.xml