|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - develop |
| 10 | + |
| 11 | +jobs: |
| 12 | + pre_job: |
| 13 | + name: Path match check |
| 14 | + runs-on: ubuntu-latest |
| 15 | + outputs: |
| 16 | + should_skip: ${{ steps.skip_check.outputs.should_skip }} |
| 17 | + steps: |
| 18 | + - id: skip_check |
| 19 | + uses: fkirc/skip-duplicate-actions@v5.3.1 |
| 20 | + with: |
| 21 | + github_token: ${{ github.token }} |
| 22 | + paths_ignore: '["**.po", "**.json"]' |
| 23 | + |
| 24 | + download_tar: |
| 25 | + name: Download Kolibri tar |
| 26 | + needs: pre_job |
| 27 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} |
| 28 | + runs-on: ubuntu-latest |
| 29 | + outputs: |
| 30 | + tar-file-name: ${{ steps.get_tar.outputs.tar-file-name }} |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v6 |
| 33 | + - name: Get latest Kolibri release URL |
| 34 | + id: get_release |
| 35 | + uses: actions/github-script@v8 |
| 36 | + with: |
| 37 | + result-encoding: string |
| 38 | + script: | |
| 39 | +
|
| 40 | + const { data: releases } = await github.rest.repos.listReleases({ |
| 41 | + owner: 'learningequality', |
| 42 | + repo: 'kolibri', |
| 43 | + per_page: 1, |
| 44 | + page: 1, |
| 45 | + }); |
| 46 | +
|
| 47 | + const latestRelease = releases[0]; |
| 48 | + const tarAsset = latestRelease.assets.find(asset => asset.name.endsWith('.tar.gz')); |
| 49 | + return tarAsset.browser_download_url; |
| 50 | +
|
| 51 | + - name: Download Kolibri tar |
| 52 | + id: get_tar |
| 53 | + run: | |
| 54 | + make get-tar tar="${{ steps.get_release.outputs.result }}" |
| 55 | + echo "tar-file-name=$(ls tar/*.tar.gz | head -1 | xargs basename)" >> $GITHUB_OUTPUT |
| 56 | + - name: Upload tar as artifact |
| 57 | + uses: actions/upload-artifact@v6 |
| 58 | + with: |
| 59 | + name: ${{ steps.get_tar.outputs.tar-file-name }} |
| 60 | + path: tar/${{ steps.get_tar.outputs.tar-file-name }} |
| 61 | + |
| 62 | + build_apk: |
| 63 | + name: Build Debug APK |
| 64 | + needs: [pre_job, download_tar] |
| 65 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} |
| 66 | + uses: ./.github/workflows/build_apk.yml |
| 67 | + with: |
| 68 | + tar-file-name: ${{ needs.download_tar.outputs.tar-file-name }} |
| 69 | + |
| 70 | + tests: |
| 71 | + name: Unit tests |
| 72 | + needs: [pre_job, download_tar] |
| 73 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v6 |
| 77 | + - name: Set up JDK 17 |
| 78 | + uses: actions/setup-java@v4 |
| 79 | + with: |
| 80 | + distribution: 'temurin' |
| 81 | + java-version: '17' |
| 82 | + cache: 'gradle' |
| 83 | + - name: Set up Python 3.10 |
| 84 | + uses: actions/setup-python@v6 |
| 85 | + with: |
| 86 | + python-version: "3.10" |
| 87 | + - name: Install Python dependencies |
| 88 | + run: pip install -r requirements.txt |
| 89 | + - name: Download Kolibri tar |
| 90 | + uses: actions/download-artifact@v7 |
| 91 | + with: |
| 92 | + name: ${{ needs.download_tar.outputs.tar-file-name }} |
| 93 | + path: tar |
| 94 | + - name: Run unit tests |
| 95 | + run: ./gradlew test |
| 96 | + |
| 97 | + smoke_test: |
| 98 | + name: Smoke test |
| 99 | + needs: [pre_job, build_apk] |
| 100 | + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} |
| 101 | + runs-on: ubuntu-latest |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v6 |
| 104 | + - name: Set up JDK 17 |
| 105 | + uses: actions/setup-java@v4 |
| 106 | + with: |
| 107 | + distribution: 'temurin' |
| 108 | + java-version: '17' |
| 109 | + - name: Install Maestro CLI |
| 110 | + run: make maestro-install |
| 111 | + - name: Add Maestro to PATH |
| 112 | + run: echo "$HOME/.maestro/bin" >> $GITHUB_PATH |
| 113 | + - name: Enable KVM |
| 114 | + run: | |
| 115 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 116 | + sudo udevadm control --reload-rules |
| 117 | + sudo udevadm trigger --name-match=kvm |
| 118 | + - name: Download APK artifact |
| 119 | + uses: actions/download-artifact@v7 |
| 120 | + with: |
| 121 | + name: ${{ needs.build_apk.outputs.apk-file-name }} |
| 122 | + path: dist |
| 123 | + - name: Run smoke test |
| 124 | + uses: reactivecircus/android-emulator-runner@v2 |
| 125 | + with: |
| 126 | + api-level: 30 |
| 127 | + arch: x86_64 |
| 128 | + target: google_apis |
| 129 | + script: | |
| 130 | + adb install -r dist/*.apk |
| 131 | + adb shell am set-debug-app --persistent org.learningequality.Kolibri |
| 132 | + make smoke-test |
| 133 | + - name: Upload Maestro debug output |
| 134 | + if: always() |
| 135 | + uses: actions/upload-artifact@v6 |
| 136 | + with: |
| 137 | + name: maestro-debug-output |
| 138 | + path: ~/.maestro/tests/ |
0 commit comments