From 7c63164103c2529881d37f7d917f7614b5bbd5a4 Mon Sep 17 00:00:00 2001 From: Damontecres Date: Wed, 5 Nov 2025 16:20:32 -0500 Subject: [PATCH] CI for mpv builds --- .github/actions/native-build.yml | 65 ++++++++++++++++++++++++++++++++ .github/actions/setup.yml | 26 +++++++++++++ .github/workflows/pr.yml | 42 +++------------------ 3 files changed, 96 insertions(+), 37 deletions(-) create mode 100644 .github/actions/native-build.yml create mode 100644 .github/actions/setup.yml diff --git a/.github/actions/native-build.yml b/.github/actions/native-build.yml new file mode 100644 index 00000000..942c9c0f --- /dev/null +++ b/.github/actions/native-build.yml @@ -0,0 +1,65 @@ +name: "Native build" +description: "Performs native builds" +inputs: + cache: + description: "Whether to use the cache or not" + required: true +runs: + using: "composite" + steps: + - name: Load ffmpeg module cache + id: cache_ffmpeg_module + if: ${{ inputs.cache }} + uses: actions/cache/restore@v4 + with: + path: | + app/libs + key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/libs.versions.toml', '**/build_ffmpeg_decoder.sh') }} + - name: Build ffmpeg decoder + id: ffmpeg-decoder + if: steps.cache_ffmpeg_module.outputs.cache-hit != 'true' + run: | + ./build_ffmpeg_decoder.sh "${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.NDK_VERSION }}" + - name: Save ffmpeg module cache + id: cache_ffmpeg_module_save + uses: actions/cache/save@v4 + with: + path: | + app/libs + key: ${{ steps.cache_ffmpeg_module.outputs.cache-primary-key }} + + - name: Load libmpv module cache + id: cache_libmpv_module + if: ${{ inputs.cache }} + uses: actions/cache/restore@v4 + with: + path: | + app/src/main/libs + key: ${{ runner.os }}-libmpv-${{ hashFiles('**/scripts/mpv/*.sh', '**/scripts/mpv/include/*', '**/scripts/mpv/scripts/*') }} + + - name: Install python dependencies + if: steps.cache_libmpv_module.outputs.cache-hit != 'true' + run: | + python -m pip install --upgrade pip + pip install jsonschema jinja2 meson + - name: Get libmpv dependencies + if: steps.cache_libmpv_module.outputs.cache-hit != 'true' + run: | + cd scripts/mpv + ./get_dependencies + - name: Build libmpv dependencies + if: steps.cache_libmpv_module.outputs.cache-hit != 'true' + run: | + cd scripts/mpv + ./buildall.sh --clean --arch arm64 mpv + ./buildall.sh mpv + cd ../.. + env PREFIX32="$(realpath prefix/armv7l)" PREFIX64="$(realpath prefix/arm64)" ndk-build -C app/src/main -j + ln -s app/src/main/libs app/src/main/jnilibs + - name: Save libmpv module cache + id: cache_libmpv_module_save + uses: actions/cache/save@v4 + with: + path: | + app/src/main/libs + key: ${{ steps.cache_libmpv_module.outputs.cache-primary-key }} diff --git a/.github/actions/setup.yml b/.github/actions/setup.yml new file mode 100644 index 00000000..826ac70d --- /dev/null +++ b/.github/actions/setup.yml @@ -0,0 +1,26 @@ +name: Setup +description: "Setup the environment" + +runs: + using: "composite" + steps: + - name: Checkout the code + uses: actions/checkout@v5 + with: + fetch-depth: 0 # Need the tags to build + # Setup the SDKs + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + - name: Setup JDK + uses: actions/setup-java@v5 + with: + distribution: zulu + java-version: '21' + cache: 'gradle' + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + with: + packages: "tools platform-tools build-tools;36.0.0 ndk;29.0.14206865" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 69b1ea1b..1e9a429a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,10 +8,7 @@ defaults: shell: bash env: - BUILD_TOOLS_VERSION: 36.0.0 BUILD_DIRS_ARTIFACT: build-dirs - NDK_VERSION: "29.0.14206865" - jobs: pre-commit: @@ -32,41 +29,12 @@ jobs: runs-on: ubuntu-latest needs: pre-commit steps: - - name: Checkout the code - uses: actions/checkout@v5 + - name: Setup + uses: ./.github/actions/setup.yml + - name: Native build + uses: ./.github/actions/native-build.yml with: - fetch-depth: 0 # Need the tags to build - - name: Setup JDK - uses: actions/setup-java@v5 - with: - distribution: zulu - java-version: '21' - cache: 'gradle' - - name: Setup Android SDK - uses: android-actions/setup-android@v3 - with: - packages: "tools platform-tools build-tools;${{ env.BUILD_TOOLS_VERSION }} ndk;${{ env.NDK_VERSION }}" - - - name: Load ffmpeg module cache - id: cache_ffmpeg_module - uses: actions/cache/restore@v4 - with: - path: | - app/libs - key: ${{ runner.os }}-ffmpeg-${{ hashFiles('**/libs.versions.toml', '**/build_ffmpeg_decoder.sh') }} - - name: Build ffmpeg decoder - id: ffmpeg-decoder - if: steps.cache_ffmpeg_module.outputs.cache-hit != 'true' - run: | - ./build_ffmpeg_decoder.sh "${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.NDK_VERSION }}" - - name: Save ffmpeg module cache - id: cache_ffmpeg_module_save - uses: actions/cache/save@v4 - with: - path: | - app/libs - key: ${{ steps.cache_ffmpeg_module.outputs.cache-primary-key }} - + cache: true - name: Build app id: buildapp run: |