Skip to content

Commit d7dda38

Browse files
rtibblesclaude
andcommitted
Update CI workflows and build scripts for Chaquopy
- Add build_and_test.yml for running unit tests in CI - Update build_apk.yml and release_apk.yml for Gradle-based builds - Remove pr_build.yml (replaced by build_and_test.yml) - Update pre-commit.yml and .pre-commit-config.yaml (add ruff, spotless) - Overhaul Makefile for Gradle/Chaquopy workflow (SDK setup, emulator, build, install, test targets) - Simplify scripts/version.py, create_strings.py, play_store_api.py for the new project structure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dbdd22b commit d7dda38

11 files changed

Lines changed: 451 additions & 432 deletions

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ updates:
1919
- "actions/*"
2020
# Maintain dependencies for Gradle
2121
- package-ecosystem: "gradle"
22-
directory: "python-for-android/dists/kolibri"
22+
directory: "/app"
2323
schedule:
2424
interval: "monthly"
2525
time: "00:00"
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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/

.github/workflows/build_apk.yml

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,17 @@ jobs:
102102
# of whether this is being run from the local repository with workflow_dispatch
103103
# or from another repository with workflow_call.
104104
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
105-
- name: Set up Python 3.9
105+
- name: Set up JDK 17
106+
uses: actions/setup-java@v4
107+
with:
108+
distribution: 'temurin'
109+
java-version: '17'
110+
cache: 'gradle'
111+
- name: Set up Python 3.10
106112
uses: actions/setup-python@v6
107113
with:
108-
python-version: 3.9
114+
python-version: "3.10"
115+
cache: 'pip'
109116
- name: Install Apt Dependencies
110117
# Dependencies installed here are taken from the buildozer Dockerfile:
111118
# https://github.com/kivy/buildozer/blob/master/Dockerfile#L45
@@ -122,38 +129,20 @@ jobs:
122129
libltdl-dev \
123130
patch \
124131
zlib1g-dev
125-
- uses: actions/cache@v5
126-
with:
127-
# This is where python for android puts its intermediary build
128-
# files - we cache this to improve build performance, but be
129-
# aggressive in clearing the cache whenever any file changes
130-
# in the repository, especially as we commit files to this folder
131-
# too, so we don't want the cache to override these files.
132-
# We achieve this by just caching on the currently checked out commit.
133-
# Every time we update this repository, this commit will change,
134-
# but repeated workflow calls for this commit will use the cache.
135-
path: ./python-for-android
136-
key: ${{ runner.os }}-python-for-android-${{ steps.get-commit.outputs.sha }}
137-
- uses: actions/cache@v5
138-
with:
139-
path: ~/.cache/pip
140-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
141-
restore-keys: |
142-
${{ runner.os }}-pip-
143132
- name: Download the tarfile from URL for workflow_dispatch
144133
if: ${{ github.event.inputs.tar-url }}
145-
run: make get-tar tar=${{ github.event.inputs.tar-url }}
134+
run: make get-tar tar="${{ github.event.inputs.tar-url }}"
146135
- name: Download the tarfile from URL for workflow_call
147136
if: ${{ inputs.tar-url }}
148-
run: make get-tar tar=${{ inputs.tar-url }}
137+
run: make get-tar tar="${{ inputs.tar-url }}"
149138
- name: Download the tarfile from artifacts
150139
if: ${{ inputs.tar-file-name }}
151140
uses: actions/download-artifact@v7
152141
with:
153142
name: ${{ inputs.tar-file-name }}
154143
path: tar
155144
- name: Install dependencies
156-
run: pip install -r requirements.txt
145+
run: pip install -r build-requirements.txt -r requirements.txt
157146
- name: Ensure that Android SDK dependencies are installed
158147
run: make setup
159148
- name: Build the aab

.github/workflows/pr_build.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
should_skip: ${{ steps.skip_check.outputs.should_skip }}
1818
steps:
1919
- id: skip_check
20-
uses: fkirc/skip-duplicate-actions@master
20+
uses: fkirc/skip-duplicate-actions@v5.3.1
2121
with:
2222
github_token: ${{ github.token }}
2323
paths_ignore: '["**.po", "**.json"]'
@@ -30,5 +30,12 @@ jobs:
3030
- uses: actions/checkout@v6
3131
- uses: actions/setup-python@v6
3232
with:
33-
python-version: 3.9
33+
python-version: "3.10"
34+
cache: 'pip'
35+
- name: Set up JDK 17
36+
uses: actions/setup-java@v4
37+
with:
38+
distribution: 'temurin'
39+
java-version: '17'
40+
cache: 'gradle'
3441
- uses: pre-commit/action@v3.0.1

.github/workflows/release_apk.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,12 @@ jobs:
3535
with:
3636
repository: learningequality/kolibri-installer-android
3737
ref: ${{ inputs.ref }}
38-
- name: Set up Python 3.9
38+
- name: Set up Python 3.10
3939
uses: actions/setup-python@v6
4040
with:
41-
python-version: 3.9
42-
- uses: actions/cache@v5
43-
with:
44-
path: ~/.cache/pip
45-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
46-
restore-keys: |
47-
${{ runner.os }}-pip-
41+
python-version: "3.10"
42+
cache: 'pip'
4843
- name: Install dependencies
49-
run: pip install -r requirements.txt
44+
run: pip install -r build-requirements.txt
5045
- name: Release APK
5146
run: python scripts/play_store_api.py release "${{ inputs.version-code }}"

.pre-commit-config.yaml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
repos:
2-
- repo: https://github.com/python/black
3-
rev: 22.3.0
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.9.6
44
hooks:
5-
- id: black
6-
types_or: [ python, pyi ]
7-
- repo: https://github.com/pycqa/flake8
8-
rev: 4.0.1
9-
hooks:
10-
- id: flake8
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
118
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v4.1.0
9+
rev: v6.0.0
1310
hooks:
1411
- id: trailing-whitespace
1512
- id: check-yaml
13+
args: ['--allow-multiple-documents']
1614
- id: check-added-large-files
1715
- id: debug-statements
1816
- id: end-of-file-fixer
19-
20-
- repo: https://github.com/asottile/reorder_python_imports
21-
rev: v2.6.0
17+
- repo: local
2218
hooks:
23-
- id: reorder-python-imports
19+
- id: spotless
20+
name: spotless (Java/Gradle formatting)
21+
entry: ./gradlew spotlessCheck --no-daemon
22+
language: system
23+
pass_filenames: false
24+
files: \.(java|gradle)$

0 commit comments

Comments
 (0)