1+ name : Build and test
2+
3+ permissions :
4+ contents : write
5+
6+ on :
7+ pull_request :
8+ push :
9+ paths-ignore :
10+ - ' .github/workflows/coverage.yml'
11+ - ' .gitignore'
12+ - ' LICENSE'
13+ - ' CHANGELOG.md'
14+ - ' README.md'
15+
16+ jobs :
17+ build :
18+ strategy :
19+ fail-fast : false
20+ matrix :
21+ confs :
22+ - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x86, mode: debug, package: true, test: true, }
23+ - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x86, mode: releasedbg, package: true, test: true, }
24+ - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x64, mode: debug, package: true, test: true, }
25+ - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x64, mode: releasedbg, package: true, test: true, }
26+ - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: arm64, mode: debug, package: true, test: false, }
27+ - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: arm64, mode: releasedbg, package: true, test: false, }
28+ - { name: MinGW, runner: windows-latest, shell: 'msys2 {0}', plat: mingw, arch: i686, mode: debug, package: true, test: true, msystem: mingw32 }
29+ - { name: MinGW, runner: windows-latest, shell: 'msys2 {0}', plat: mingw, arch: i686, mode: releasedbg, package: true, test: true, msystem: mingw32 }
30+ - { name: MinGW, runner: windows-latest, shell: 'msys2 {0}', plat: mingw, arch: x86_64, mode: debug, package: true, test: true, msystem: mingw64 }
31+ - { name: MinGW, runner: windows-latest, shell: 'msys2 {0}', plat: mingw, arch: x86_64, mode: releasedbg, package: true, test: true, msystem: mingw64 }
32+ - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: true, test: true, }
33+ - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: false, test: true, config: --asan=y }
34+ - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: false, test: true, config: --lsan=y }
35+ - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: false, test: true, config: --tsan=y }
36+ - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: releasedbg, package: true, test: true, }
37+ - { name: Android NDK 25c, runner: ubuntu-latest, shell: bash, plat: android, arch: armeabi-v7a, mode: debug, package: false, test: false, ndk_ver: 25c, ndk_sdkver: 28 }
38+ - { name: Android NDK 25c, runner: ubuntu-latest, shell: bash, plat: android, arch: armeabi-v7a, mode: releasedbg, package: false, test: false, ndk_ver: 25c, ndk_sdkver: 28 }
39+ - { name: Android NDK 25c, runner: ubuntu-latest, shell: bash, plat: android, arch: arm64-v8a, mode: debug, package: false, test: false, ndk_ver: 25c, ndk_sdkver: 28 }
40+ - { name: Android NDK 25c, runner: ubuntu-latest, shell: bash, plat: android, arch: arm64-v8a, mode: releasedbg, package: false, test: false, ndk_ver: 25c, ndk_sdkver: 28 }
41+ - { name: Android NDK 26b, runner: ubuntu-latest, shell: bash, plat: android, arch: armeabi-v7a, mode: debug, package: true, test: false, ndk_ver: 26b, ndk_sdkver: 28 }
42+ - { name: Android NDK 26b, runner: ubuntu-latest, shell: bash, plat: android, arch: armeabi-v7a, mode: releasedbg, package: true, test: false, ndk_ver: 26b, ndk_sdkver: 28 }
43+ - { name: Android NDK 26b, runner: ubuntu-latest, shell: bash, plat: android, arch: arm64-v8a, mode: debug, package: true, test: false, ndk_ver: 26b, ndk_sdkver: 28 }
44+ - { name: Android NDK 26b, runner: ubuntu-latest, shell: bash, plat: android, arch: arm64-v8a, mode: releasedbg, package: true, test: false, ndk_ver: 26b, ndk_sdkver: 28 }
45+ - { name: macOS, runner: macos-latest, shell: bash, plat: macosx, arch: x86_64, mode: debug, package: true, test: true, }
46+ - { name: macOS, runner: macos-latest, shell: bash, plat: macosx, arch: x86_64, mode: releasedbg, package: true, test: true, }
47+ - { name: macOS, runner: macos-14, shell: bash, plat: macosx, arch: arm64, mode: debug, package: true, test: true, }
48+ - { name: macOS, runner: macos-14, shell: bash, plat: macosx, arch: arm64, mode: releasedbg, package: true, test: true, }
49+ - { name: iOS, runner: macos-latest, shell: bash, plat: iphoneos, arch: arm64, mode: debug, package: true, test: false, }
50+ - { name: iOS, runner: macos-latest, shell: bash, plat: iphoneos, arch: arm64, mode: releasedbg, package: true, test: false, }
51+ - { name: Emscripten, runner: ubuntu-latest, shell: bash, plat: wasm, arch: wasm32, mode: debug, package: true, test: false, }
52+ - { name: Emscripten, runner: ubuntu-latest, shell: bash, plat: wasm, arch: wasm32, mode: releasedbg, package: true, test: false, }
53+ - { name: Emscripten, runner: ubuntu-latest, shell: bash, plat: wasm, arch: wasm64, mode: debug, package: true, test: false, }
54+ - { name: Emscripten, runner: ubuntu-latest, shell: bash, plat: wasm, arch: wasm64, mode: releasedbg, package: true, test: false, }
55+ kind : [shared, static]
56+ exclude :
57+ - confs : { name: Emscripten }
58+ kind : shared
59+
60+ defaults :
61+ run :
62+ shell : ${{ matrix.confs.shell }}
63+
64+ name : ${{ matrix.confs.name }} ${{ matrix.confs.arch }} (${{ matrix.kind }} ${{ matrix.confs.mode }})
65+ runs-on : ${{ matrix.confs.runner }}
66+ if : ${{ !contains(github.event.head_commit.message, 'ci skip') }}
67+
68+ steps :
69+ - name : Checkout repository
70+ uses : actions/checkout@v6
71+
72+ # Install system dependencies
73+ - name : Setup Linux
74+ if : ${{ matrix.confs.plat == 'linux' }}
75+ run : |
76+ sudo apt-get update
77+ sudo apt-get -y install mesa-common-dev
78+
79+ # Setup Emsdk
80+ - name : Setup Emscripten
81+ if : ${{ matrix.confs.plat == 'wasm' }}
82+ uses : mymindstorm/setup-emsdk@v14
83+ with :
84+ version : 4.0.15
85+ actions-cache-folder : emsdk-cache-${{ matrix.confs.mode }}
86+
87+ # Setup MSYS2
88+ - name : Setup MSYS2
89+ if : ${{ matrix.confs.plat == 'mingw' }}
90+ uses : msys2/setup-msys2@v2
91+ with :
92+ msystem : ${{ matrix.confs.msystem }}
93+ install : base-devel git unzip p7zip mingw-w64-${{ matrix.confs.arch }}-toolchain mingw-w64-${{ matrix.confs.arch }}-xmake
94+ update : true
95+
96+ # Setup NDK
97+ - name : Setup Android NDK (${{ matrix.confs.ndk_ver }})
98+ if : ${{ matrix.confs.plat == 'android' }}
99+ run : |
100+ wget -q https://dl.google.com/android/repository/android-ndk-r${{ matrix.confs.ndk_ver }}-linux.zip
101+ unzip -q -o ./android-ndk-r${{ matrix.confs.ndk_ver }}-linux.zip
102+ echo "ADDITIONAL_CONF=--ndk=`pwd`/android-ndk-r${{ matrix.confs.ndk_ver }} --ndk_sdkver=${{ matrix.confs.ndk_sdkver }}" >> $GITHUB_ENV
103+
104+ - name : Get current date as package key
105+ id : cache_key
106+ run : echo "key=$(date +'%W')" >> $GITHUB_OUTPUT
107+ shell : bash
108+
109+ # Force xmake to a specific folder (for cache)
110+ - name : Set xmake global dir
111+ run : echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV
112+
113+ # Install xmake
114+ - name : Setup xmake
115+ if : ${{ matrix.confs.plat != 'mingw' }}
116+ uses : xmake-io/github-action-setup-xmake@v1
117+ with :
118+ xmake-version : latest
119+ actions-cache-folder : .xmake-cache-W${{ steps.cache_key.outputs.key }}
120+
121+ # Update xmake repository (in order to have the file that will be cached)
122+ - name : Update xmake repository
123+ run : xmake repo --update
124+
125+ # Fetch xmake dephash
126+ - name : Retrieve dependencies hash
127+ id : dep_hash
128+ run : echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT
129+
130+ # Restore xmake dependencies
131+ - name : Restore cached xmake dependencies
132+ id : restore-depcache
133+ uses : actions/cache/restore@v4
134+ with :
135+ path : ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
136+ key : ${{ matrix.confs.plat }}-${{ matrix.confs.arch }}-${{ matrix.confs.mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }}
137+
138+ # Setup platform configs
139+ - name : Setup platform config
140+ run : |
141+ PLATFORM_CONF=""
142+ if [ "${{ matrix.confs.test }}" == "true" ]; then
143+ PLATFORM_CONF="${PLATFORM_CONF} --tests=y" >> $GITHUB_ENV
144+ fi
145+ echo "ADDITIONAL_CONF=${{ env.ADDITIONAL_CONF }} $PLATFORM_CONF" >> $GITHUB_ENV
146+ FILENAME="concerto-reflection_${{ matrix.confs.plat }}_${{ matrix.confs.arch }}_${{ matrix.kind }}"
147+ if [ "${{ startsWith(github.event.ref, 'refs/tags/') }}" == "false" ]; then
148+ FILENAME="${FILENAME}_${{ matrix.confs.mode }}"
149+ fi
150+ if [ "${{ matrix.confs.plat }}" == "windows" ]; then
151+ FILENAME="${FILENAME}.zip"
152+ else
153+ FILENAME="${FILENAME}.tgz"
154+ fi
155+ echo "OUTPUT_FILE=$FILENAME" >> $GITHUB_ENV
156+
157+ # Setup compilation mode and install project dependencies
158+ - name : Configure xmake and install dependencies
159+ run : xmake config --plat=${{ matrix.confs.plat }} --arch=${{ matrix.confs.arch }} --kind=${{ matrix.kind }} --mode=${{ matrix.confs.mode }} ${{ env.ADDITIONAL_CONF }} --ccache=n --yes
160+
161+ # Save dependencies
162+ - name : Save cached xmake dependencies
163+ if : ${{ !steps.restore-depcache.outputs.cache-hit }}
164+ uses : actions/cache/save@v4
165+ with :
166+ path : ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
167+ key : ${{ steps.restore-depcache.outputs.cache-primary-key }}
168+
169+ # Build library and tests
170+ - name : Build library
171+ run : xmake
172+
173+ # Run unit tests
174+ - name : Run unit tests
175+ if : ${{ matrix.confs.test }}
176+ run : xmake run concerto-reflection-tests
177+
178+ - name : Install
179+ run : xmake install -vo concerto-reflection
180+
181+ # For some reason macOS-14 doesn't seem to have Python
182+ - uses : actions/setup-python@v6
183+ if : ${{ matrix.platform.runner == 'macos-14' }}
184+ with :
185+ python-version : " 3.11"
186+
187+ - name : Archive result
188+ uses : ihiroky/archive-action@v1
189+ with :
190+ root_dir : concerto-reflection
191+ file_path : ${{ env.OUTPUT_FILE }}
192+ verbose : true
193+
194+ # Nightly tags (for commits to main branch)
195+ - name : Upload binaries to release (Main)
196+ uses : svenstaro/upload-release-action@v2
197+ if : ${{ (github.ref == 'refs/heads/main') && github.event_name == 'push' && matrix.confs.package }}
198+ with :
199+ repo_token : ${{ secrets.GITHUB_TOKEN }}
200+ file : ${{ env.OUTPUT_FILE }}
201+ asset_name : ${{ env.OUTPUT_FILE }}
202+ tag : " 0.0.0-nightly"
203+ overwrite : true
204+ prerelease : true
205+
206+ # Release tags (for tags)
207+ - name : Upload binaries to release (Tag)
208+ uses : svenstaro/upload-release-action@v2
209+ if : ${{ startsWith(github.event.ref, 'refs/tags/') && matrix.confs.mode == 'releasedbg' && matrix.confs.package }}
210+ with :
211+ repo_token : ${{ secrets.GITHUB_TOKEN }}
212+ file : ${{ env.OUTPUT_FILE }}
213+ asset_name : ${{ env.OUTPUT_FILE }}
214+ tag : ${{ github.ref }}
215+ overwrite : true
0 commit comments