Skip to content

Commit

Permalink
Merge pull request #101 from learningequality/vendor_build
Browse files Browse the repository at this point in the history
Update Android App building and runtime
  • Loading branch information
rtibbles authored Apr 4, 2022
2 parents 2bb07ad + 23565cd commit 947fa84
Show file tree
Hide file tree
Showing 35 changed files with 603 additions and 494 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/build_apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Build Android App

on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
whl-url:
description: 'URL for Kolibri whl file'
required: true
arch:
description: 'Architecture of the build'
required: true
default: '32bit'
type: choice
options:
- 32bit
- 64bit
workflow_call:
inputs:
whl-file-name:
required: true
type: string
arch:
description: 'Architecture of the build: 32bit or 64bit'
required: true
type: string
ref:
description: 'A ref for this workflow to check out its own repo'
required: true
type: string
outputs:
apk-file-name:
description: "APK file name"
value: ${{ jobs.build_apk.outputs.apk-file-name }}

jobs:
build_apk:
runs-on: ubuntu-latest
outputs:
apk-file-name: ${{ steps.get-apk-filename.outputs.apk-file-name }}
steps:
- uses: actions/checkout@v2
if: ${{ !inputs.ref }}
- uses: actions/checkout@v2
if: ${{ inputs.ref }}
with:
repository: learningequality/kolibri-android-installer
ref: ${{ inputs.ref }}
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: actions/cache@v2
with:
# This is where python for android puts its intermediary build
# files - we cache this to improve build performance, but be
# aggressive in clearing the cache whenever any file changes
# in the repository.
path: ~/.local
key: ${{ runner.os }}-local-${{ github.event.inputs.arch || inputs.arch }}-${{ hashFiles('*') }}
restore-keys: |
${{ runner.os }}-local-${{ github.event.inputs.arch || inputs.arch }}-
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Download the whlfile from URL
if: ${{ github.event.inputs.whl-url }}
run: make get-whl whl=${{ github.event.inputs.whl-url }}
- name: Download the whlfile from artifacts
if: ${{ inputs.whl-file-name }}
uses: actions/download-artifact@v2
with:
name: ${{ inputs.whl-file-name }}
path: whl
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build the app
env:
ARCH: ${{ github.event.inputs.arch || inputs.arch }}
# No need to set the ANDROID_HOME environment variable here that is used for
# setting up the ANDROID SDK and ANDROID NDK, as the github actions images
# have these SDKs and NDKs already installed.
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-3
ANDROIDSDK: ${{ env.ANDROID_SDK_ROOT }}
ANDROIDNDK: ${{ env.ANDROID_NDK_ROOT }}
run: make kolibri.apk.unsigned
- name: Get APK filename
id: get-apk-filename
run: echo "::set-output name=apk-file-name::$(ls dist | grep .apk | cat)"
- uses: actions/upload-artifact@v2
with:
name: ${{ steps.get-apk-filename.outputs.apk-file-name }}
path: dist/${{ steps.get-apk-filename.outputs.apk-file-name }}
28 changes: 28 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Linting

on: [push, pull_request]

jobs:
pre_job:
name: Path match check
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
github_token: ${{ github.token }}
paths_ignore: '["**.po", "**.json"]'
linting:
name: All file linting
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: pre-commit/[email protected]
12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
src/kolibri
src/preseeded_kolibri_home
src/extra-packages
tmpenv
whl/*

# File format for signing key
*.jks

# Generated for pew
project_info.json
# pew output folder
# output folder
dist/

__pycache__
*.pyc
build_docker
build/
bin/
build.log
tmphome/
static/
android_root/

*.apk
.env
22 changes: 22 additions & 0 deletions .p4a
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--window
--bootstrap "webview"
--package "org.learningequality.Kolibri"
--name "Kolibri"
--dist_name "kolibri"
--private "src"
--orientation sensor
--requirements python3,android,pyjnius,genericndkbuild,sqlite3,cryptography,twisted,attrs,bcrypt,service_identity,pyasn1,pyasn1_modules,pyopenssl,openssl,six
--android-api 30
--minsdk 21
--permission WRITE_EXTERNAL_STORAGE
--permission ACCESS_NETWORK_STATE
--permission FOREGROUND_SERVICE
--service server:server.py
--service remoteshell:remoteshell.py
--presplash assets/icon.png
--presplash-color #FFFFFF
--icon assets/icon.png
--fileprovider-paths src/fileprovider_paths.xml
--add-asset assets/_load.html:_load.html
--whitelist ./allowlist.txt
--blacklist ./blocklist.txt
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/python/black
rev: 22.3.0
hooks:
- id: black
types_or: [ python, pyi ]
exclude: '^.+?\.template$'
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
exclude: '^.+?\.template$'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
exclude: '^.+?\.template$'
- id: check-yaml
exclude: '^.+?\.template$'
- id: check-added-large-files
exclude: '^.+?\.template$'
- id: debug-statements
exclude: '^.+?\.template$'
- id: end-of-file-fixer
exclude: '^.+?(\.json|\.template)$'

- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
hooks:
- id: reorder-python-imports
22 changes: 6 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,8 @@ ENV PATH /usr/local/bin:$PATH
RUN cd /usr/local/bin && \
ln -s $(which python3) python

ENV PEW_BRANCH=p4a_update
ENV P4A_BRANCH=pew_webview

# Allows us to invalidate cache if those repos update.
# Intentionally not pinning for dev velocity.
ADD https://github.com/learningequality/pyeverywhere/archive/$PEW_BRANCH.zip pew.zip
ADD https://github.com/learningequality/python-for-android/archive/$P4A_BRANCH.zip p4a.zip

# clean up the pew cache if the source repos changed
RUN rm -r /home/kivy/.pyeverywhere || true

# install python dependencies
RUN pip install cython virtualenv pbxproj && \
# get custom packages
pip install -e git+https://github.com/learningequality/pyeverywhere@$PEW_BRANCH#egg=pyeverywhere && \
pip install -e git+https://github.com/learningequality/python-for-android@$P4A_BRANCH#egg=python-for-android && \
RUN pip install -r requirements.txt && \
useradd -lm kivy

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
Expand All @@ -78,10 +64,14 @@ WORKDIR /home/kivy
ARG ARCH=$ARCH

# Initializes the directory, owned by new user. Volume mounts adopt existing permissions, etc.
RUN mkdir ~/.local ~/.pyeverywhere
RUN mkdir ~/.local

COPY --chown=kivy:kivy . .

RUN make setup

RUN set -a; source .env; set +a

ENTRYPOINT [ "make" ]

CMD [ "kolibri.apk" ]
Loading

0 comments on commit 947fa84

Please sign in to comment.