Android CI based on GitHub Image (#712)

This commit is contained in:
Bart Louwers
2023-01-26 19:40:49 +01:00
committed by GitHub
parent f7fa009f08
commit 85e33f88b1
22 changed files with 27 additions and 200 deletions

View File

@@ -28,14 +28,11 @@ concurrency:
jobs: jobs:
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-22.04
defaults: defaults:
run: run:
working-directory: platform/android working-directory: platform/android
container:
image: ghcr.io/maplibre/android-ndk-r21b
env: env:
LIBSYSCONFCPUS: 8
JOBS: 8 JOBS: 8
BUILDTYPE: Debug BUILDTYPE: Debug
IS_LOCAL_DEVELOPMENT: false IS_LOCAL_DEVELOPMENT: false
@@ -47,14 +44,6 @@ jobs:
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Android SDK for accepting tool licenses
uses: android-actions/setup-android@v2
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v3 uses: actions/cache@v3
env: env:
@@ -71,6 +60,9 @@ jobs:
run: npm install --ignore-scripts run: npm install --ignore-scripts
working-directory: platform/android working-directory: platform/android
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Prepare ccache - name: Prepare ccache
run: ccache --clear run: ccache --clear

View File

@@ -25,17 +25,11 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-22.04
defaults: defaults:
run: run:
working-directory: platform/android working-directory: platform/android
container:
image: ghcr.io/maplibre/android-ndk-r21b
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
env: env:
LIBSYSCONFCPUS: 8
JOBS: 8 JOBS: 8
BUILDTYPE: Debug BUILDTYPE: Debug
IS_LOCAL_DEVELOPMENT: false IS_LOCAL_DEVELOPMENT: false
@@ -47,14 +41,6 @@ jobs:
submodules: recursive submodules: recursive
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Android SDK for accepting tool licenses
uses: android-actions/setup-android@v2
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v3 uses: actions/cache@v3
env: env:
@@ -70,6 +56,9 @@ jobs:
- name: npm install - name: npm install
run: npm install --ignore-scripts run: npm install --ignore-scripts
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Prepare ccache - name: Prepare ccache
run: ccache --clear run: ccache --clear

View File

@@ -1,29 +0,0 @@
name: android-base-docker-image
on:
workflow_dispatch
jobs:
push_to_registry:
name: Docker image android-base
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push android-base image
uses: docker/build-push-action@v3
with:
file: ./platform/android/docker/android-base
context: ./platform/android/docker
tags: ghcr.io/maplibre/android-base:latest
push: true

View File

@@ -1,29 +0,0 @@
name: android-ndk-r21b-docker-image
on:
workflow_dispatch
jobs:
push_to_registry:
name: Docker image android-ndk-r21b
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push android-ndk-r21b image
uses: docker/build-push-action@v3
with:
file: ./platform/android/docker/android-ndk-r21b
context: ./platform/android/docker
tags: ghcr.io/maplibre/android-ndk-r21b:latest
push: true

View File

@@ -5,14 +5,11 @@ on:
jobs: jobs:
build: build:
runs-on: [self-hosted, Linux] runs-on: ubuntu-22.04
defaults: defaults:
run: run:
working-directory: platform/android working-directory: platform/android
container:
image: ghcr.io/maplibre/android-ndk-r21b
env: env:
LIBSYSCONFCPUS: 8
JOBS: 8 JOBS: 8
BUILDTYPE: Release BUILDTYPE: Release
IS_LOCAL_DEVELOPMENT: false IS_LOCAL_DEVELOPMENT: false
@@ -44,6 +41,9 @@ jobs:
run: npm install --ignore-scripts run: npm install --ignore-scripts
working-directory: platform/android working-directory: platform/android
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Prepare ccache - name: Prepare ccache
run: ccache --clear run: ccache --clear

View File

@@ -1,7 +1,9 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 33 compileSdkVersion androidVersions.compileSdkVersion
ndkVersion androidSdkVersions.ndkVersion
buildToolsVersion androidSdkVersions.buildToolsVersion
defaultConfig { defaultConfig {
applicationId = 'com.mapbox.mapboxsdk.maps.benchmark_runner' applicationId = 'com.mapbox.mapboxsdk.maps.benchmark_runner'
@@ -32,7 +34,7 @@ android {
} }
externalNativeBuild { externalNativeBuild {
cmake { cmake {
version '3.10.2' version androidSdkVersions.cmakeVersion
path '../../../CMakeLists.txt' path '../../../CMakeLists.txt'
} }
} }

View File

@@ -34,6 +34,7 @@ dependencies {
android { android {
compileSdkVersion androidVersions.compileSdkVersion compileSdkVersion androidVersions.compileSdkVersion
buildToolsVersion androidSdkVersions.buildToolsVersion
defaultConfig { defaultConfig {
minSdkVersion androidVersions.minSdkVersion minSdkVersion androidVersions.minSdkVersion

View File

@@ -1,5 +0,0 @@
```
docker build -t maplibre/android-base -f android-base .
docker build -t maplibre/android-ndk-r21b -f android-ndk-r21b .
```

View File

@@ -1,57 +0,0 @@
FROM ubuntu:xenial-20181005
ENV DEBIAN_FRONTEND="noninteractive"
# Add base filesystems
ADD filesystem/libsysconfcpus.tar.gz \
filesystem/apt-google-cloud-sdk.tar.gz \
/
# libsysconfcpus.so can be used to alter the number of CPUs reported by the system
ENV LD_PRELOAD=/usr/lib/libsysconfcpus.so
# Add apt keys
RUN set -eu \
&& (find /tmp/*.gpg | xargs -n1 apt-key add) \
&& rm /tmp/*.gpg
# Install base packages
RUN set -eu \
&& apt-get update \
&& apt-get -y install software-properties-common \
&& apt-get update \
&& add-apt-repository -y ppa:git-core/ppa \
&& apt-get update \
&& apt-get -y install git curl make python3 python3-pip zip unzip ccache openjdk-11-jdk-headless apt-transport-https \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \
&& rm -rf /var/lib/apt/lists/*
# Install CLI tools for CI scripting
RUN set -eu \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 \
&& apt-add-repository https://cli.github.com/packages \
&& apt-get update \
&& apt-get -y install jq gh \
&& rm -rf /var/lib/apt/lists/*
# Install Google Cloud SDK
RUN set -eu \
&& apt-get update \
&& apt-get -y install google-cloud-sdk \
&& rm -rf /var/lib/apt/lists/*
# Install awscli
RUN set -eu \
&& pip3 install awscli
# Install Node.js
# Check https://nodejs.org/en/download/releases/ for releases
ENV NVM_DIR="/root/.nvm" \
PATH="/root/.nvm/versions/node/v10.13.0/bin:$PATH"
RUN set -e \
&& git -c advice.detachedHead=false clone https://github.com/creationix/nvm.git -b v0.33.11 --depth=1 "$NVM_DIR" \
&& . "$NVM_DIR/nvm.sh" \
&& nvm install v10.13.0
ENV ANDROID_NDK_HOME=/android/sdk/ndk-bundle \
ANDROID_HOME=/android/sdk \
GRADLE_OPTS=-Dorg.gradle.daemon=false

View File

@@ -1,41 +0,0 @@
FROM ghcr.io/maplibre/android-base
WORKDIR /android/sdk
# Install Android SDK
# Use most recent version from https://developer.android.com/studio/index.html#command-tools
# and update the checksum.
RUN set -eu \
&& curl -L --retry 3 https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip -o tools.zip \
&& (echo "f10f9d5bca53cc27e2d210be2cbc7c0f1ee906ad9b868748d74d62e10f2c8275 tools.zip" | sha256sum -c) \
&& unzip -q tools.zip && rm tools.zip
# Install Android NDK
# Use desired version from https://developer.android.com/ndk/downloads/index.html
# and update the checksum.
RUN set -eu \
&& curl -L --retry 3 https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip -o ndk.zip \
&& (echo "afc9c0b9faad222898ac8168c78ad4ccac8a1b5c ndk.zip" | sha1sum -c) \
&& unzip -q ndk.zip && rm ndk.zip && mv android-ndk-r* ndk-bundle
# Install dependencies and build tools
RUN set -eu \
&& mkdir -p "${ANDROID_HOME}/licenses" \
&& echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "${ANDROID_HOME}/licenses/android-sdk-license" \
&& tools/bin/sdkmanager \
"--sdk_root=${ANDROID_HOME}" \
"platform-tools" \
"platforms;android-29" \
"build-tools;29.0.2" \
"build-tools;29.0.3" \
"platforms;android-28" \
"build-tools;28.0.3" \
"extras;android;m2repository" \
"patcher;v4" \
"extras;google;m2repository" \
"extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2" \
"cmake;3.10.2.4988404" \
&& rm -rf "${ANDROID_HOME}/licenses"
WORKDIR /src

View File

@@ -1 +0,0 @@
deb http://packages.cloud.google.com/apt cloud-sdk-xenial main

View File

@@ -1,2 +0,0 @@
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main

View File

@@ -1,2 +0,0 @@
deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main
deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main

View File

@@ -6,6 +6,12 @@ ext {
compileSdkVersion: 33, compileSdkVersion: 33,
] ]
androidSdkVersions = [
buildToolsVersion: '31.0.0',
ndkVersion : '25.1.8937393',
cmakeVersion : '3.18.1+',
]
versions = [ versions = [
mapLibreServices: '5.9.0', mapLibreServices: '5.9.0',
mapboxCore : '2.0.1', mapboxCore : '2.0.1',

View File

@@ -1,5 +1,8 @@
ext.nativeBuild = { nativeTargets -> ext.nativeBuild = { nativeTargets ->
android { android {
ndkVersion androidSdkVersions.ndkVersion
buildToolsVersion androidSdkVersions.buildToolsVersion
defaultPublishConfig project.hasProperty("mapbox.buildtype") ? project.getProperty("mapbox.buildtype") : "debug" defaultPublishConfig project.hasProperty("mapbox.buildtype") ? project.getProperty("mapbox.buildtype") : "debug"
// We sometimes want to invoke Gradle without building a native dependency, e.g. when we just want // We sometimes want to invoke Gradle without building a native dependency, e.g. when we just want
@@ -22,7 +25,7 @@ ext.nativeBuild = { nativeTargets ->
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path "../MapboxGLAndroidSDK/src/cpp/CMakeLists.txt" path "../MapboxGLAndroidSDK/src/cpp/CMakeLists.txt"
version "3.10.2" version androidSdkVersions.cmakeVersion
} }
} }
} }