CI: Use nixbuild.net

The build takes place on the remote, which takes advantage of Nix's
caching.
The previous workflow used a remote cache but in order to build locally,
all the dependencies needed to be downloaded from the cache everytime.
The dependencies are 462M, downloading took most of the time.
This commit is contained in:
Jules Aguillon 2022-03-23 10:23:13 +01:00
parent 0d1ddcce3f
commit 3373c59b90
2 changed files with 42 additions and 19 deletions

View File

@ -1,4 +1,4 @@
name: Make Apk CI name: Build-debug-apk
on: on:
workflow_dispatch: workflow_dispatch:
@ -6,29 +6,36 @@ on:
pull_request: pull_request:
jobs: jobs:
Build-Apk: Make-apk:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install nix - name: Install nix
uses: cachix/install-nix-action@v15 uses: cachix/install-nix-action@v15
with: with:
nix_path: nixpkgs=channel:nixos-unstable nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v10 - name: Setup nixbuild.net
uses: nixbuild/nixbuild-action@v8
with: with:
name: julow nixbuild_ssh_key: ${{ secrets.nixbuild_ssh_key }}
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' - name: Checkout repo
- name: Checkout Repo
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache debug certificate - name: Cache debug certificate
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: _build/debug.keystore path: _build/debug.keystore
key: debug-keystore key: debug-keystore
- name: Run nix-shell and Make # Hopefully cached.
uses: ZenithalHourlyRate/nix-shell-action@v4 - name: Debug certificate
with: run: |
file: shell.nix [[ -f _build/debug.keystore ]] ||
script: make nix-shell ./shell.nix --run 'make debug.keystore'
- name: Build
run: |
nix build --eval-store auto --store ssh-ng://eu.nixbuild.net \
-f ./shell.nix debug-apk
nix build -f ./shell.nix debug-apk
mkdir -p _build
cp result/*.apk _build
- name: Save debug apk - name: Save debug apk
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:

View File

@ -1,19 +1,35 @@
{ pkgs ? import <nixpkgs> { { pkgs ? import <nixpkgs> {
config.android_sdk.accept_license = true; config.android_sdk.accept_license = true;
config.allowUnfree = true; config.allowUnfree = true;
} }: } }:
let let
jdk = pkgs.openjdk8;
android = pkgs.androidenv.composeAndroidPackages { android = pkgs.androidenv.composeAndroidPackages {
buildToolsVersions = [ "30.0.3" ]; buildToolsVersions = [ "30.0.3" ];
platformVersions = [ "30" ]; platformVersions = [ "30" ];
abiVersions = [ "armeabi-v7a" ]; abiVersions = [ "armeabi-v7a" ];
}; };
in buildInputs =
pkgs.mkShell { [ pkgs.findutils pkgs.openjdk8 android.androidsdk pkgs.fontforge ];
buildInputs = [ pkgs.findutils jdk android.androidsdk pkgs.fontforge ];
# Env variable required by the Makefile
ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk"; ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk";
# Build the debug APK. Exposed as an attribute, used in CI
debug-apk = pkgs.stdenv.mkDerivation {
name = "unexpected-keyboard-debug";
src = ./.;
inherit buildInputs ANDROID_HOME;
buildPhase = ''
make
'';
installPhase = ''
mkdir -p $out
mv _build/*.apk $out
'';
};
in pkgs.mkShell { inherit buildInputs ANDROID_HOME; } // {
inherit debug-apk;
} }