Skip to content

Commit

Permalink
[RN][GHA] Add Android Helloworld test on PR
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
blakef committed Jun 18, 2024
1 parent 5df5ed1 commit e91e1fe
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ parameters:
default: false
type: boolean

skip:
default: true
type: boolean

jobs:
choose_ci_jobs:
docker:
Expand Down Expand Up @@ -59,6 +63,9 @@ jobs:
- run:
name: Yarn Install
command: yarn install
- when:
condition:
- equal: [ false, << pipeline.parameters.skip ]
- when:
condition:
or:
Expand Down
148 changes: 148 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Test Android Helloworld on PR

on: [workflow_dispatch, pull_request, push]

jobs:
prepare_hermes_workspace:
runs-on: 4-core-ubuntu
env:
HERMES_WS_DIR: /tmp/hermes
HERMES_VERSION_FILE: packages/react-native/sdks/.hermesversion
BUILD_FROM_SOURCE: true
outputs:
react-native-version: ${{ steps.react-native-version.outputs.version }}
hermes-version: ${{ steps.hermes-version.outputs.version }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Setup hermes version
id: hermes-version
run: |
mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes"
if [ -f "$HERMES_VERSION_FILE" ]; then
echo "Hermes Version file found! Using this version for the build:"
echo "VERSION=$(cat $HERMES_VERSION_FILE)" >> "$GITHUB_OUTPUT"
else
echo "Hermes Version file not found!!!"
echo "Using the last commit from main for the build:"
HERMES_TAG_SHA=$(git ls-remote https://github.com/$GITHUB_REPOSITORY main | cut -f 1 | tr -d '[:space:]')
echo "VERSION=$HERMES_TAG_SHA" >> "$GITHUB_OUTPUT"
fi
echo "Hermes commit is $HERMES_TAG_SHA"
- name: Get react-native version
id: react-native-version
run: |
VERSION=$(cat packages/react-native/package.json | jq -r '.version')
# Save the react native version we are building in an output variable so we can use that file as part of the cache key.
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "React Native Version is $VERSION"
- name: Cache hermes workspace
uses: actions/[email protected]
with:
path: |
/tmp/hermes/download/
/tmp/hermes/hermes/
key: v1-hermes-${{ steps.hermes-version.outputs.version }}-${{ github.run_number }}
enableCrossOsArchive: true
- name: Yarn- Install Dependencies
run: yarn install --non-interactive
- name: Download Hermes tarball
run: |
node packages/react-native/scripts/hermes/prepare-hermes-for-build ${{ github.event.pull_request.html_url }}
cp packages/react-native/sdks/download/* $HERMES_WS_DIR/download/.
cp -r packages/react-native/sdks/hermes/* $HERMES_WS_DIR/hermes/.
echo ${{ steps.hermes-version.outputs.version }}
test_android_helloworld:
runs-on: ubuntu-latest
needs: prepare_hermes_workspace
container:
image: reactnativecommunity/react-native-android:latest
env:
# Set the encoding to resolve a known character encoding issue with decompressing tar.gz files in conatiners
# via Gradle: https://github.com/gradle/gradle/issues/23391#issuecomment-1878979127
LC_ALL: C.UTF8
YARN_ENABLE_IMMUTABLE_INSTALLS: false
TERM: "dumb"
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
TARGET_ARCHITECTURE: "arm64-v8a"
continue-on-error: true
strategy:
fail-fast: false
matrix:
flavor: [Debug, Release]
architecture: [NewArch, OldArch]
jsengine: [Hermes, JSC]
steps:
- name: Checkout
uses: actions/[email protected]
- name: Cache setup
id: cache_setup
uses: ./.github/actions/cache_setup
with:
hermes-version: ${{ needs.prepare_hermes_workspace.outputs.hermes-version }}
react-native-version: ${{ needs.prepare_hermes_workspace.outputs.react-native-version }}
- name: Run yarn
shell: bash
run: yarn install --non-interactive
- name: Disk check 1
shell: bash
if: always()
run: du -h
- name: Setup gradle
uses: ./.github/actions/setup-gradle
- name: Disk check 2
shell: bash
if: always()
run: du -h
- name: Build CodeGen JS scripts
shell: bash
run: |
cd packages/react-native-codegen
yarn run build
- name: Monitor Disk utilization (before build)
shell: bash
if: always()
run: |
echo "On Runner:"
df -h
echo "Root:"
du -hs *
echo "Projects folder:"
du -hs ./packages/*
- name: Build the Helloworld application for ${{ matrix.flavor }} with Architecture set to ${{ matrix.architecture }}, and using the ${{ matrix.jsengine }} JS engine.
shell: bash
run: |
cd packages/helloworld/android
args=()
if [[ ${{ matrix.architecture }} == "OldArch" ]]; then
args+=(--arch old)
fi
if [[ ${{ matrix.jsengine }} == "JSC" ]]; then
args+=(--jsvm jsc)
fi
if [[ ${{ matrix.flavor }} == "Release" ]]; then
args+=(--prod)
fi
yarn build android "${args[@]}" -P reactNativeArchitectures="$TARGET_ARCHITECTURE"
- name: Monitor Disk utilization (after build)
shell: bash
if: always()
run: |
echo "On Runner:"
df -h
echo "Root:"
du -hs *
echo "Projects folder:"
du -hs ./packages/*
- name: Upload artifact
uses: actions/[email protected]
with:
name: template-apk-${{ matrix.flavor }}-${{ matrix.architecture }}-${{ matrix.jsengine }}
path: ./app/build/outputs/apk/
compression-level: 0

0 comments on commit e91e1fe

Please sign in to comment.