v0.2.3
A ready-to-use CI/CD Pipeline and jobs for Android projects
Attributes
Includes Deno configuration
Repository
Current version released
3 years ago
Android Pipeline
A ready-to-use GitLab CI Pipeline and Jobs for your Android projects.
🚀 Usage
Quick start:
import { GitLab } from "https://deno.land/x/android_pipeline/mod.ts";
const { pipeline } = GitLab;
pipeline.write(); // Write the pipeline to the file .gitlab-ci.ymlOr, if you want to use the predefined jobs:
import { GitlabCI } from "https://deno.land/x/fluent_gitlab_ci/mod.ts";
import { GitLab } from "https://deno.land/x/android_pipeline/mod.ts";
const { assembleDebug, debugTests, lintDebug } = GitLab;
const const pipeline = new GitlabCI()
.image("openjdk:11-jdk")
.variables({
ANDROID_COMPILE_SDK: "30",
ANDROID_BUILD_TOOLS: "30.0.3",
ANDROID_SDK_TOOLS: "7583922",
})
.comment("Packages installation before running script")
.beforeScript(
`
apt-get --quiet update --yes
apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
export ANDROID_HOME="\${PWD}/android-home"
install -d $ANDROID_HOME
wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-\${ANDROID_SDK_TOOLS}_latest.zip
pushd $ANDROID_HOME
unzip -d cmdline-tools cmdline-tools.zip
pushd cmdline-tools
mv cmdline-tools tools || true
popd
popd
export PATH=$PATH:\${ANDROID_HOME}/cmdline-tools/tools/bin/
sdkmanager --version
yes | sdkmanager --licenses || true
sdkmanager "platforms;android-\${ANDROID_COMPILE_SDK}"
sdkmanager "platform-tools"
sdkmanager "build-tools;\${ANDROID_BUILD_TOOLS}"
chmod +x ./gradlew
`
)
.comment("Basic android and gradle stuff")
.comment("Check linting")
.addJob("lintDebug", lintDebug)
.comment("Make Project")
.addJob("assembleDebug", assembleDebug)
.comment("Run all tests, if any fails, interrupt the pipeline(fail it)")
.addJob("debugTests", debugTests);
pipeline.write(); // Write the pipeline to the file .gitlab-ci.ymlIt will generate the following .gitlab-ci.yml file:
# Do not edit this file directly. It is generated by Fluent GitLab CI
image: openjdk:11-jdk
variables:
ANDROID_COMPILE_SDK: "30"
ANDROID_BUILD_TOOLS: 30.0.3
ANDROID_SDK_TOOLS: "7583922"
# Packages installation before running script
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- export ANDROID_HOME="${PWD}/android-home"
- install -d $ANDROID_HOME
- wget --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
- pushd $ANDROID_HOME
- unzip -d cmdline-tools cmdline-tools.zip
- pushd cmdline-tools
- mv cmdline-tools tools || true
- popd
- popd
- export PATH=$PATH:${ANDROID_HOME}/cmdline-tools/tools/bin/
- sdkmanager --version
- yes | sdkmanager --licenses || true
- sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
- sdkmanager "platform-tools"
- sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
- chmod +x ./gradlew
# Basic android and gradle stuff
# Check linting
lintDebug:
interruptible: true
stage: build
script:
- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint
# Make Project
assembleDebug:
interruptible: true
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
# Run all tests, if any fails, interrupt the pipeline(fail it)
debugTests:
interruptible: true
stage: test
script:
- ./gradlew -Pci --console=plain :app:testDebug🧪 Advanced Usage
This package also provides a ready-to-use pipeline for Dagger, just run the following command on your Android project:
dagger run deno run -A https://deno.land/x/android_pipeline/ci.tsOr, if you want to use the predefined jobs:
import Client, { connect } from "@dagger.io/dagger";
import { Dagger } from "https://deno.land/x/android_pipeline/mod.ts";
const { lintDebug, assembleDebug, debugTests } = Dagger;
function pipeline(src = ".") {
connect(async (client: Client) => {
await lintDebug(client, src);
await assembleDebug(client, src);
await debugTests(client, src);
});
}
pipeline();