Skip to content

Commit ab38704

Browse files
committed
[RN][GHA] Add Android Helloworld test on PR
Will run test_android_helloworld when users create a PR, to provide coverage while we figure out what's going on with our CircleCI tests / deprecate them. Changelog: [Internal]
1 parent 5df5ed1 commit ab38704

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-0
lines changed

.circleci/config.yml

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ parameters:
3232
default: false
3333
type: boolean
3434

35+
skip:
36+
default: true
37+
type: boolean
38+
3539
jobs:
3640
choose_ci_jobs:
3741
docker:
@@ -59,6 +63,9 @@ jobs:
5963
- run:
6064
name: Yarn Install
6165
command: yarn install
66+
- when:
67+
condition:
68+
- equal: [ false, << pipeline.parameters.skip ]
6269
- when:
6370
condition:
6471
or:

.github/workflows/android.yml

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Test Android Helloworld on PR
2+
3+
on: [workflow_dispatch, pull_request, push]
4+
5+
jobs:
6+
prepare_hermes_workspace:
7+
runs-on: 4-core-ubuntu
8+
env:
9+
HERMES_WS_DIR: /tmp/hermes
10+
HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion
11+
BUILD_FROM_SOURCE: true
12+
outputs:
13+
react-native-version: ${{ steps.react-native-version.outputs.version }}
14+
hermes-version: ${{ steps.hermes-version.outputs.version }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/[email protected]
18+
- name: Setup node.js
19+
uses: ./.github/actions/setup-node
20+
- name: Setup hermes version
21+
id: hermes-version
22+
run: |
23+
mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes"
24+
25+
if [ -f "$HERMES_VERSION_FILE" ]; then
26+
echo "Hermes Version file found! Using this version for the build:"
27+
echo "VERSION=$(cat $HERMES_VERSION_FILE)" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "Hermes Version file not found!!!"
30+
echo "Using the last commit from main for the build:"
31+
HERMES_TAG_SHA=$(git ls-remote https://github.com/$GITHUB_REPOSITORY main | cut -f 1 | tr -d '[:space:]')
32+
echo "VERSION=$HERMES_TAG_SHA" >> "$GITHUB_OUTPUT"
33+
fi
34+
echo "Hermes commit is $HERMES_TAG_SHA"
35+
- name: Get react-native version
36+
id: react-native-version
37+
run: |
38+
VERSION=$(cat packages/react-native/package.json | jq -r '.version')
39+
# Save the react native version we are building in an output variable so we can use that file as part of the cache key.
40+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
41+
echo "React Native Version is $VERSION"
42+
- name: Cache hermes workspace
43+
uses: actions/[email protected]
44+
with:
45+
path: |
46+
/tmp/hermes/download/
47+
/tmp/hermes/hermes/
48+
key: v1-hermes-${{ steps.hermes-version.outputs.version }}-${{ github.run_number }}
49+
enableCrossOsArchive: true
50+
- name: Yarn- Install Dependencies
51+
run: yarn install --non-interactive
52+
- name: Download Hermes tarball
53+
run: |
54+
node packages/react-native/scripts/hermes/prepare-hermes-for-build ${{ github.event.pull_request.html_url }}
55+
cp packages/react-native/sdks/download/* $HERMES_WS_DIR/download/.
56+
cp -r packages/react-native/sdks/hermes/* $HERMES_WS_DIR/hermes/.
57+
58+
echo ${{ steps.hermes-version.outputs.version }}
59+
60+
test_android_helloworld:
61+
runs-on: ubuntu-latest
62+
needs: prepare_hermes_workspace
63+
container:
64+
image: reactnativecommunity/react-native-android:latest
65+
env:
66+
# Set the encoding to resolve a known character encoding issue with decompressing tar.gz files in conatiners
67+
# via Gradle: https://github.com/gradle/gradle/issues/23391#issuecomment-1878979127
68+
LC_ALL: C.UTF8
69+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
70+
TERM: "dumb"
71+
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
72+
TARGET_ARCHITECTURE: "arm64-v8a"
73+
continue-on-error: true
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
flavor: [Debug, Release]
78+
architecture: [NewArch, OldArch]
79+
jsengine: [Hermes, JSC]
80+
steps:
81+
- name: Checkout
82+
uses: actions/[email protected]
83+
- name: Cache setup
84+
id: cache_setup
85+
uses: ./.github/actions/cache_setup
86+
with:
87+
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
88+
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
89+
- name: Run yarn
90+
shell: bash
91+
run: yarn install --non-interactive
92+
- name: Disk check 1
93+
shell: bash
94+
if: always()
95+
run: df -h
96+
- name: Setup gradle
97+
uses: ./.github/actions/setup-gradle
98+
- name: Disk check 2
99+
shell: bash
100+
if: always()
101+
run: df -h
102+
- name: Build CodeGen JS scripts
103+
shell: bash
104+
run: |
105+
cd packages/react-native-codegen
106+
yarn run build
107+
- name: Monitor Disk utilization (before build)
108+
shell: bash
109+
if: always()
110+
run: |
111+
echo "On Runner:"
112+
df -h
113+
echo "Root:"
114+
du -hs *
115+
echo "Projects folder:"
116+
du -hs ./packages/*
117+
- name: Build the Helloworld application for ${{ matrix.flavor }} with Architecture set to ${{ matrix.architecture }}, and using the ${{ matrix.jsengine }} JS engine.
118+
shell: bash
119+
run: |
120+
cd packages/helloworld/android
121+
args=()
122+
if [[ ${{ matrix.architecture }} == "OldArch" ]]; then
123+
args+=(--arch old)
124+
fi
125+
if [[ ${{ matrix.jsengine }} == "JSC" ]]; then
126+
args+=(--jsvm jsc)
127+
fi
128+
if [[ ${{ matrix.flavor }} == "Release" ]]; then
129+
args+=(--prod)
130+
fi
131+
yarn build android "${args[@]}" -P reactNativeArchitectures="$TARGET_ARCHITECTURE"
132+
- name: Monitor Disk utilization (after build)
133+
shell: bash
134+
if: always()
135+
run: |
136+
echo "On Runner:"
137+
df -h
138+
echo "Root:"
139+
du -hs *
140+
echo "Projects folder:"
141+
du -hs ./packages/*
142+
- name: Upload artifact
143+
uses: actions/[email protected]
144+
with:
145+
name: template-apk-${{ matrix.flavor }}-${{ matrix.architecture }}-${{ matrix.jsengine }}
146+
path: ./app/build/outputs/apk/
147+
compression-level: 0
148+

0 commit comments

Comments
 (0)