-
Notifications
You must be signed in to change notification settings - Fork 34
Ci fix android #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ci fix android #194
Changes from 62 commits
0f63ab6
a056c78
96e1809
934e046
1866f2c
cd66837
6bab1f4
8862f71
e0bbab5
619ccdc
20eb56e
a441a2a
68db8fc
422d4b2
d8371fd
705fcae
fbc18a2
4c73ce9
a94be73
94960e2
e3a9cf5
1dd30cb
fa27dad
57c0ea1
54125dc
65ead39
7d88430
f9b82c9
1d994ec
d41c4af
7889bab
83394dd
9377f27
5698133
8d3de9f
0fd1014
8c153d8
f812502
3ec779d
cb375e7
0c8ab0c
6f18051
bcea4a9
24f09a3
531b420
eb51a78
914e0c9
dec1c94
983cc75
eec2d04
fa44897
bc589bd
f3c27e0
6562040
f342d8a
326c233
3ca5fb3
5b3cc6e
8862ed3
db16e45
7d86ebf
56b24cd
4004717
0a8228b
6d6e0b9
c39bbf7
043fb6a
578647a
0a6deab
7d7ac2e
c346da0
e897c26
e762b71
248a31b
3af9a2a
2ecad25
7ec1d89
93acfe8
80d99f0
0433eba
cdb64e5
3378072
4be85f0
d3c9b6b
8a53097
fe12a95
c44dcfd
f17e890
13b27a8
75fe2a2
ad9a97d
9b408fa
aec34f9
319ccb6
390226c
fee886b
260ec4e
44f91a0
a5e7ce6
fa764f7
98eb91f
3fe440c
46cba0b
691d2b4
17046d9
e710383
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| name: 'Setup Android' | ||
| description: 'Sets up Java and Android SDK components' | ||
| inputs: | ||
| java-version: | ||
| description: 'Java version' | ||
| required: false | ||
| default: '17' | ||
| ndk-version: | ||
| description: 'Android NDK version' | ||
| required: true | ||
| cmake-version: | ||
| description: 'Android CMake version' | ||
| required: true | ||
| install-emulator: | ||
| description: 'Whether to install emulator packages' | ||
| required: false | ||
| default: 'false' | ||
| system-image: | ||
| description: 'Android system image package' | ||
| required: false | ||
| default: '' | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set up JDK | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: ${{ inputs.java-version }} | ||
|
|
||
| - name: Install Android SDK packages | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Initialize ANDROID_HOME if not set (standard on x86, missing on ARM) | ||
| if [ -z "${ANDROID_HOME:-}" ]; then | ||
| export ANDROID_HOME="$HOME/android-sdk" | ||
| mkdir -p "$ANDROID_HOME" | ||
| fi | ||
| echo "ANDROID_HOME=$ANDROID_HOME" >> "$GITHUB_ENV" | ||
|
|
||
| # Install command-line tools if missing | ||
| if [ ! -d "$ANDROID_HOME/cmdline-tools/latest" ]; then | ||
| echo "Downloading Android Command Line Tools..." | ||
| mkdir -p "$ANDROID_HOME/cmdline-tools" | ||
| curl -LSs https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -o cmdline-tools.zip | ||
| unzip -q cmdline-tools.zip -d "$ANDROID_HOME/cmdline-tools" | ||
| mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest" | ||
| rm cmdline-tools.zip | ||
| fi | ||
|
|
||
| SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" | ||
|
|
||
| packages=( | ||
| "ndk;${{ inputs.ndk-version }}" | ||
| "cmake;${{ inputs.cmake-version }}" | ||
| ) | ||
|
|
||
| #use emulator for test-android | ||
| if [ "${{ inputs.install-emulator }}" = "true" ]; then | ||
| packages+=("emulator") | ||
| packages+=("platform-tools") | ||
| if [ -n "${{ inputs.system-image }}" ]; then | ||
| packages+=("${{ inputs.system-image }}") | ||
| fi | ||
| fi | ||
|
|
||
| # Accept licenses | ||
| yes | "$SDKMANAGER" --sdk_root="$ANDROID_HOME" --licenses || true | ||
|
|
||
| "$SDKMANAGER" --sdk_root="$ANDROID_HOME" "${packages[@]}" | ||
|
|
||
| - name: Set Android environment variables | ||
| shell: bash | ||
| run: | | ||
| export NDK_PATH="$ANDROID_HOME/ndk/${{ inputs.ndk-version }}" | ||
| echo "ANDROID_NDK=$NDK_PATH" >> "$GITHUB_ENV" | ||
| echo "ANDROID_NDK_HOME=$NDK_PATH" >> "$GITHUB_ENV" | ||
| echo "ANDROID_NDK_ROOT=$NDK_PATH" >> "$GITHUB_ENV" | ||
| echo "ANDROID_HOME=$ANDROID_HOME" >> "$GITHUB_ENV" | ||
| echo "$ANDROID_HOME/cmake/${{ inputs.cmake-version }}/bin" >> "$GITHUB_PATH" | ||
| echo "$ANDROID_HOME/platform-tools" >> "$GITHUB_PATH" | ||
| echo "$ANDROID_HOME/cmdline-tools/latest/bin" >> "$GITHUB_PATH" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: 'Setup vcpkg for Android' | ||
| description: 'Setup vcpkg for Android workflow' | ||
| inputs: | ||
| vcpkg-path: | ||
| description: 'Path to vcpkg' | ||
| required: true | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Set VCPKG_ROOT | ||
| shell: bash | ||
| run: echo "VCPKG_ROOT=${{ github.workspace }}/${{ inputs.vcpkg-path }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Bootstrap vcpkg | ||
| shell: bash | ||
| run: ./bootstrap-vcpkg.sh -disableMetrics | ||
| working-directory: ${{ inputs.vcpkg-path }} | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,57 @@ | ||
| name: Build Android | ||
| on: [workflow_call, workflow_dispatch] | ||
|
|
||
| jobs: | ||
| build_android: | ||
| timeout-minutes: 30 | ||
| strategy: | ||
| matrix: | ||
| preset: ["android-arm64-v8a-host_linux-x64", "android-x64-host_linux-x64", "android-armeabi-v7a-host_linux-x64"] | ||
| build-type: [MinSizeRel] | ||
| timeout-minutes: 60 | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Checkout nakama-cpp | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: nakama-cpp | ||
| - uses: ./nakama-cpp/.github/actions/setup-vcpkg | ||
| submodules: false | ||
|
|
||
| - name: Checkout vcpkg submodule | ||
| run: | | ||
| git submodule update --init --filter=blob:none -- submodules/vcpkg | ||
| working-directory: nakama-cpp | ||
|
|
||
| - uses: ./nakama-cpp/.github/actions/setup-android | ||
| with: | ||
| github_token: ${{ secrets.github_token }} | ||
| vcpkg-path: vcpkg | ||
| - uses: ./nakama-cpp/.github/actions/setup-ubuntu | ||
| - uses: ./nakama-cpp/.github/actions/build-library-and-upload | ||
| ndk-version: 27.2.12479018 | ||
| cmake-version: 4.0.2 | ||
|
|
||
| - uses: ./nakama-cpp/.github/actions/setup-vcpkg-android | ||
| with: | ||
| nakama-cpp-path: nakama-cpp | ||
| preset: ${{ matrix.preset }} | ||
| build-type: ${{ matrix.build-type }} | ||
| - if: failure() | ||
| uses: ./nakama-cpp/.github/actions/handle-failure | ||
| vcpkg-path: nakama-cpp/submodules/vcpkg | ||
|
|
||
| - name : Build with Gradle | ||
| run : ./gradlew build --no-daemon | ||
| working-directory: nakama-cpp/android | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| nakama-cpp-path: nakama-cpp | ||
| vcpkg-path: vcpkg | ||
| name: nakama-sdk-android-aar | ||
| path: nakama-cpp/android/nakama-sdk/build/outputs/aar/*.aar | ||
| if-no-files-found: error | ||
|
|
||
| # - name: Install NDK & CMake | ||
|
VBorisof marked this conversation as resolved.
Outdated
|
||
| # run: | | ||
| # # On GitHub ubuntu runners ANDROID_HOME is set as a shell env var. | ||
| # # sdkmanager is NOT on PATH, use the full path. | ||
| # "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \ | ||
| # --sdk_root="$ANDROID_HOME" \ | ||
| # "ndk;27.2.12479018" \ | ||
| # "cmake;4.0.2" | ||
|
|
||
| # - name: Add CMake to PATH | ||
| # run: echo "$ANDROID_HOME/cmake/4.0.2/bin" >> "$GITHUB_PATH" | ||
|
|
||
| # - name: Set VCPKG_ROOT | ||
| # run: echo "VCPKG_ROOT=$GITHUB_WORKSPACE/nakama-cpp/submodules/vcpkg" >> $GITHUB_ENV | ||
|
|
||
| # - name: Bootstrap vcpkg | ||
| # run: ./bootstrap-vcpkg.sh -disableMetrics | ||
| # working-directory: nakama-cpp/submodules/vcpkg | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Test Android | ||
| on: [workflow_call, workflow_dispatch, pull_request] | ||
|
|
||
| jobs: | ||
| test_android: | ||
| timeout-minutes: 90 | ||
|
VBorisof marked this conversation as resolved.
Outdated
|
||
| runs-on: ubuntu-22.04 | ||
| env: | ||
| ABI: x86_64 | ||
| CMAKE_PRESET: android-x86_64 | ||
|
upwelling-twll marked this conversation as resolved.
|
||
|
|
||
| steps: | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '17' | ||
|
upwelling-twll marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Checkout nakama-cpp | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: nakama-cpp | ||
| submodules: false | ||
|
|
||
| - name: Checkout vcpkg submodule | ||
| run: | | ||
| git submodule update --init --filter=blob:none -- submodules/vcpkg | ||
|
Comment on lines
+31
to
+33
|
||
| working-directory: nakama-cpp | ||
|
|
||
| - uses: ./nakama-cpp/.github/actions/setup-android | ||
| with: | ||
| ndk-version: 27.2.12479018 | ||
| cmake-version: 4.0.2 | ||
| install-emulator: true | ||
| system-image: "system-images;android-29;google_apis;x86_64" | ||
|
|
||
| - uses: ./nakama-cpp/.github/actions/setup-vcpkg-android | ||
| with: | ||
| vcpkg-path: nakama-cpp/submodules/vcpkg | ||
|
|
||
| - name: Start Nakama server | ||
| run: docker compose -f integrationtests/server/docker-compose.yml up -d --build --wait | ||
| working-directory: nakama-cpp | ||
|
|
||
| - name: Install Task | ||
| run: npm install -g @go-task/cli | ||
|
|
||
| - name: Run tests on emulator | ||
| uses: reactivecircus/android-emulator-runner@v2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pin this third-party action to commit SHA pls
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @novabyte Wondering about licensing implications of this. The runner itself is Apache-2, but the sdk it pulls, especially the google_apis bit might be subject to stricter licensing?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done |
||
| with: | ||
| api-level: 29 | ||
| target: google_apis | ||
| arch: x86_64 | ||
| force-avd-creation: false | ||
| emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -memory 4096 -cores 2 | ||
| disable-animations: true | ||
| timeout: 50 | ||
| script: | | ||
| set -xe && for port in 7349 7350 7351; do adb reverse tcp:$port tcp:$port; done && cd nakama-cpp && sleep 30 && task test-android ABI=$ABI CMAKE_EXTRA="-DCMAKE_ANDROID_ARCH_ABI=$ABI -DANDROID_ABI=$ABI" | ||
|
upwelling-twll marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is line 65 in Taskfile |
||
Uh oh!
There was an error while loading. Please reload this page.