Skip to content

Commit 93ff398

Browse files
committed
Enhance CI with Android change detection and dependency tracking
- Added `check-android-changes` job to detect Android-related changes and conditionally trigger builds. - Introduced `vcpkg.json` for better dependency management. - Updated `install_dependencies_windows.bat` to utilize `vcpkg.json` for streamlined dependency installation.
1 parent b3bbff4 commit 93ff398

File tree

3 files changed

+82
-8
lines changed

3 files changed

+82
-8
lines changed

.github/workflows/workflow.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,70 @@ on:
88

99
jobs:
1010

11+
check-android-changes:
12+
name: Check Android Changes
13+
runs-on: ubuntu-latest
14+
outputs:
15+
should_build: ${{ steps.check.outputs.should_build }}
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0 # Fetch all history for all branches and tags
21+
22+
- name: Check for Android changes
23+
id: check
24+
run: |
25+
# For push events, check if workflow file has changed
26+
if [ "${{ github.event_name }}" == "push" ] && [ -n "${{ github.event.before }}" ] && [ -n "${{ github.event.after }}" ]; then
27+
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q ".github/workflows/workflow.yml"; then
28+
echo "Workflow file has changed, building Android"
29+
echo "should_build=true" >> $GITHUB_OUTPUT
30+
exit 0
31+
fi
32+
fi
33+
34+
# For pull requests, check the files changed in the PR
35+
if [ "${{ github.event_name }}" == "pull_request" ]; then
36+
echo "Checking files changed in pull request..."
37+
38+
# Check if PR has android label or title contains android
39+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'android') }}" == "true" || \
40+
"${{ contains(github.event.pull_request.title, 'android') }}" == "true" || \
41+
"${{ contains(github.event.pull_request.title, 'Android') }}" == "true" ]]; then
42+
echo "PR has android label or title contains android"
43+
echo "should_build=true" >> $GITHUB_OUTPUT
44+
exit 0
45+
fi
46+
47+
# Get the list of files changed in the PR
48+
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
49+
PR_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }})
50+
else
51+
# For pushes, check the files changed in the last commit
52+
echo "Checking files changed in push..."
53+
54+
# If this is the first commit, build Android
55+
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
56+
echo "First commit, building Android"
57+
echo "should_build=true" >> $GITHUB_OUTPUT
58+
exit 0
59+
fi
60+
61+
# Get the list of files changed in the push
62+
PR_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
63+
fi
64+
65+
# Check if any Android-related files have changed
66+
ANDROID_PATTERN="attachments/34_android.cpp|attachments/35_gltf_ktx.cpp|attachments/android/|attachments/27_shader_depth.(frag|vert)"
67+
if echo "$PR_FILES" | grep -E "$ANDROID_PATTERN"; then
68+
echo "Android-related files have changed"
69+
echo "should_build=true" >> $GITHUB_OUTPUT
70+
else
71+
echo "No Android-related files have changed"
72+
echo "should_build=false" >> $GITHUB_OUTPUT
73+
fi
74+
1175
build:
1276
strategy:
1377
fail-fast: false
@@ -337,6 +401,10 @@ jobs:
337401
name: Android Build
338402
runs-on: ubuntu-latest
339403

404+
# We need to run a preliminary job to check for changes
405+
needs: check-android-changes
406+
if: needs.check-android-changes.outputs.should_build == 'true'
407+
340408
steps:
341409
- uses: actions/checkout@v3
342410

scripts/install_dependencies_windows.bat

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,7 @@ if not exist %TEMP%\vcpkg-cache mkdir %TEMP%\vcpkg-cache
2323

2424
:: Install all dependencies at once using vcpkg with parallel installation
2525
echo Installing all dependencies...
26-
vcpkg install --triplet=x64-windows --x-manifest-root=%~dp0 --feature-flags=binarycaching,manifests --x-install-root=%VCPKG_INSTALLATION_ROOT%/installed ^
27-
glfw3 ^
28-
glm ^
29-
tinyobjloader ^
30-
stb ^
31-
tinygltf ^
32-
nlohmann-json ^
33-
ktx
26+
vcpkg install --triplet=x64-windows --x-manifest-root=%~dp0\.. --feature-flags=binarycaching,manifests --x-install-root=%VCPKG_INSTALLATION_ROOT%/installed
3427

3528
:: Remind about Vulkan SDK
3629
echo.

vcpkg.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "vulkan-tutorial",
3+
"version": "1.0.0",
4+
"dependencies": [
5+
"glfw3",
6+
"glm",
7+
"tinyobjloader",
8+
"stb",
9+
"tinygltf",
10+
"nlohmann-json",
11+
"ktx"
12+
]
13+
}

0 commit comments

Comments
 (0)