generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 0
226 lines (201 loc) · 6.63 KB
/
ci.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
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
---
name: CI
on:
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
push:
branches:
- master
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
setup_release:
name: Setup Release
outputs:
publish_release: ${{ steps.setup_release.outputs.publish_release }}
release_body: ${{ steps.setup_release.outputs.release_body }}
release_commit: ${{ steps.setup_release.outputs.release_commit }}
release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }}
release_tag: ${{ steps.setup_release.outputs.release_tag }}
release_version: ${{ steps.setup_release.outputs.release_version }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Release
id: setup_release
uses: LizardByte/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build:
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
shell: "bash"
- os: ubuntu-latest
shell: "bash"
- os: windows-latest
shell: "msys2 {0}"
name: Build (${{ matrix.os }})
needs: setup_release
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Dependencies Linux
if: runner.os == 'Linux'
run: |
dependencies=(
"bison"
"build-essential"
"clang"
"cmake"
"flex"
"git"
"lld"
"llvm"
)
sudo apt-get update
sudo apt-get install --no-install-recommends -y "${dependencies[@]}"
- name: Setup Dependencies macOS
if: runner.os == 'macOS'
run: |
dependencies=(
"cmake"
"coreutils"
"lld"
"llvm"
)
brew install "${dependencies[@]}"
- name: Setup Dependencies Windows
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
make
cmake
git
bison
flex
mingw-w64-x86_64-gcc
mingw-w64-x86_64-llvm
mingw-w64-x86_64-clang
mingw-w64-x86_64-lld
- name: Setup python
id: setup-python
uses: actions/setup-python@v5
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: |
export NXDK_DIR="$(pwd)/third-party/nxdk"
eval "$(${NXDK_DIR}/bin/activate -s)"
cd "${NXDK_DIR}"
make NXDK_ONLY=y
make tools
cd "${GITHUB_WORKSPACE}"
mkdir -p build
# the main target needs to be cross compiled
echo "--- Building ALL ---"
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE="${NXDK_DIR}/share/toolchain-nxdk.cmake"
cmake --build build
# TODO: Tests are not building properly...
# the tests target should not be cross compiled, so we can run it on the runner
# https://stackoverflow.com/a/64335131/11214013
# echo "--- Building tests ---"
# cmake \
# -B build/tests \
# -S . \
# -DBUILD_TESTS=ON
# cmake --build build/tests --target test_moonlight
# recursively list all files in build directory
ls -R build
# move artifacts
mkdir -p artifacts
tar -czf ./artifacts/Moonlight.tar.gz ./build/xbe
mv ./Moonlight.iso ./artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: moonlight-${{ runner.os }}
path: artifacts/
- name: Run tests
id: test
if: false
working-directory: build/tests
run: |
./test_moonlight --gtest_color=yes
- name: Generate gcov report
# any except canceled or skipped
if: always() && (steps.test.outcome == 'success' || steps.test.outcome == 'failure')
id: test_report
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
if: >-
always() &&
steps.test_report.outcome == 'success'
run: |
cat build/coverage.xml
# todo: upload coverage in separate job similar to LizardByte/libdisplaydevice
- name: Upload coverage
# any except canceled or skipped
if: >-
always() &&
steps.test_report.outcome == 'success' &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@v5
with:
disable_search: true
fail_ci_if_error: true
files: ./build/coverage.xml
flags: "${{ runner.os }}"
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Create/Update GitHub Release
# only publish release on ubuntu-latest, is there any difference between the different builds?
if: ${{ needs.setup_release.outputs.publish_release == 'true' && matrix.os == 'ubuntu-latest' }}
uses: LizardByte/[email protected]
with:
allowUpdates: true
body: ${{ needs.setup_release.outputs.release_body }}
generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }}
name: ${{ needs.setup_release.outputs.release_tag }}
prerelease: true
tag: ${{ needs.setup_release.outputs.release_tag }}
token: ${{ secrets.GH_BOT_TOKEN }}