Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions .github/workflows/scripts-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ name: Test Android build scripts

jobs:
build-android:
name: Build Android ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: "Default: 8"
id: default
- name: "JDK 17"
id: jdk17
java_version: '17'
- name: "JDK 21"
id: jdk21
java_version: '21'
permissions:
contents: read
pull-requests: write
Expand All @@ -82,6 +95,28 @@ jobs:
GH_TOKEN: ${{ secrets.CN1SS_GH_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Free Disk Space
if: matrix.id != 'default'
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android/sdk/ndk
sudo rm -rf /opt/ghc
sudo rm -rf /usr/share/swift
- name: Setup JDK
if: matrix.id != 'default'
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java_version }}
distribution: 'zulu'
- name: Set JDK_HOME
if: matrix.id != 'default'
run: echo "JDK_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- name: Configure CN1SS options
if: matrix.id != 'default'
run: |
echo "CN1SS_SKIP_COMMENT=1" >> $GITHUB_ENV
echo "CN1SS_FAIL_ON_MISMATCH=1" >> $GITHUB_ENV
echo "CN1SS_SKIP_COVERAGE=1" >> $GITHUB_ENV
- name: Setup workspace
run: ./scripts/setup-workspace.sh -q -DskipTests
- name: Build Android port
Expand All @@ -100,11 +135,9 @@ jobs:
api-level: 31
arch: x86_64
target: google_apis
script: |
./scripts/run-android-instrumentation-tests.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
./scripts/generate-android-coverage-report.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
script: ./scripts/run-android-instrumentation-tests.sh "${{ steps.build-android-app.outputs.gradle_project_dir }}"
- name: Upload emulator screenshot
if: always() # still collect it if tests fail
if: always() && matrix.id == 'default'
uses: actions/upload-artifact@v4
with:
name: emulator-screenshot
Expand All @@ -113,7 +146,7 @@ jobs:
retention-days: 14
compression-level: 6
- name: Upload Android Jacoco coverage report
if: always()
if: always() && matrix.id == 'default'
uses: actions/upload-artifact@v4
with:
name: android-jacoco-coverage
Expand Down
Binary file removed scripts/android/screenshots/GraphicsPipeline.png
Binary file not shown.
Binary file not shown.
Binary file removed scripts/android/screenshots/GraphicsStateAndText.png
Binary file not shown.
Binary file not shown.
Binary file modified scripts/android/screenshots/graphics-draw-line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/android/screenshots/graphics-draw-string-decorated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/android/screenshots/graphics-draw-string.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified scripts/android/screenshots/kotlin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions scripts/build-android-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ if [ ! -f "$PATCH_GRADLE_SOURCE_PATH/$PATCH_GRADLE_MAIN_CLASS.java" ]; then
exit 1
fi

PATCH_GRADLE_JAVA="${JAVA17_HOME}/bin/java"
PATCH_GRADLE_JAVA="${JDK_HOME:-$JAVA17_HOME}/bin/java"
if [ ! -x "$PATCH_GRADLE_JAVA" ]; then
ba_log "JDK 17 java binary missing at $PATCH_GRADLE_JAVA" >&2
ba_log "JDK java binary missing at $PATCH_GRADLE_JAVA" >&2
exit 1
fi

Expand All @@ -151,7 +151,7 @@ echo "---------------------------------"
ba_log "Invoking Gradle build in $GRADLE_PROJECT_DIR"
chmod +x "$GRADLE_PROJECT_DIR/gradlew"
ORIGINAL_JAVA_HOME="$JAVA_HOME"
export JAVA_HOME="$JAVA17_HOME"
export JAVA_HOME="${JDK_HOME:-$JAVA17_HOME}"
(
cd "$GRADLE_PROJECT_DIR"
if command -v sdkmanager >/dev/null 2>&1; then
Expand Down
11 changes: 10 additions & 1 deletion scripts/lib/cn1ss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,18 @@ cn1ss_process_and_report() {

cn1ss_log "STAGE:COMMENT_POST -> Submitting PR feedback"
local comment_rc=0
if ! cn1ss_post_pr_comment "$comment_out" "$preview_dir"; then
if [ "${CN1SS_SKIP_COMMENT:-0}" = "1" ]; then
cn1ss_log "Skipping PR comment as requested (CN1SS_SKIP_COMMENT=1)"
elif ! cn1ss_post_pr_comment "$comment_out" "$preview_dir"; then
comment_rc=$?
fi

if [ "${CN1SS_FAIL_ON_MISMATCH:-0}" = "1" ]; then
if [ -f "$summary_out" ] && (grep -q "^different|" "$summary_out" || grep -q "^error|" "$summary_out"); then
cn1ss_log "FATAL: Screenshot mismatches or errors detected (CN1SS_FAIL_ON_MISMATCH=1)"
return 15
Comment on lines +412 to +415

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fail matrix runs on all CN1SS mismatches

The new CN1SS_FAIL_ON_MISMATCH guard only trips when the summary file contains different| or error|. RenderScreenshotReport emits other non‑success statuses such as missing_expected and missing_actual (e.g., when a reference PNG is absent or the test never produced a screenshot), but those are ignored here, so matrix jobs with CN1SS_FAIL_ON_MISMATCH=1 still exit 0 even though the comparison detected missing screenshots. That defeats the goal of failing non‑default JDK runs on visual regressions; a JDK‑specific omission would be silently green.

Useful? React with 👍 / 👎.

fi
fi

return $comment_rc
}
30 changes: 18 additions & 12 deletions scripts/run-android-instrumentation-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ if [ -z "${JAVA17_HOME:-}" ]; then
exit 3
fi

JAVA17_BIN="$JAVA17_HOME/bin/java"
if [ ! -x "$JAVA17_BIN" ]; then
ra_log "JDK 17 java binary missing at $JAVA17_BIN" >&2
TARGET_JAVA_HOME="${JDK_HOME:-$JAVA17_HOME}"
TARGET_JAVA_BIN="$TARGET_JAVA_HOME/bin/java"

if [ ! -x "$TARGET_JAVA_BIN" ]; then
ra_log "Target java binary missing at $TARGET_JAVA_BIN" >&2
exit 3
fi

cn1ss_setup "$JAVA17_BIN" "$CN1SS_HELPER_SOURCE_DIR"
cn1ss_setup "$TARGET_JAVA_BIN" "$CN1SS_HELPER_SOURCE_DIR"

[ -d "$GRADLE_PROJECT_DIR" ] || { ra_log "Gradle project directory not found: $GRADLE_PROJECT_DIR"; exit 4; }
[ -x "$GRADLE_PROJECT_DIR/gradlew" ] || chmod +x "$GRADLE_PROJECT_DIR/gradlew"
Expand Down Expand Up @@ -115,7 +117,7 @@ GRADLE_CMD=("$GRADLEW" --stacktrace --info --no-daemon connectedDebugAndroidTest
ra_log "Executing connectedDebugAndroidTest via Gradle"
if ! (
cd "scripts/hellocodenameone/android/target/hellocodenameone-android-1.0-SNAPSHOT-android-source"
JAVA_HOME="$JAVA17_HOME" "${GRADLE_CMD[@]}"
JAVA_HOME="${JDK_HOME:-$JAVA17_HOME}" "${GRADLE_CMD[@]}"
); then
ra_log "FATAL: connectedDebugAndroidTest failed"
exit 10
Expand All @@ -140,15 +142,19 @@ done

sleep 3

ra_log "STAGE:COVERAGE -> Collecting Jacoco coverage report"
if ARTIFACTS_DIR="$ARTIFACTS_DIR" "$SCRIPT_DIR/generate-android-coverage-report.sh" "$GRADLE_PROJECT_DIR"; then
if [ -f "$COVERAGE_SUMMARY" ]; then
ra_log " -> Coverage summary detected at $COVERAGE_SUMMARY"
if [ "${CN1SS_SKIP_COVERAGE:-0}" = "1" ]; then
ra_log "Skipping coverage report generation (CN1SS_SKIP_COVERAGE=1)"
else
ra_log "STAGE:COVERAGE -> Collecting Jacoco coverage report"
if ARTIFACTS_DIR="$ARTIFACTS_DIR" "$SCRIPT_DIR/generate-android-coverage-report.sh" "$GRADLE_PROJECT_DIR"; then
if [ -f "$COVERAGE_SUMMARY" ]; then
ra_log " -> Coverage summary detected at $COVERAGE_SUMMARY"
else
ra_log " -> Coverage summary not found after report generation"
fi
else
ra_log " -> Coverage summary not found after report generation"
ra_log "WARNING: Coverage report generation failed; continuing without coverage details"
fi
else
ra_log "WARNING: Coverage report generation failed; continuing without coverage details"
fi

declare -a CN1SS_SOURCES=("LOGCAT:$TEST_LOG")
Expand Down