Send proper Accept headers for XML, make JSON content negotiation optional
#636
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: synctools tests | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| paths: &paths | |
| - 'synctools/**' | |
| - 'gradle/libs.versions.toml' | |
| pull_request: | |
| paths: *paths | |
| concurrency: | |
| group: ${{github.workflow_ref}}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| compile: | |
| name: Compile and cache | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: 21 # keep in sync with gradle/gradle-daemon-jvm.properties | |
| # See https://community.gradle.org/github-actions/docs/setup-gradle/ for more information | |
| - uses: gradle/actions/setup-gradle@v6 # creates build cache when on main branch | |
| with: | |
| cache-encryption-key: ${{ secrets.gradle_encryption_key }} | |
| - run: ./gradlew --build-cache --configuration-cache synctools:compileDebugSources | |
| test: | |
| needs: compile | |
| if: ${{ !cancelled() }} # even if compile didn't run (because not on main branch) | |
| name: Unit tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: 21 # keep in sync with gradle/gradle-daemon-jvm.properties | |
| - uses: gradle/actions/setup-gradle@v6 | |
| with: | |
| cache-encryption-key: ${{ secrets.gradle_encryption_key }} | |
| cache-read-only: true | |
| - name: Run lint | |
| run: ./gradlew --build-cache --configuration-cache synctools:lintDebug | |
| - name: Run unit tests | |
| run: ./gradlew --build-cache --configuration-cache synctools:testDebugUnitTest | |
| test_on_emulator: | |
| needs: compile | |
| if: ${{ !cancelled() }} # even if compile didn't run (because not on main branch) | |
| name: Instrumented tests (API ${{ matrix.api-level }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| api-level: | |
| # - 24 # Android 7 (minSdk level; not supported by gradle-managed devices) | |
| # - 27 # the lowest supported version by GMD; doesn't work for some reason | |
| - 30 # Android 11 # Android 11 is the latest version where calendar provider doesn't match millisecond occurrences of recurring events | |
| - 32 # Android 12L # Android 12 is the first version where calendar provider matches millisecond occurrences of recurring events | |
| - 35 # Android 15 # use latest SDK that has an AOSP image here | |
| env: | |
| apk-dir: synctools/apk | |
| fdroid-packages: "at.techbee.jtx org.dmfs.tasks org.tasks" | |
| API_LEVEL: ${{ matrix.api-level }} | |
| steps: | |
| - uses: gradle/actions/setup-gradle@v6 | |
| with: | |
| cache-encryption-key: ${{ secrets.gradle_encryption_key }} | |
| cache-read-only: true | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: 21 # keep in sync with gradle/gradle-daemon-jvm.properties | |
| - name: Install jq | |
| run: sudo apt-get update && sudo apt-get install -y jq | |
| - name: Restore F-Droid APKs from cache | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: ${{ env.apk-dir }} | |
| key: fdroid-apks | |
| restore-keys: | # restore nearest cache (regardless of the hash) | |
| fdroid-apks- | |
| - name: Download F-Droid packages | |
| continue-on-error: true | |
| run: | | |
| mkdir -p ${{ env.apk-dir }} | |
| for pkg in ${{ env.fdroid-packages }}; do | |
| # Get package info from F-Droid API | |
| api_url="https://f-droid.org/api/v1/packages/$pkg" | |
| response=$(curl -s "$api_url") | |
| # Extract package name and suggested version code | |
| package_name=$(echo "$response" | jq -r '.packageName') | |
| suggested_version_code=$(echo "$response" | jq -r '.suggestedVersionCode') | |
| if [ -z "$package_name" ] || [ "$package_name" == "null" ]; then | |
| echo "Error: Could not get package info for $pkg" | |
| continue | |
| fi | |
| # Download the APK using ETag-based caching | |
| apk_url="https://f-droid.org/repo/${package_name}_${suggested_version_code}.apk" | |
| apk_file="${{ env.apk-dir }}/${package_name}_latest.apk" | |
| etag_file="${apk_file}.etag" | |
| echo "Downloading $apk_url -> $apk_file" | |
| curl --etag-compare "$etag_file" --etag-save "$etag_file" -Lo "$apk_file" "$apk_url" || true | |
| done | |
| - name: Cache F-Droid APKs | |
| uses: actions/cache/save@v6 | |
| with: | |
| path: ${{ env.apk-dir }} | |
| key: fdroid-apks-${{ hashFiles(format('{0}/*.apk', env.apk-dir)) }} | |
| - name: Enable KVM group perms | |
| 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 | |
| - name: Run device tests | |
| run: ./gradlew :synctools:virtualCheck |