diff --git a/.github/workflows/build-quick.yml b/.github/workflows/build-quick.yml index 97d28aedb..87cb3a18d 100644 --- a/.github/workflows/build-quick.yml +++ b/.github/workflows/build-quick.yml @@ -22,13 +22,51 @@ concurrency: cancel-in-progress: true jobs: + # We want to generate our matrix dynamically + # Initial job generates the matrix as a JSON, and following job will use deserialize and use the result + matrix_prep: + # Do not run the scheduled jobs on forks + if: (github.event_name == 'schedule' && github.repository == 'ankidroid/Anki-Android-Backend') || (github.event_name != 'schedule') + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.build-matrix.outputs.result }} + steps: + - id: build-matrix + uses: actions/github-script@v7 + with: + script: | + // by default, we will include all 3 platforms we test on + // "latest" would be easy everywhere, but "macos-15" isn't "latest" so we are specific there + let osArray = ["ubuntu-latest", "macos-15", "windows-latest"] + + let includeArray = []; + for(const os of osArray) { + // we do this work to define 'name' so we don't need to update branch protection rules + // if the os changes, the name is used in the expanded workflow run name, which is then + // used as a "required check" on branch protection merge rules, this keeps it stable + // even if "macos-15" changes to "macos-latest" in the future so we just change the list here + // but don't have to go into organization settings / protection rules etc etc + includeArray.push({"os": os, "name": os.split('-')[0]}); + } + return { + "os": osArray, + "include": includeArray, + } + - name: Debug Output + run: echo "${{ steps.build-matrix.outputs.result }}" + + # This uses the matrix generated from the matrix-prep stage build: + needs: matrix_prep + # Do not run the scheduled jobs on forks + if: (github.event_name == 'schedule' && github.repository == 'ankidroid/Anki-Android-Backend') || (github.event_name != 'schedule') strategy: - matrix: - os: [ubuntu-22.04, windows-latest, macos-14] fail-fast: false + matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}} runs-on: ${{ matrix.os }} timeout-minutes: 80 + # Stable name so branch protection required checks set is stable regardless of runner version (-latest, -15, etc) + name: build (${{ matrix.name }}) steps: - name: Liberate disk space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -57,12 +95,16 @@ jobs: c:\msys64\usr\bin\pacman.exe -S --noconfirm git rsync rm -force c:\msys64\usr\bin\zstd.exe - - name: Enable KVM group perms (Ubuntu) + - name: Ubuntu setup + # We get KVM set up on Ubuntu as we run the emulator there (only platform with nested virt) + # We also install some system software needed for the build on ubuntu if: contains(matrix.os, 'ubuntu') run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules sudo udevadm control --reload-rules sudo udevadm trigger --name-match=kvm + sudo apt update + sudo apt -y install liblzma-dev - name: Fetch submodules run: git submodule update --init @@ -132,7 +174,7 @@ jobs: # Builds on other branches will only read from main branch cache writes # Comment this and the with: above out for performance testing on a branch cache-read-only: ${{ github.ref != 'refs/heads/main' }} - gradle-home-cache-cleanup: true + cache-cleanup: true - name: Build all (current platform) # Ubuntu currently requires multiple build attempts before it succeeds - it builds a little further each time then works @@ -167,10 +209,16 @@ jobs: target: default arch: x86_64 profile: Nexus 6 - script: ./gradlew rsdroid-instrumented:connectedCheck + script: | + touch adb-log.txt + $ANDROID_HOME/platform-tools/adb logcat '*:D' >> adb-log.txt & + adb emu screenrecord start --time-limit 1800 video.webm + sleep 5 + ./gradlew rsdroid-instrumented:connectedCheck - name: Upload rsdroid AAR as artifact uses: actions/upload-artifact@v4 + if: ${{ always() }} with: name: rsdroid-aar-${{ matrix.os }} if-no-files-found: error @@ -178,11 +226,26 @@ jobs: - name: Upload rsdroid-robo JAR as artifact uses: actions/upload-artifact@v4 + if: ${{ always() }} with: name: rsdroid-robo-${{ matrix.os }} if-no-files-found: error path: rsdroid-testing/build/libs + - name: Upload Emulator Log + uses: actions/upload-artifact@v4 + if: always() + with: + name: ${{ matrix.name }}-adb_logs + path: adb-log.txt + + - name: Upload Emulator Screen Record + uses: actions/upload-artifact@v4 + if: always() + with: + name: ${{ matrix.name }}-adb_video + path: video.webm + - name: Save Rust Cache (Windows) uses: actions/cache/save@v4 if: contains(matrix.os, 'windows') && github.ref == 'refs/heads/main' diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 6f62013ae..ada54d78c 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -28,7 +28,7 @@ concurrency: jobs: build: - runs-on: macos-14 + runs-on: macos-15 timeout-minutes: 180 steps: - uses: actions/checkout@v4 @@ -85,7 +85,7 @@ jobs: # Builds on other branches will only read from main branch cache writes # Comment this and the with: above out for performance testing on a branch cache-read-only: ${{ github.ref != 'refs/heads/main' }} - gradle-home-cache-cleanup: true + cache-cleanup: true - name: Build all # We use retries as the build fetches network resources and those may flake diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fdb8043f6..033dcaa22 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -27,7 +27,7 @@ jobs: # - https://gh.io/supported-runners-and-hardware-resources # - https://gh.io/using-larger-runners (GitHub.com only) # Consider using larger runners or machines with greater resources for possible analysis time improvements. - runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-22.04' }} + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} permissions: # required for all workflows @@ -77,18 +77,11 @@ jobs: # to build your code. # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # We need a great deal of pre-build stuff for the Java to work, because it relies on the Rust working... - - name: Liberate disk space (Ubuntu) - if: matrix.build-mode == 'manual' - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - android: false - dotnet: true - haskell: true - large-packages: false - docker-images: true - swap-storage: false + - name: Ubuntu setup + # We also install some system software needed for the build on ubuntu + run: | + sudo apt update + sudo apt -y install liblzma-dev - name: Fetch submodules if: matrix.build-mode == 'manual' @@ -135,7 +128,7 @@ jobs: # Builds on other branches will only read from main branch cache writes # Comment this and the with: above out for performance testing on a branch cache-read-only: ${{ github.ref != 'refs/heads/main' }} - gradle-home-cache-cleanup: true + cache-cleanup: true - name: Build all (current platform) if: matrix.build-mode == 'manual'