Skip to content

Commit 3ddf622

Browse files
committed
ci: streamlining e2e workflow to depend on build step
1 parent a3b55db commit 3ddf622

File tree

2 files changed

+78
-178
lines changed

2 files changed

+78
-178
lines changed

.github/workflows/build.yml

Lines changed: 53 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ jobs:
154154
mobile/build.gradle
155155
bundle exec fastlane update_version
156156
157+
- name: Assemble debug & test APK
158+
run: |
159+
make build-apk-debug
160+
157161
# Install age & load secrets
158162
- name: Install age
159163
uses: adnsio/setup-age-action@v1.2.0
@@ -171,8 +175,6 @@ jobs:
171175
JKS_STOREPASS: ${{ secrets.KEY_ANDROID_JKS_STOREPASS }}
172176
JKS_KEYPASS: ${{ secrets.KEY_ANDROID_JKS_KEYPASS }}
173177
run: |
174-
# TODO: Add related stuff in .travis.yml
175-
# TODO: Allow building even if secrets not set
176178
make dist/aw-android.apk
177179
178180
- name: Upload artifact
@@ -181,39 +183,48 @@ jobs:
181183
name: aw-android
182184
path: dist/aw-android*.apk
183185

184-
test:
185-
name: Test ${{ matrix.android_avd }} #-${{ matrix.os }}-eAPI-${{ matrix.android_emu_version }}-java-${{ matrix.java_version }}-node-${{ matrix.node_version }}
186+
- name: Upload artifact
187+
uses: actions/upload-artifact@v3
188+
with:
189+
name: apks
190+
path: dist/apk/
191+
192+
test-e2e:
193+
needs: [build]
194+
name: Test E2E ${{ matrix.android_avd }} #-${{ matrix.os }}-eAPI-${{ matrix.android_emu_version }}-java-${{ matrix.java_version }}-node-${{ matrix.node_version }}
186195
runs-on: ${{ matrix.os }}
187196
env:
188-
SUPPLY_TRACK: production # used by fastlane to determine track to publish to
189197
MATRIX_E_SDK: ${{ matrix.android_emu_version }}
190198
MATRIX_AVD: ${{ matrix.android_avd }}
191199
strategy:
192200
fail-fast: false
193201
max-parallel: 1
194202
matrix:
195203
os: [macos-12] # macOS-latest,
196-
android_emu_version: [27] #29, 31, 32]
197-
# android_avd: [Pixel_API_29_AOSP]
204+
android_avd: [Pixel_API_27_AOSP]
198205
java_version: [11]
199-
node_version: [16]
200-
ruby_version: ['3.0']
201-
rust_build: [false] # if true, will build aw-server-rust, otherwise will fetch artifact from recent CI run
202-
skip_webui: [true]
206+
ndk_version: ['21.4.7075529']
203207
include:
204208
- android_avd: Pixel_API_27_AOSP
205209
android_emu_version: 27
206210
# # # Cannot run > 27-emuLevel -_- https://github.com/actions/runner-images/issues/6527
207-
# - android_avd: Pixel_API_29_AOSP
208-
# android_emu_version: 29
209-
# - android_avd: Pixel_API_31_AOSP
210-
# android_emu_version: 31
211211
# - android_avd: Pixel_API_32_AOSP
212212
# android_emu_version: 32
213213
steps:
214214
- uses: actions/checkout@v2
215215
with:
216216
submodules: 'recursive'
217+
218+
# Will download all artifacts to path
219+
- name: Download build artifacts
220+
uses: actions/download-artifact@v3
221+
with:
222+
name: apks
223+
path: dist/apk
224+
- name: Display structure of downloaded files
225+
working-directory: dist
226+
run: ls -R
227+
217228
# # # Below code is majorly from https://github.com/actions/runner-images/issues/6152#issuecomment-1243718140
218229
- name: Create Android emulator
219230
run: |
@@ -265,162 +276,6 @@ jobs:
265276
$ANDROID_HOME/platform-tools/adb exec-out screencap -p > emulator$SUFFIX.png
266277
# # # Have to re-setup everything since we need to run emulator for faster performance on masOS ? Other os'es emulator will not startup ?
267278
# TODO: Optimize the steps taking into consideration all software present by default on macOS runner image
268-
# Build in release mode if: (longer build times)
269-
# - on a tag (release)
270-
# - on the master branch (nightly)
271-
- name: Set RELEASE
272-
run: |
273-
echo "RELEASE=${{ startsWith(github.ref_name, 'v') || github.ref_name == 'master' }}" >> $GITHUB_ENV
274-
275-
- name: Set up JDK
276-
uses: actions/setup-java@v1
277-
with:
278-
java-version: ${{ matrix.java_version }}
279-
280-
# Android SDK & NDK
281-
- name: Set up Android SDK
282-
uses: android-actions/setup-android@v2
283-
284-
- name: Install NDK
285-
run: sdkmanager "ndk;25.0.8775105"
286-
287-
- name: Set up Node
288-
uses: actions/setup-node@v1
289-
if: ${{ !matrix.skip_webui }}
290-
with:
291-
node-version: ${{ matrix.node_version }}
292-
293-
- name: Set up Rust nightly
294-
uses: actions-rs/toolchain@v1
295-
if: ${{ matrix.rust_build }}
296-
with:
297-
profile: minimal
298-
toolchain: nightly
299-
override: true
300-
301-
- name: Set up Ruby
302-
uses: actions/setup-ruby@v1
303-
with:
304-
ruby-version: ${{ matrix.ruby_version }}
305-
306-
- uses: adnsio/setup-age-action@v1.2.0
307-
308-
# Set up caches
309-
- name: Get npm cache dir
310-
id: npm-cache-dir
311-
if: ${{ !matrix.skip_webui }}
312-
run: |
313-
echo "::set-output name=dir::$(npm config get cache)"
314-
315-
- uses: actions/cache@v1
316-
name: Cache npm
317-
if: ${{ !matrix.skip_webui }}
318-
env:
319-
cache-name: node
320-
with:
321-
path: ${{ steps.npm-cache-dir.outputs.dir }}
322-
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
323-
restore-keys: |
324-
${{ runner.os }}-${{ env.cache-name }}-
325-
326-
- name: Cache cargo build
327-
uses: actions/cache@v1
328-
if: ${{ matrix.rust_build }}
329-
env:
330-
cache-name: cargo-build-target
331-
with:
332-
path: aw-server-rust/target
333-
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
334-
restore-keys: |
335-
${{ runner.os }}-${{ env.cache-name }}-
336-
337-
# Install fastlane
338-
- name: Install fastlane
339-
run: |
340-
gem install bundler
341-
bundle install
342-
343-
# Set up Rust toolchain
344-
- name: Set up Rust toolchain for Android NDK
345-
if: ${{ matrix.rust_build }}
346-
run: |
347-
ANDROID_NDK_HOME=
348-
./aw-server-rust/install-ndk.sh
349-
350-
# Build webui
351-
- name: Build webui
352-
if: ${{ !matrix.skip_webui }}
353-
run: |
354-
make aw-webui
355-
356-
# Build or fetch aw-server-rust artifacts
357-
- name: Build aw-server-rust
358-
if: ${{ matrix.rust_build }}
359-
env:
360-
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
361-
run: |
362-
make aw-server-rust
363-
364-
- name: Download artifact
365-
uses: dawidd6/action-download-artifact@v2
366-
if: ${{ !matrix.rust_build }}
367-
with:
368-
repo: ActivityWatch/aw-server-rust
369-
branch: master
370-
workflow: build.yml
371-
# Optional, uploaded artifact name,
372-
# will download all artifacts if not specified
373-
# and extract them in respective subdirectories
374-
# https://github.com/actions/download-artifact#download-all-artifacts
375-
name: binaries-android
376-
path: aw-server-rust/target/
377-
# Optional, the status or conclusion of a completed workflow to search for
378-
# Can be one of a workflow conculsion::
379-
# "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required"
380-
# Or a workflow status:
381-
# "completed", "in_progress", "queued"
382-
# Default: "completed"
383-
workflow_conclusion: success
384-
385-
- name: Install aw-server-rust binaries
386-
if: ${{ !matrix.rust_build }}
387-
# TODO: These are only debug + develop something like "make install" for below
388-
run: |
389-
mkdir -p mobile/src/main/jniLibs/arm64-v8a/
390-
cp -f ./aw-server-rust/target/aarch64-linux-android/debug/libaw_server.so mobile/src/main/jniLibs/arm64-v8a/libaw_server.so
391-
mkdir -p mobile/src/main/jniLibs/armeabi-v7a/
392-
cp -f ./aw-server-rust/target/armv7-linux-androideabi/debug/libaw_server.so mobile/src/main/jniLibs/armeabi-v7a/libaw_server.so
393-
mkdir -p mobile/src/main/jniLibs/x86/
394-
cp -f ./aw-server-rust/target/i686-linux-android/debug/libaw_server.so mobile/src/main/jniLibs/x86/libaw_server.so
395-
mkdir -p mobile/src/main/jniLibs/x86_64/
396-
cp -f ./aw-server-rust/target/x86_64-linux-android/debug/libaw_server.so mobile/src/main/jniLibs/x86_64/libaw_server.so
397-
398-
- name: Set version
399-
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag
400-
run: |
401-
# Sets versionName, tail used to skip "v" at start of tag name
402-
SHORT_VERSION=$(echo "${{ github.ref_name }}" | tail -c +2 -)
403-
sed -i "s/versionName \".*\"/versionName \"$SHORT_VERSION\"/g" \
404-
mobile/build.gradle
405-
bundle exec fastlane update_version
406-
407-
- name: Load secrets
408-
if: env.KEY_ANDROID_JKS != null
409-
env:
410-
KEY_ANDROID_JKS: ${{ secrets.KEY_ANDROID_JKS }}
411-
run: |
412-
printf "$KEY_ANDROID_JKS" > android.jks.key
413-
cat android.jks.age | age -d -i android.jks.key -o android.jks
414-
rm android.jks.key
415-
416-
- name: Cache Assemble APK
417-
env:
418-
JKS_STOREPASS: ${{ secrets.KEY_ANDROID_JKS_STOREPASS }}
419-
JKS_KEYPASS: ${{ secrets.KEY_ANDROID_JKS_KEYPASS }}
420-
run: |
421-
# TODO: Add related stuff in .travis.yml
422-
# TODO: Allow building even if secrets not set
423-
make dist/aw-android.apk
424279

425280
# # # Test # # reactiveCircus is giving a black screenshot not working
426281
# # # TODO: Take a screenshot of OS to confirm if its Emulator issue or testcode/androidsdk issue - or maybe the emulator is screen off ?
@@ -456,11 +311,35 @@ jobs:
456311
# # $ANDROID_HOME/tools/emulator -port 18725 -verbose -no-audio -gpu swiftshader_indirect -logcat *:v @$MATRIX_AVD &
457312
# ffmpeg -f avfoundation -i 0 -t 120 out$SUFFIX.mov &
458313

314+
# Java
315+
# Needs to be set up after emulator is started, otherwise I get:
316+
# java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
317+
# This seemes relevant: https://stackoverflow.com/a/58652345/965332
318+
#- name: Set up JDK
319+
# uses: actions/setup-java@v1
320+
# with:
321+
# java-version: ${{ matrix.java_version }}
322+
323+
# Android SDK & NDK
324+
#- name: Set up Android SDK
325+
# uses: android-actions/setup-android@v2
326+
#- name: Install NDK
327+
# run: |
328+
# sdkmanager "ndk;${{ matrix.ndk_version }}"
329+
# ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}"
330+
# ls $ANDROID_NDK_HOME
331+
# echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
332+
459333
- name: Test App
460334
id: test
461335
run: |
336+
adb install dist/apk/debug/mobile-debug.apk
337+
adb install dist/apk/androidTest/debug/mobile-debug-androidTest.apk
338+
adb shell pm list instrumentation
462339
adb logcat -v color &
463-
./gradlew connectedCheck -Pandroid.testInstrumentationRunnerArguments.class=net.activitywatch.android.ScreenshotTest --stacktrace
340+
adb shell am instrument -w \
341+
-e class net.activitywatch.android.debug.ScreenshotTest \
342+
net.activitywatch.android.debug.test/androidx.test.runner.AndroidJUnitRunner
464343
# adb logcat -d
465344
adb logcat > mobile/build/logcat.log
466345
@@ -512,7 +391,6 @@ jobs:
512391
# echo '<style>' >> GITHUB_STEP_SUMMARY.html;for file in ./mobile/build/reports/androidTests/connected/**/*.css; do cat $file >> GITHUB_STEP_SUMMARY.html ; done; echo '</style>' >> GITHUB_STEP_SUMMARY.html;
513392
cat GITHUB_STEP_SUMMARY.html >> $GITHUB_STEP_SUMMARY
514393
515-
516394
release-fastlane:
517395
needs: [build]
518396
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag
@@ -526,8 +404,8 @@ jobs:
526404
path: dist
527405

528406
- name: Display structure of downloaded files
529-
run: ls -R
530407
working-directory: dist
408+
run: ls -R
531409

532410
# detect if version tag is stable/beta
533411
- uses: nowsprinting/check-version-format-action@v2
@@ -565,8 +443,8 @@ jobs:
565443
path: dist
566444

567445
- name: Display structure of downloaded files
568-
run: ls -R
569446
working-directory: dist
447+
run: ls -R
570448

571449
# detect if version tag is stable/beta
572450
- uses: nowsprinting/check-version-format-action@v2

Makefile

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,33 @@ SHELL := /bin/bash
88
RELEASE_TYPE = $(shell $$RELEASE && echo 'release' || echo 'debug')
99
HAS_SECRETS = $(shell test -n "$$JKS_KEYPASS" && echo 'true' || echo 'false')
1010

11+
APKDIR = mobile/build/outputs/apk
12+
1113
# Main targets
1214
all: aw-server-rust aw-webui
1315
build: all
1416

17+
# builds a complete, signed apk, puts it in dist
1518
build-apk: dist/aw-android.apk
1619

17-
dist/aw-android.apk: mobile/build/outputs/apk/release/mobile-release-unsigned.apk
20+
# builds debug and test apks (unsigned)
21+
build-apk-debug: $(APKDIR)/debug/mobile-debug.apk $(APKDIR)/androidTest/debug/mobile-debug-androidTest.apk
22+
mkdir -p dist
23+
cp -r $(APKDIR) dist
24+
25+
$(APKDIR)/release/mobile-release-unsigned.apk:
26+
TERM=xterm ./gradlew assembleRelease
27+
tree $(APKDIR)
28+
29+
$(APKDIR)/debug/mobile-debug.apk:
30+
TERM=xterm ./gradlew assembleDebug
31+
tree $(APKDIR)
32+
33+
$(APKDIR)/androidTest/debug/mobile-debug-androidTest.apk:
34+
TERM=xterm ./gradlew assembleAndroidTest
35+
tree $(APKDIR)
36+
37+
dist/aw-android.apk: $(APKDIR)/release/mobile-release-unsigned.apk
1838
@# TODO: Name the APK based on the version number or commit hash.
1939
mkdir -p dist
2040
@# Only sign if we have key secrets set ($JKS_KEYPASS and $JKS_STOREPASS)
@@ -25,8 +45,10 @@ else
2545
./scripts/sign_apk.sh $< $@
2646
endif
2747

28-
mobile/build/outputs/apk/release/mobile-release-unsigned.apk:
29-
TERM=xterm ./gradlew assembleRelease
48+
# for mobile-debug.apk and mobile-debug-androidTest.apk
49+
dist/debug/%: $(APKDIR)/debug/%
50+
mkdir -p dist
51+
cp $< $@
3052

3153
# aw-server-rust stuff
3254

0 commit comments

Comments
 (0)