Skip to content

Commit c2307e6

Browse files
committed
wire android lint into android build e2e workflow. save resources
1 parent c8f1214 commit c2307e6

2 files changed

Lines changed: 49 additions & 105 deletions

File tree

.github/workflows/build-android-e2e.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ on:
1515
required: false
1616
default: 'main'
1717
type: string
18+
run_android_lint:
19+
description: 'Whether to run Android lint in this workflow'
20+
required: false
21+
default: false
22+
type: boolean
1823
metamask_environment:
1924
description: 'The environment to build for'
2025
required: false
@@ -71,6 +76,49 @@ jobs:
7176
echo "🚀 Setting up project..."
7277
yarn setup:github-ci --no-build-ios
7378
79+
# React Native is an includeBuild() with its own settings root; cap ABI + Gradle there so the
80+
# composite build does not default to all ABIs or ignore android/gradle.properties.
81+
- name: Tune included React Native build for CI memory
82+
if: ${{ inputs.run_android_lint }}
83+
run: |
84+
set -euo pipefail
85+
RN_GP="node_modules/react-native/gradle.properties"
86+
if ! grep -qF '# metamask-mobile android-lint CI' "$RN_GP"; then
87+
{
88+
echo ''
89+
echo '# metamask-mobile android-lint CI'
90+
echo 'reactNativeArchitectures=x86_64'
91+
echo 'org.gradle.parallel=false'
92+
echo 'org.gradle.workers.max=1'
93+
echo 'org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError -Dfile.encoding=UTF-8'
94+
echo 'kotlin.daemon.jvmargs=-Xmx512m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError'
95+
} >> "$RN_GP"
96+
fi
97+
98+
- name: Run Android lint (prodRelease)
99+
if: ${{ inputs.run_android_lint }}
100+
working-directory: android
101+
env:
102+
NODE_OPTIONS: --max-old-space-size=4096
103+
# ReactAndroid CMake invokes Ninja with high parallelism by default; cap native compile RAM.
104+
CMAKE_BUILD_PARALLEL_LEVEL: 1
105+
NINJAFLAGS: -j1
106+
run: |
107+
set -euo pipefail
108+
cp gradle.properties.github gradle.properties
109+
# github file targets 48GB runners; shrink JVM + workers on smaller self-hosted runners.
110+
sed -i \
111+
-e 's/^org.gradle.parallel=.*/org.gradle.parallel=false/' \
112+
-e 's/^org.gradle.workers.max=.*/org.gradle.workers.max=1/' \
113+
-e 's/^org.gradle.jvmargs=.*/org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError -Dfile.encoding=UTF-8/' \
114+
-e 's/^kotlin.daemon.jvmargs=.*/kotlin.daemon.jvmargs=-Xmx512m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError/' \
115+
gradle.properties
116+
./gradlew --stop || true
117+
SENTRY_DISABLE_AUTO_UPLOAD=true ./gradlew :app:lintProdRelease \
118+
-PreactNativeArchitectures=x86_64 \
119+
--max-workers=1 \
120+
--no-daemon
121+
74122
# Generate fingerprint AFTER setup but BEFORE any build modifications (the fingerprint now is fake we do not want the cached apk)
75123
- name: Generate current fingerprint
76124
id: generate-fingerprint

.github/workflows/ci.yml

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -448,110 +448,6 @@ jobs:
448448
run: ${{ steps.download-actionlint.outputs.executable }} -color -config-file .github/actionlint.yaml
449449
shell: bash
450450

451-
android-lint:
452-
name: Android lint
453-
runs-on: ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg
454-
timeout-minutes: 45
455-
if: >-
456-
${{
457-
needs.get_requirements.outputs.skip_everything != 'true' &&
458-
!(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork)
459-
}}
460-
needs:
461-
- get_requirements
462-
permissions:
463-
contents: read
464-
id-token: write
465-
env:
466-
GRADLE_USER_HOME: /home/admin/_work/.gradle
467-
steps:
468-
- uses: actions/checkout@v6
469-
470-
- name: Restore .metamask folder
471-
uses: actions/cache@v4
472-
with:
473-
path: .metamask
474-
key: .metamask-${{ hashFiles('package.json', 'yarn.lock') }}
475-
476-
- name: Setup Android build environment
477-
timeout-minutes: 15
478-
uses: ./.github/actions/setup-e2e-env
479-
with:
480-
platform: android
481-
setup-simulator: false
482-
configure-keystores: true
483-
android-api-level: 36
484-
target: qa
485-
486-
# React Native is an includeBuild() with its own settings root; cap ABI + Gradle there so the
487-
# composite build does not default to all ABIs or ignore android/gradle.properties.
488-
- name: Tune included React Native build for CI memory
489-
run: |
490-
set -euo pipefail
491-
RN_GP="node_modules/react-native/gradle.properties"
492-
if ! grep -qF '# metamask-mobile android-lint CI' "$RN_GP"; then
493-
{
494-
echo ''
495-
echo '# metamask-mobile android-lint CI'
496-
echo 'reactNativeArchitectures=x86_64'
497-
echo 'org.gradle.parallel=false'
498-
echo 'org.gradle.workers.max=1'
499-
echo 'org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError -Dfile.encoding=UTF-8'
500-
echo 'kotlin.daemon.jvmargs=-Xmx512m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError'
501-
} >> "$RN_GP"
502-
fi
503-
504-
- name: Restore Gradle dependencies
505-
uses: cirruslabs/cache@bba69c6578b863ad0398ad40567bd2ef70290fe0 # v4
506-
env:
507-
GRADLE_LINT_CACHE_VERSION: 1
508-
with:
509-
path: |
510-
/home/admin/_work/.gradle/caches
511-
/home/admin/_work/.gradle/wrapper
512-
key: android-lint-gradle-${{ env.GRADLE_LINT_CACHE_VERSION }}-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
513-
514-
- name: Setup project dependencies with retry
515-
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
516-
with:
517-
timeout_minutes: 10
518-
max_attempts: 3
519-
retry_wait_seconds: 30
520-
command: yarn setup:github-ci --no-build-ios
521-
522-
- name: Run Android lint (prodRelease)
523-
working-directory: android
524-
env:
525-
NODE_OPTIONS: --max-old-space-size=4096
526-
# ReactAndroid CMake invokes Ninja with high parallelism by default; cap native compile RAM.
527-
CMAKE_BUILD_PARALLEL_LEVEL: 1
528-
NINJAFLAGS: -j1
529-
run: |
530-
set -euo pipefail
531-
cp gradle.properties.github gradle.properties
532-
# github file targets 48GB runners; shrink JVM + workers on smaller self-hosted runners.
533-
sed -i \
534-
-e 's/^org.gradle.parallel=.*/org.gradle.parallel=false/' \
535-
-e 's/^org.gradle.workers.max=.*/org.gradle.workers.max=1/' \
536-
-e 's/^org.gradle.jvmargs=.*/org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError -Dfile.encoding=UTF-8/' \
537-
-e 's/^kotlin.daemon.jvmargs=.*/kotlin.daemon.jvmargs=-Xmx512m -XX:+UseG1GC -XX:+ExitOnOutOfMemoryError/' \
538-
gradle.properties
539-
./gradlew --stop || true
540-
SENTRY_DISABLE_AUTO_UPLOAD=true ./gradlew :app:lintProdRelease \
541-
-PreactNativeArchitectures=x86_64 \
542-
--max-workers=1 \
543-
--no-daemon
544-
545-
- name: Require clean working directory
546-
shell: bash
547-
run: |
548-
if ! git diff --exit-code; then
549-
echo "Working tree dirty at end of job"
550-
exit 1
551-
else
552-
echo "No changes detected"
553-
fi
554-
555451
unit-tests:
556452
name: Unit tests (${{ matrix.shard }})
557453
runs-on: ubuntu-latest
@@ -831,6 +727,7 @@ jobs:
831727
uses: ./.github/workflows/build-android-e2e.yml
832728
with:
833729
build_type: 'main'
730+
run_android_lint: true
834731
metamask_environment: 'e2e'
835732
keystore_target: 'qa'
836733
secrets: inherit
@@ -1053,7 +950,6 @@ jobs:
1053950
unit-tests,
1054951
component-view-tests,
1055952
check-workflows,
1056-
android-lint,
1057953
js-bundle-size-check,
1058954
sonar-cloud-quality-gate-status,
1059955
]

0 commit comments

Comments
 (0)