-
Notifications
You must be signed in to change notification settings - Fork 0
214 lines (188 loc) · 6.83 KB
/
ci.yml
File metadata and controls
214 lines (188 loc) · 6.83 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
name: ci
on:
push:
branches-ignore:
- 'ga-ignore-**'
- 'gh-pages'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UNWANTED_REGEX: '^(?!.*tests\/).*gc(no|da|ov)$|(.*\.(a|o|so|lib))$|(.*~)$|^(#.*#)$|^tmp\/.*|.*\/tmp\/.*'
jobs:
check_repository_cleanliness:
name: Checks if the repository is clean and void of any unwanted files (temp files, binary files, etc.)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Find unwanted files
run: |
UNWANTED_FILES=$(find . -type f -printf '%P\n' | grep -P "${{ env.UNWANTED_REGEX }}" || true)
if [ -n "$UNWANTED_FILES" ]; then
while IFS= read -r LINE; do
echo "::error file=${LINE},line=1,col=1,title=Unwanted file detected::${LINE}"
done <<< "$UNWANTED_FILES"
echo "FAIL_TASK=true" >> "$GITHUB_ENV"
exit 1
else
echo "FAIL_TASK=false" >> "$GITHUB_ENV"
fi
lint_code:
name: Lint with clang-format
runs-on: ubuntu-latest
steps:
- name: Check if triggered by bot
id: check_bot
env:
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
run: |
if [ "$COMMIT_AUTHOR" = "github-actions[bot]" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "Commit made by github-actions[bot], skipping lint steps"
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
if: steps.check_bot.outputs.skip != 'true'
with:
ref: ${{ github.ref_name }}
- name: Install clang-format
if: steps.check_bot.outputs.skip != 'true'
run: sudo apt-get install -y clang-format
- name: Run clang-format
if: steps.check_bot.outputs.skip != 'true'
run: |
git ls-files -z "*.cpp" "*.hpp" "*.inl" | while IFS= read -rd '' f; do tail -c1 < "$f" | read -r _ || echo >> "$f"; done
find . -iname '*.hpp' -o -iname '*.cpp' -o -iname '*.inl' | xargs clang-format -i
if [[ -n $(git status --porcelain) ]]; then
echo "::error title=Code formatting issues detected::Please run clang-format on your code and commit the changes."
git --no-pager diff
exit 1
fi
check_program_compilation:
name: Build and verify binaries
needs: [check_repository_cleanliness, lint_code]
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Setup Linux dependencies
if: contains(runner.os, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa-dev freeglut3-dev mesa-common-dev mesa-utils
- name: Setup Windows dependencies
if: contains(runner.os, 'windows')
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
- name: Install xmake
uses: xmake-io/github-action-setup-xmake@e50494030a33fd120900e739f6418a48100cd6ce
with:
xmake-version: latest
actions-cache-folder: '.xmake-cache-${{ runner.os }}'
actions-cache-key: 'xmake-actions-cache-key-${{ runner.os }}-compilation'
package-cache: true
package-cache-key: 'xmake-package-cache-key-${{ runner.os }}-compilation'
project-path: '.'
build-cache: true
build-cache-key: 'xmake-build-cache-key-${{ runner.os }}-compilation'
build-cache-path: 'build/.build_cache'
- name: Build project
run: |
xmake f -y
xmake build -y
timeout-minutes: 30
run_tests:
name: Run tests
needs: [check_repository_cleanliness, lint_code]
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Setup Linux test dependencies
if: contains(runner.os, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa-dev freeglut3-dev mesa-common-dev mesa-utils
sudo apt-get install -y python3 python3-pip
pip3 install gcovr
- name: Setup Windows dependencies
if: contains(runner.os, 'windows')
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
- name: Install xmake
uses: xmake-io/github-action-setup-xmake@e50494030a33fd120900e739f6418a48100cd6ce
with:
xmake-version: latest
actions-cache-folder: '.xmake-cache-${{ runner.os }}'
actions-cache-key: 'xmake-actions-cache-key-${{ runner.os }}-tests'
package-cache: true
package-cache-key: 'xmake-package-cache-key-${{ runner.os }}-tests'
project-path: '.'
- name: Run tests
run: |
xmake test -y -v
timeout-minutes: 30
- name: Check test coverage (Linux)
if: contains(runner.os, 'linux')
uses: threeal/gcovr-action@1b53388d5f84b4f3afb1b9082782961dff911ba0
check_examples:
name: Build and test examples
needs: [check_repository_cleanliness, lint_code]
strategy:
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Pull latest changes
run: git pull origin ${{ github.ref_name }} || true
- name: Setup Linux dependencies
if: contains(runner.os, 'linux')
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa-dev freeglut3-dev mesa-common-dev mesa-utils
- name: Setup Windows dependencies
if: contains(runner.os, 'windows')
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
- name: Install xmake
uses: xmake-io/github-action-setup-xmake@fadadea1162ec75ce1541d5bb68226fb147c221e
with:
xmake-version: latest
package-cache: true
project-path: '.'
build-cache: true
- name: Build and test examples
run: |
xmake f --all_examples=y -y -m debug
xmake build -y
xmake f --executable_examples=y -y -m debug
xmake run -y -v
timeout-minutes: 30