Skip to content

Commit bf559b1

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 bf559b1

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-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

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

0 commit comments

Comments
 (0)