-
Notifications
You must be signed in to change notification settings - Fork 2
136 lines (116 loc) · 4.96 KB
/
analyze.yml
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
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Part of BlueTit Solver, licensed under Apache 2.0 with Commons Clause.
# Commercial use, including SaaS, requires a separate license, see /LICENSE.md
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
name: Analyze
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
# Cancel previous runs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze
strategy:
matrix:
os: [ubuntu-24.04]
compiler: [g++-14]
configuration: [Coverage]
runs-on: ${{ matrix.os }}
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
CXX_COVERAGE_REPORT_PATH_CODECOV: cxx_coverage_codecov.xml
CXX_COVERAGE_REPORT_PATH_SONAR: cxx_coverage_sonar.xml
JS_COVERAGE_REPORT_PATH: source/titfront/coverage/lcov.info
PYTHON_COVERAGE_REPORT_PATH: python_coverage.xml
# To be set by the steps.
VCPKG_ROOT:
VCPKG_DEFAULT_BINARY_CACHE:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Fetch all history for proper analysis and coverage reports.
fetch-depth: 0
- name: Install packages and tools
run: ./build/setup-ci-runner.sh
- name: Install Sonar Scanner
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Restore vcpkg packages cache
id: vcpkg-cache-restore
uses: actions/cache/restore@v4
with:
path: |
${{ env.VCPKG_ROOT }}/installed
${{ env.VCPKG_ROOT }}/buildtrees
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
# Use the run ID as the cache key, this way the cache is updated
# after each run.
key: vcpkg-${{ runner.os }}-${{ matrix.compiler }}-${{ github.run_id }}
restore-keys: vcpkg-${{ runner.os }}-${{ matrix.compiler }}
- name: Install vcpkg packages
run: $VCPKG_ROOT/vcpkg install
env:
CXX: ${{ matrix.compiler }}
- name: Update vcpkg packages cache
uses: actions/cache/save@v4
with:
path: |
${{ env.VCPKG_ROOT }}/installed
${{ env.VCPKG_ROOT }}/buildtrees
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ steps.vcpkg-cache-restore.outputs.cache-primary-key }}
- name: Build
run: |
build-wrapper-linux-x86-64 \
--out-dir "${{ env.BUILD_WRAPPER_OUT_DIR }}" \
./build/build.sh --force \
--compiler ${{ matrix.compiler }} \
--config ${{ matrix.configuration }}
- name: Run tests
run: ./build/test.sh
- name: Collect coverage reports
run: |
# Generate C++ coverage report.
GCOV_EXE="${{ matrix.compiler }}"
GCOV_EXE="${GCOV_EXE/g++/gcov}"
gcovr \
--gcov-executable "$GCOV_EXE" \
--exclude "output/.*" \
--exclude "tests/.*" \
--exclude ".*\.test.*" \
--exclude-unreachable-branches \
--exclude-throw-branches \
--xml "${{ env.CXX_COVERAGE_REPORT_PATH_CODECOV }}" \
--sonarqube "${{ env.CXX_COVERAGE_REPORT_PATH_SONAR }}"
# Generate Python coverage report.
find output/test_output -name ".coverage" | xargs coverage combine
coverage xml -o "${{ env.PYTHON_COVERAGE_REPORT_PATH }}"
- name: Upload test output
uses: actions/upload-artifact@v4
if: always()
with:
name: test-output-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.configuration }}
path: output/test_output
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Jhuighuy/TitSolver
files: ${{ env.CXX_COVERAGE_REPORT_PATH_CODECOV }},${{ env.JS_COVERAGE_REPORT_PATH }},${{ env.PYTHON_COVERAGE_REPORT_PATH }}
disable_search: true
- name: Run Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define sonar.coverageReportPaths="${{ env.CXX_COVERAGE_REPORT_PATH_SONAR }}" \
--define sonar.javascript.lcov.reportPaths="${{ env.JS_COVERAGE_REPORT_PATH }}" \
--define sonar.python.coverage.reportPaths="${{ env.PYTHON_COVERAGE_REPORT_PATH }}"