Skip to content

Commit 145fba0

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 145fba0

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

.github/workflows/android.yml

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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: ubuntu-latest
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: Setup gradle
93+
uses: ./.github/actions/setup-gradle
94+
- name: Build CodeGen JS scripts
95+
shell: bash
96+
run: |
97+
cd packages/react-native-codegen
98+
yarn run build
99+
- name: Monitor Disk utilization (before build)
100+
shell: bash
101+
if: always()
102+
run: |
103+
echo "On Runner:"
104+
df -h
105+
echo "Root:"
106+
du -hs *
107+
echo "Projects folder:"
108+
du -hs ./packages/*
109+
- name: Build the Helloworld application for ${{ matrix.flavor }} with Architecture set to ${{ matrix.architecture }}, and using the ${{ matrix.jsengine }} JS engine.
110+
shell: bash
111+
run: |
112+
cd packages/helloworld/android
113+
args=()
114+
if [[ ${{ matrix.architecture }} == "OldArch" ]]; then
115+
args+=(--arch old)
116+
fi
117+
if [[ ${{ matrix.jsengine }} == "JSC" ]]; then
118+
args+=(--jsvm jsc)
119+
fi
120+
if [[ ${{ matrix.flavor }} == "Release" ]]; then
121+
args+=(--prod)
122+
fi
123+
yarn build android "${args[@]}" -P reactNativeArchitectures="$TARGET_ARCHITECTURE"
124+
- name: Monitor Disk utilization (after build)
125+
shell: bash
126+
if: always()
127+
run: |
128+
echo "On Runner:"
129+
df -h
130+
echo "Root:"
131+
du -hs *
132+
echo "Projects folder:"
133+
du -hs ./packages/*
134+
- name: Upload artifact
135+
uses: actions/[email protected]
136+
with:
137+
name: template-apk-${{ matrix.flavor }}-${{ matrix.architecture }}-${{ matrix.jsengine }}
138+
path: ./app/build/outputs/apk/
139+
compression-level: 0
140+

0 commit comments

Comments
 (0)