v14.0.0: upgrade to nutmeg

The app is upgraded to v3.0.2. Version v3.1.0 was not functional in our
experiment: it was crashing on every run.
This commit is contained in:
Régis Behmo 2022-05-23 17:34:38 +02:00 committed by Régis Behmo
parent e165bf04ea
commit c2d05ef635
7 changed files with 78 additions and 31 deletions

View File

@ -38,10 +38,10 @@ setup(
long_description=load_readme(),
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.5",
install_requires=["tutor>=13.0.0,<14.0.0"],
python_requires=">=3.7",
install_requires=["tutor>=14.0.0,<15.0.0"],
entry_points={
"tutor.plugin.v0": [
"tutor.plugin.v1": [
"android = tutorandroid.plugin"
]
},
@ -51,8 +51,6 @@ setup(
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",

View File

@ -1 +1 @@
__version__ = "13.0.0"
__version__ = "14.0.0"

View File

@ -2,18 +2,17 @@ from glob import glob
import os
import pkg_resources
from tutor import hooks as tutor_hooks
from .__about__ import __version__
templates = pkg_resources.resource_filename("tutorandroid", "templates")
config = {
"add": {"OAUTH2_SECRET": "{{ 24|random_string }}"},
"unique": {"OAUTH2_SECRET": "{{ 24|random_string }}"},
"defaults": {
"VERSION": __version__,
"APP_HOST": "mobile.{{ LMS_HOST }}",
"APP_VERSION": "2.26.1", # https://github.com/edx/edx-app-android/releases
"APP_VERSION": "3.0.2", # https://github.com/edx/edx-app-android/releases
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-android:{{ ANDROID_VERSION }}",
"APP_DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-android-app:{{ ANDROID_VERSION }}",
"ENABLE_RELEASE_MODE": False,
@ -23,22 +22,71 @@ config = {
},
}
hooks = {
"build-image": {
"android": "{{ ANDROID_DOCKER_IMAGE }}",
"android-app": "{{ ANDROID_APP_DOCKER_IMAGE }}",
},
"remote-image": {"android": "{{ ANDROID_DOCKER_IMAGE }}"},
"init": ["lms"],
}
tutor_hooks.Filters.COMMANDS_INIT.add_item(
(
"lms",
("android", "tasks", "lms", "init"),
)
)
tutor_hooks.Filters.IMAGES_BUILD.add_items(
[
(
"android",
("plugins", "android", "build", "android"),
"{{ ANDROID_DOCKER_IMAGE }}",
(),
),
(
"android-app",
("plugins", "android", "build", "app"),
"{{ ANDROID_APP_DOCKER_IMAGE }}",
(),
),
]
)
tutor_hooks.Filters.IMAGES_PULL.add_item(
(
"android",
"{{ ANDROID_DOCKER_IMAGE }}",
)
)
tutor_hooks.Filters.IMAGES_PUSH.add_item(
(
"android",
"{{ ANDROID_DOCKER_IMAGE }}",
)
)
def patches():
all_patches = {}
patches_dir = pkg_resources.resource_filename("tutorandroid", "patches")
for path in glob(os.path.join(patches_dir, "*")):
with open(path) as patch_file:
name = os.path.basename(path)
content = patch_file.read()
all_patches[name] = content
return all_patches
####### Boilerplate code
# Add the "templates" folder as a template root
tutor_hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(
pkg_resources.resource_filename("tutorandroid", "templates")
)
# Render the "build" and "apps" folders
tutor_hooks.Filters.ENV_TEMPLATE_TARGETS.add_items(
[
("android/build", "plugins"),
("android/apps", "plugins"),
],
)
# Load patches from files
for path in glob(
os.path.join(
pkg_resources.resource_filename("tutorandroid", "patches"),
"*",
)
):
with open(path, encoding="utf-8") as patch_file:
tutor_hooks.Filters.ENV_PATCHES.add_item(
(os.path.basename(path), patch_file.read())
)
# Add configuration entries
tutor_hooks.Filters.CONFIG_DEFAULTS.add_items(
[(f"ANDROID_{key}", value) for key, value in config.get("defaults", {}).items()]
)
tutor_hooks.Filters.CONFIG_UNIQUE.add_items(
[(f"ANDROID_{key}", value) for key, value in config.get("unique", {}).items()]
)
tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(
list(config.get("overrides", {}).items())
)

View File

@ -23,7 +23,7 @@ RUN wget https://dl.google.com/android/repository/commandlinetools-linux-${ANDRO
# Accept licenses
# https://developer.android.com/studio/command-line/sdkmanager
# Check target version: https://github.com/edx/edx-app-android/blob/master/constants.gradle
ARG ANDROID_API_LEVEL=29
ARG ANDROID_API_LEVEL=30
RUN yes | /app/android-sdk/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --install "platforms;android-$ANDROID_API_LEVEL" 1> /dev/null
# Install android app repo

View File

@ -14,6 +14,7 @@ RUN sed -i "s/APPLICATION_ID = .*/APPLICATION_ID = \"{{ LMS_HOST|reverse_host|re
RUN ./gradlew assembleProd{{ "Release" if ANDROID_ENABLE_RELEASE_MODE else "Debuggable" }}
#### File server to serve apk file
FROM docker.io/caddy:2.4.3-alpine as production
# https://hub.docker.com/_/caddy?tab=tags
FROM docker.io/caddy:2.5.1-alpine as production
COPY --from=build /app/edx-app-android/OpenEdXMobile/build/outputs/apk/prod/{{ "release" if ANDROID_ENABLE_RELEASE_MODE else "debuggable" }}/edx-{{ "release" if ANDROID_ENABLE_RELEASE_MODE else "debuggable" }}-{{ ANDROID_APP_VERSION }}.apk /srv/app.apk
CMD caddy file-server --listen=:8000 --root=/srv