-
Notifications
You must be signed in to change notification settings - Fork 5
121 lines (103 loc) · 4.51 KB
/
build.yml
File metadata and controls
121 lines (103 loc) · 4.51 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
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: 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