Skip to content

Commit e7fc87e

Browse files
committed
CMake: Update CI
Replaced some manual shell commands to detect changes with tj-actions/changed-files@v45 Duplicated the ci.yml into ci-scons.yml and ci-cmake.yml conditionally run the CI depending on what files change.
1 parent 9aefe09 commit e7fc87e

File tree

6 files changed

+249
-57
lines changed

6 files changed

+249
-57
lines changed

.github/actions/setup-godot-cpp/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ inputs:
2222
ndk-version:
2323
default: r23c
2424
description: Android NDK version.
25+
buildtool:
26+
description: scons or cmake
2527
scons-version:
2628
default: 4.4.0
2729
description: SCons version.
2830

31+
2932
runs:
3033
using: composite
3134
steps:
@@ -55,8 +58,13 @@ runs:
5558
version: ${{ inputs.mingw-version }}
5659

5760
- name: Setup SCons
61+
if: ${{ inputs.buildtool == 'scons' }}
5862
shell: bash
5963
run: |
6064
python -c "import sys; print(sys.version)"
6165
python -m pip install scons==${{ inputs.scons-version }}
6266
scons --version
67+
68+
- name: Install Ninja
69+
if: ${{ inputs.buildtool == 'cmake' }}
70+
uses: ashutoshvarma/setup-ninja@master

.github/workflows/ci-cmake.yml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: Continuous integration
2+
on:
3+
workflow_call:
4+
5+
env:
6+
# Only used for the cache key. Increment version to force clean build.
7+
GODOT_BASE_BRANCH: master
8+
# Used to select the version of Godot to run the tests with.
9+
GODOT_TEST_VERSION: master
10+
# Use UTF-8 on Linux.
11+
LANG: en_US.UTF-8
12+
LC_ALL: en_US.UTF-8
13+
14+
concurrency:
15+
group: ci-cmake-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build-cmake:
20+
name: ${{ matrix.name }}
21+
runs-on: ${{ matrix.os }}
22+
env:
23+
EM_VERSION: 3.1.39
24+
config-flags:
25+
-DCMAKE_C_COMPILER_LAUNCHER=sccache
26+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
27+
-DGODOTCPP_ENABLE_TESTING=ON
28+
-DGODOTCPP_BUILD_PROFILE="test/build_profile.json"
29+
SCCACHE_GHA_ENABLED: "true"
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- name: 🐧 Linux (GCC, Makefiles)
36+
os: ubuntu-22.04
37+
platform: linux
38+
config-flags: -DCMAKE_BUILD_TYPE=Release
39+
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release.cmake
40+
artifact-path: cmake-build/bin/libgodot-cpp.linux.template_release.x86_64.a
41+
run-tests: true
42+
43+
- name: 🐧 Linux (GCC, Makefiles, Double Precision)
44+
os: ubuntu-22.04
45+
platform: linux
46+
config-flags: -DCMAKE_BUILD_TYPE=Release -DGODOTCPP_PRECISION=double
47+
artifact-name: godot-cpp-linux-glibc2.27-x86_64-double-release.cmake
48+
artifact-path: cmake-build/bin/libgodot-cpp.linux.template_release.double.x86_64.a
49+
flags: precision=double
50+
run-tests: false
51+
52+
- name: 🏁 Windows (x86_64, MSVC)
53+
os: windows-2019
54+
platform: windows
55+
compiler: msvc
56+
build-flags: --config Release
57+
artifact-name: godot-cpp-windows-msvc2019-x86_64-release.cmake
58+
artifact-path: cmake-build/bin/libgodot-cpp.windows.template_release.x86_64.lib
59+
run-tests: false
60+
61+
- name: 🏁 Windows (x86_64, MinGW, Ninja)
62+
os: windows-2019
63+
platform: windows
64+
compiler: mingw
65+
config-flags: -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=cc -DCMAKE_CXX_COMPILER=c++
66+
artifact-name: godot-cpp-linux-mingw-x86_64-release.cmake
67+
artifact-path: cmake-build/bin/libgodot-cpp.windows.template_release.x86_64.a
68+
run-tests: false
69+
70+
- name: 🍎 macOS (universal, Makefiles)
71+
os: macos-latest
72+
platform: macos
73+
config-flags: -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
74+
artifact-name: godot-cpp-macos-universal-release.cmake
75+
artifact-path: cmake-build/bin/libgodot-cpp.macos.template_release.universal.a
76+
run-tests: false
77+
78+
- name: 🤖 Android (arm64, Ninja)
79+
os: ubuntu-22.04
80+
platform: android
81+
config-flags:
82+
-G Ninja -DCMAKE_BUILD_TYPE=Release
83+
--toolchain ${ANDROID_HOME}/ndk/23.2.8568313/build/cmake/android.toolchain.cmake
84+
-DANDROID_PLATFORM=21 -DANDROID_ABI=arm64-v8a
85+
artifact-name: godot-cpp-android-arm64-release.cmake
86+
artifact-path: cmake-build/bin/libgodot-cpp.android.template_release.arm64.a
87+
flags: arch=arm64
88+
run-tests: false
89+
90+
- name: 🍏 iOS (arm64, XCode)
91+
os: macos-latest
92+
platform: ios
93+
config-flags: -G Xcode -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO -DCMAKE_BUILD_TYPE=Release
94+
artifact-name: godot-cpp-ios-arm64-release.cmake
95+
artifact-path: cmake-build/bin/libgodot-cpp.ios.template_release.arm64.a
96+
flags: arch=arm64
97+
run-tests: false
98+
99+
- name: 🌐 Web (wasm32, Ninja)
100+
os: ubuntu-22.04
101+
platform: web
102+
config-flags:
103+
-G Ninja -DCMAKE_BUILD_TYPE=Release
104+
--toolchain ${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
105+
artifact-name: godot-cpp-web-wasm32-release.cmake
106+
artifact-path: cmake-build/bin/libgodot-cpp.web.template_release.wasm32.a
107+
run-tests: false
108+
109+
steps:
110+
- name: Checkout
111+
uses: actions/checkout@v4
112+
with:
113+
submodules: recursive
114+
115+
- name: Run sccache-cache
116+
uses: mozilla-actions/[email protected]
117+
118+
- name: Setup godot-cpp
119+
uses: ./.github/actions/setup-godot-cpp
120+
with:
121+
platform: ${{ matrix.platform }}
122+
windows-compiler: ${{ matrix.compiler }}
123+
buildtool: cmake
124+
125+
- name: Configure
126+
run: >
127+
cmake --log-level=VERBOSE -S . -B cmake-build ${{ env.config-flags }} ${{ matrix.config-flags }}
128+
129+
- name: Build test.template_debug
130+
run: >
131+
cmake --build cmake-build --verbose --target godot-cpp.test.template_debug ${{ matrix.build-flags }}
132+
133+
- name: Build test.template_release
134+
run: >
135+
cmake --build cmake-build --verbose --target godot-cpp.test.template_release ${{ matrix.build-flags }}
136+
137+
- name: Run sccache stat for check
138+
shell: bash
139+
run: ${SCCACHE_PATH} --show-stats
140+
141+
- name: Download latest Godot artifacts
142+
uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9
143+
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
144+
with:
145+
repo: godotengine/godot
146+
branch: master
147+
event: push
148+
workflow: linux_builds.yml
149+
workflow_conclusion: success
150+
name: linux-editor-mono
151+
search_artifacts: true
152+
check_artifacts: true
153+
ensure_latest: true
154+
path: godot-artifacts
155+
156+
- name: Prepare Godot artifacts for testing
157+
if: matrix.run-tests && env.GODOT_TEST_VERSION == 'master'
158+
run: |
159+
chmod +x ./godot-artifacts/godot.linuxbsd.editor.x86_64.mono
160+
echo "GODOT=$(pwd)/godot-artifacts/godot.linuxbsd.editor.x86_64.mono" >> $GITHUB_ENV
161+
162+
- name: Download requested Godot version for testing
163+
if: matrix.run-tests && env.GODOT_TEST_VERSION != 'master'
164+
run: |
165+
wget "https://github.com/godotengine/godot-builds/releases/download/${GODOT_TEST_VERSION}/Godot_v${GODOT_TEST_VERSION}_linux.x86_64.zip" -O Godot.zip
166+
unzip -a Godot.zip
167+
chmod +x "Godot_v${GODOT_TEST_VERSION}_linux.x86_64"
168+
echo "GODOT=$(pwd)/Godot_v${GODOT_TEST_VERSION}_linux.x86_64" >> $GITHUB_ENV
169+
170+
- name: Run tests
171+
if: matrix.run-tests
172+
run: |
173+
$GODOT --headless --version
174+
cd test
175+
# Need to run the editor so .godot is generated... but it crashes! Ignore that :-)
176+
(cd project && (timeout 30 $GODOT --import --headless >/dev/null 2>&1 || true))
177+
./run-tests.sh
178+
179+
- name: Upload artifact
180+
uses: actions/upload-artifact@v4
181+
with:
182+
name: ${{ matrix.artifact-name }}
183+
path: ${{ matrix.artifact-path }}
184+
if-no-files-found: error

.github/workflows/ci.yml renamed to .github/workflows/ci-scons.yml

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ env:
1212
LC_ALL: en_US.UTF-8
1313

1414
concurrency:
15-
group: ci-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}
15+
group: ci-scons-${{ github.actor }}-${{ github.head_ref || github.run_number }}-${{ github.ref }}
1616
cancel-in-progress: true
1717

1818
jobs:
19-
build:
19+
build-scons:
2020
name: ${{ matrix.name }}
2121
runs-on: ${{ matrix.os }}
2222
strategy:
@@ -113,6 +113,7 @@ jobs:
113113
with:
114114
platform: ${{ matrix.platform }}
115115
windows-compiler: ${{ contains(matrix.flags, 'use_mingw=yes') && 'mingw' || 'msvc' }}
116+
buildtool: scons
116117

117118
- name: Generate godot-cpp sources only
118119
run: |
@@ -183,40 +184,3 @@ jobs:
183184
name: ${{ matrix.artifact-name }}
184185
path: ${{ matrix.artifact-path }}
185186
if-no-files-found: error
186-
187-
linux-cmake-ninja:
188-
name: 🐧 Build (Linux, GCC, CMake Ninja)
189-
runs-on: ubuntu-22.04
190-
steps:
191-
- name: Checkout
192-
uses: actions/checkout@v4
193-
with:
194-
submodules: recursive
195-
196-
- name: Install dependencies
197-
run: |
198-
sudo apt-get update -qq
199-
sudo apt-get install -qqq build-essential pkg-config cmake ninja-build
200-
201-
- name: Build test GDExtension library
202-
run: |
203-
mkdir cmake-build
204-
cd cmake-build
205-
cmake ../ -DGODOTCPP_ENABLE_TESTING=YES
206-
cmake --build . --verbose -j $(nproc) -t godot-cpp.test.template_release --config Release
207-
208-
windows-msvc-cmake:
209-
name: 🏁 Build (Windows, MSVC, CMake)
210-
runs-on: windows-2019
211-
steps:
212-
- name: Checkout
213-
uses: actions/checkout@v4
214-
with:
215-
submodules: recursive
216-
217-
- name: Build test GDExtension library
218-
run: |
219-
mkdir cmake-build
220-
cd cmake-build
221-
cmake ../ -DGODOTCPP_ENABLE_TESTING=YES
222-
cmake --build . --verbose -t godot-cpp.test.template_release --config Release

.github/workflows/runner.yml

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,57 @@ jobs:
99
# First stage: Only static checks, fast and prevent expensive builds from running.
1010

1111
static-checks:
12-
if: '!vars.DISABLE_GODOT_CI'
1312
name: 📊 Static Checks
13+
if: '!vars.DISABLE_GODOT_CI'
1414
uses: ./.github/workflows/static_checks.yml
1515

16-
# Second stage: Run all the builds and some of the tests.
17-
18-
ci:
19-
name: 🛠️ Continuous Integration
16+
# Second stage: Review code changes
17+
changes:
18+
name: Analyze Changes
2019
needs: static-checks
21-
uses: ./.github/workflows/ci.yml
20+
runs-on: ubuntu-latest
21+
outputs:
22+
sources: ${{ steps.filter.outputs.sources_any_changed }}
23+
scons: ${{ steps.filter.outputs.scons_any_changed }}
24+
cmake: ${{ steps.filter.outputs.cmake_any_changed }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
- uses: tj-actions/changed-files@v45
30+
id: filter
31+
with:
32+
files_yaml: |
33+
sources:
34+
- '.github/workflows/*.yml'
35+
- '**/*.py'
36+
- '**/*.cpp'
37+
- '**/*.h'
38+
- 'test/build_profile.json'
39+
- 'gdextension/extension_api.json'
40+
scons:
41+
- '**/SConstruct'
42+
- '**/SCsub'
43+
- '**/*.py'
44+
cmake:
45+
- '**/CMakeLists.txt'
46+
- '**/*.cmake'
47+
- name: echo sources changed
48+
run: |
49+
echo sources ${{ steps.filter.outputs.sources_any_modified }}
50+
echo scons ${{ steps.filter.outputs.scons_any_modified }}
51+
echo cmake ${{ steps.filter.outputs.cmake_any_modified }}
52+
53+
# Third stage: Run all the builds and some of the tests.
54+
55+
ci-scons:
56+
name: 🛠️ SCons CI
57+
needs: changes
58+
if: ${{ needs.changes.outputs.scons == 'true' || needs.changes.outputs.sources == 'true' }}
59+
uses: ./.github/workflows/ci-scons.yml
60+
61+
ci-cmake:
62+
name: 🛠️ CMake CI
63+
needs: changes
64+
if: ${{ needs.changes.outputs.cmake == 'true' || needs.changes.outputs.sources == 'true' }}
65+
uses: ./.github/workflows/ci-cmake.yml

.github/workflows/static_checks.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@ jobs:
1717
fetch-depth: 2
1818

1919
- name: Get changed files
20-
env:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
run: |
23-
if [ "${{ github.event_name }}" == "pull_request" ]; then
24-
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
25-
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
26-
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
27-
fi
28-
files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
29-
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
20+
id: changed-files
21+
uses: tj-actions/changed-files@v45
3022

3123
- name: Style checks via pre-commit
3224
uses: pre-commit/[email protected]
3325
with:
34-
extra_args: --verbose --hook-stage manual --files ${{ env.CHANGED_FILES }}
26+
extra_args: --verbose --hook-stage manual --files ${{ steps.changed-files.outputs.all_changed_files }}
3527

3628
- name: Check generated files consistency
3729
run:

cmake/godotcpp.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function(godotcpp_generate)
285285
string(
286286
CONCAT
287287
SYSTEM_NAME
288-
"$<$<PLATFORM_ID:Android>:android.${ANDROID_ABI}>"
288+
"$<$<PLATFORM_ID:Android>:android>"
289289
"$<$<PLATFORM_ID:iOS>:ios>"
290290
"$<$<PLATFORM_ID:Linux>:linux>"
291291
"$<$<PLATFORM_ID:Darwin>:macos>"

0 commit comments

Comments
 (0)