forked from dmikushin/tray
-
-
Notifications
You must be signed in to change notification settings - Fork 11
316 lines (281 loc) · 10.9 KB
/
ci.yml
File metadata and controls
316 lines (281 loc) · 10.9 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
---
name: CI
permissions: {}
on:
pull_request:
push:
branches:
- master
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
build:
name: Build (${{ matrix.os }} - ${{ matrix.appindicator || 'default' }})
defaults:
run:
shell: ${{ matrix.shell }}
permissions:
contents: read
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
shell: "bash"
- os: ubuntu-latest
appindicator: "libayatana-appindicator3-dev"
appindicator_type: "ayatana"
shell: "bash"
- os: ubuntu-latest
appindicator: "libappindicator3-dev"
appindicator_type: "legacy"
shell: "bash"
- os: windows-latest
shell: "msys2 {0}"
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Setup Dependencies Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
cmake \
${{ matrix.appindicator }} \
imagemagick \
libglib2.0-dev \
libnotify-dev \
ninja-build \
xvfb
- name: Setup virtual desktop
if: runner.os == 'Linux'
uses: LizardByte/actions/actions/virtual_desktop@70bb8d394d1c92f6113aeec6ae9cc959a5763d15 # v2026.227.200013
with:
appindicator-version: ${{ matrix.appindicator_type }}
environment: mate
- name: Setup Dependencies macOS
if: runner.os == 'macOS'
run: |
brew update
brew install \
cmake \
doxygen \
graphviz \
imagemagick \
ninja \
node
- name: Fix macOS screen recording permissions
if: runner.os == 'macOS'
run: |
# Grant screen recording permissions to prevent popup dialogs in CI
# This modifies the TCC (Transparency, Consent, and Control) database
# https://apple.stackexchange.com/questions/362865/macos-list-apps-authorized-for-full-disk-access
# https://github.com/actions/runner-images/issues/9529
# https://github.com/actions/runner-images/pull/9530
# Get macOS version
os_version=$(sw_vers -productVersion | cut -d '.' -f 1)
echo "macOS version: $os_version"
# function to execute sql query for each value
function execute_sql_query {
local value=$1
local dbPath=$2
echo "Executing SQL query for value: $value"
sudo sqlite3 "$dbPath" "INSERT OR IGNORE INTO access VALUES($value);"
}
# Find all provisioner paths and store them in an array
declare -a app_paths=()
while IFS= read -r line; do
app_paths+=("$line")
done < <(sudo find /opt /usr -name bash 2>/dev/null)
echo "Provisioner paths: ${app_paths[@]}"
# Create an empty array
declare -a values=()
# Loop through the provisioner paths and add them to the values array
for p_path in "${app_paths[@]}"; do
# Adjust the service name and other parameters as needed
values+=("'kTCCServiceAccessibility','${p_path}',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,NULL,1592919552")
values+=("'kTCCServiceScreenCapture','${p_path}',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159")
done
echo "Values: ${values[@]}"
# Adjust for Sonoma (macOS 14+) which has extra columns
if [[ "$os_version" -ge 14 ]]; then
echo "Adjusting for macOS Sonoma or later (extra TCC columns)"
# TCC access table in Sonoma has extra 4 columns: pid, pid_version, boot_uuid, last_reminded
for i in "${!values[@]}"; do
values[$i]="${values[$i]},NULL,NULL,'UNUSED',${values[$i]##*,}"
done
fi
# System and user TCC databases
dbPaths=(
"/Library/Application Support/com.apple.TCC/TCC.db"
"$HOME/Library/Application Support/com.apple.TCC/TCC.db"
)
# Execute SQL queries
for value in "${values[@]}"; do
for dbPath in "${dbPaths[@]}"; do
echo "Column names for $dbPath"
echo "-------------------"
sudo sqlite3 "$dbPath" "PRAGMA table_info(access);"
echo "Current permissions for $dbPath"
echo "-------------------"
sudo sqlite3 "$dbPath" "SELECT * FROM access WHERE service='kTCCServiceScreenCapture';"
execute_sql_query "$value" "$dbPath"
echo "Updated permissions for $dbPath"
echo "-------------------"
sudo sqlite3 "$dbPath" "SELECT * FROM access WHERE service='kTCCServiceScreenCapture';"
done
done
- name: Setup Dependencies Windows
if: runner.os == 'Windows'
uses: msys2/setup-msys2@4f806de0a5a7294ffabaff804b38a9b435a73bda # v2.30.0
with:
msystem: ucrt64
update: true
install: >-
doxygen
mingw-w64-ucrt-x86_64-binutils
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-graphviz
mingw-w64-ucrt-x86_64-imagemagick
mingw-w64-ucrt-x86_64-ninja
mingw-w64-ucrt-x86_64-nodejs
mingw-w64-ucrt-x86_64-toolchain
- name: Setup python
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.11'
- name: Python Path
id: python-path
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
# replace backslashes with double backslashes
python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g')
else
python_path=${{ steps.setup-python.outputs.python-path }}
fi
# step output
echo "python-path=${python_path}"
echo "python-path=${python_path}" >> "${GITHUB_OUTPUT}"
- name: Build
run: |
mkdir -p build
if [ "${{ runner.os }}" = "Linux" ]; then
# Doxygen from Ubuntu is too old, need Doxygen >= 1.10
DOCS=OFF
else
DOCS=ON
fi
cmake \
-DBUILD_DOCS=${DOCS} \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-B build \
-G Ninja \
-S .
ninja -C build
- name: Init tray icon (Windows)
if: runner.os == 'Windows'
working-directory: build/tests
run: ./test_tray --gtest_color=yes --gtest_filter=TrayTest.TestTrayInit
- name: Configure Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
echo "::group::Enable all tray icons"
Invoke-WebRequest `
-Uri "https://raw.githubusercontent.com/paulmann/windows-show-all-tray-icons/main/Enable-AllTrayIcons.ps1" `
-OutFile "Enable-AllTrayIcons.ps1"
.\Enable-AllTrayIcons.ps1 -Action Enable -Force # Enable with comprehensive method (resets ALL icon settings)
echo "::endgroup::"
echo "::group::Disable Do Not Disturb"
Add-Type -AssemblyName System.Windows.Forms
Start-Process "ms-settings:notifications"
Start-Sleep -Seconds 2
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
[System.Windows.Forms.SendKeys]::SendWait("{TAB}")
[System.Windows.Forms.SendKeys]::SendWait(" ")
echo "::endgroup::"
echo "::group::Minimize all windows"
$shell = New-Object -ComObject Shell.Application
$shell.MinimizeAll()
echo "::endgroup::"
echo "::group::Set Date - Hack for Quiet Time"
$newDate = (Get-Date).AddHours(2)
Set-Date -Date $newDate
echo "::endgroup::"
- name: Run tests
id: test
# TODO: tests randomly hang on Linux, https://github.com/LizardByte/tray/issues/45
timeout-minutes: 3
working-directory: build/tests
run: ./test_tray --gtest_color=yes --gtest_output=xml:test_results.xml
- name: Upload screenshots
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
uses: actions/upload-artifact@v6
with:
name: tray-screenshots-${{ runner.os }}${{ matrix.appindicator && format('-{0}', matrix.appindicator) || '' }}
path: build/tests/screenshots
if-no-files-found: error
- name: Generate gcov report
id: test_report
# any except canceled or skipped
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure')
working-directory: build
run: |
${{ steps.python-path.outputs.python-path }} -m pip install gcovr
${{ steps.python-path.outputs.python-path }} -m gcovr . -r ../src \
--exclude-noncode-lines \
--exclude-throw-branches \
--exclude-unreachable-branches \
--verbose \
--xml-pretty \
-o coverage.xml
- name: Debug coverage file
run: cat build/coverage.xml
- name: Set codecov flags
id: codecov_flags
run: |
flags="${{ runner.os }}"
if [ -n "${{ matrix.appindicator }}" ]; then
flags="${flags},${{ matrix.appindicator }}"
fi
echo "flags=${flags}" >> "${GITHUB_OUTPUT}"
- name: Upload coverage
# any except canceled or skipped
if: >-
always() &&
steps.test_report.outcome == 'success' &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
disable_search: true
fail_ci_if_error: true
files: ./build/coverage.xml
flags: "${{ steps.codecov_flags.outputs.flags }}"
report_type: coverage
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Upload test results
# any except canceled or skipped
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure') &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
disable_search: true
fail_ci_if_error: true
files: ./build/tests/test_results.xml
flags: "${{ steps.codecov_flags.outputs.flags }}"
report_type: test_results
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true