Skip to content

Commit

Permalink
chore(build-system-test): Run build system tests pre-release and on s…
Browse files Browse the repository at this point in the history
…chedule (#5706)
  • Loading branch information
esauerbo authored Aug 30, 2024
1 parent 834b4d3 commit 2e3d373
Show file tree
Hide file tree
Showing 16 changed files with 412 additions and 312 deletions.
118 changes: 3 additions & 115 deletions .github/workflows/build-system-test-react-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,126 +6,14 @@ permissions:
id-token: write # This is required for aws-actions/configure-aws-credentials

on:
push:
branches: ['main']
schedule:
- cron: '0 * * * *' # Run at the first minute of every hour

jobs:
build:
runs-on: macos-13
environment: ci
strategy:
fail-fast: false
matrix:
framework: [react-native]
framework-version: [latest]
# uncomment to re-enable
# build-tool: [cli, expo]
build-tool: [expo]
build-tool-version: [latest]
pkg-manager: [npm]
language: [ts]
node-version: [18]
platform: [ios, android]
logfile: [test.log]
pkg-manager-version: [latest]
exclude:
- build-tool: expo
platform: ios

env:
MEGA_APP_NAME: rn${{ matrix.framework-version }}${{ matrix.build-tool }}${{ matrix.build-tool-version }}${{ matrix.language }}${{ matrix.platform }}

steps:
- name: Checkout Amplify UI
uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017
with:
persist-credentials: false
- name: Setup Node.js ${{ matrix.node-version }} with ${{ matrix.pkg-manager }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 https://github.com/actions/setup-node/commit/60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: ${{ matrix.node-version }}
cache: ${{ matrix.pkg-manager }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2

- name: Restore CocoaPods cache
if: ${{ matrix.platform == 'ios' }}
id: restore-cocoapods-cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
with:
path: ./examples/react-native/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ inputs.commit }}
restore-keys: pods-${{ hashFiles('examples/react-native/ios/Podfile.lock') }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
- name: Restore node_modules cache
if: ${{ matrix.platform == 'ios' }}
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
id: restore-cache
with:
path: |
./node_modules
**/node_modules
key: ${{ runner.os }}-nodemodules-${{ inputs.commit }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
- name: Install Java 17
if: ${{ matrix.platform == 'android' }}
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # 3.6.0
with:
distribution: 'corretto' # Amazon Corretto Build of OpenJDK
java-version: '17'

- name: Install iOS simulator
if: ${{ matrix.platform == 'ios' }}
run: |
brew tap wix/brew
brew install applesimutils
brew install watchman
brew link --overwrite [email protected]
echo "ruby --version"
ruby --version
continue-on-error: true # brew overwrite step addresses a python install issue: https://github.com/actions/runner-images/issues/8500
- name: Update CocoaPods
if: ${{ matrix.platform == 'ios' }}
run: |
gem update cocoapods xcodeproj
yarn react-native-example ios:pod-install
- name: Install Android emulator
if: ${{ matrix.platform == 'android' }}
run: |
echo -e "echo \$ANDROID_HOME"
echo $ANDROID_HOME
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'build-tools;33.0.2' platform-tools
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "system-images;android-27;default;x86_64"
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd --force --name Pixel_5_API_27 --device "pixel_5" --abi x86_64 --package "system-images;android-27;default;x86_64"
printf 'hw.cpu.ncore=2\n' >> ~/.android/avd/Pixel_5_API_27.avd/config.ini
printf 'hw.ramSize=2048\n' >> ~/.android/avd/Pixel_5_API_27.avd/config.ini
printf 'hw.heapSize=576\n' >> ~/.android/avd/Pixel_5_API_27.avd/config.ini
- name: Start Android emulator
if: ${{ matrix.platform == 'android' }}
run: |
nohup $ANDROID_HOME/emulator/emulator -avd Pixel_5_API_27 -no-boot-anim -no-audio -no-snapshot-load -gpu host -accel on &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
$ANDROID_HOME/platform-tools/adb devices
# disable spell checker
$ANDROID_HOME/platform-tools/adb shell settings put secure spell_checker_enabled 0
# disable animations
$ANDROID_HOME/platform-tools/adb shell settings put global window_animation_scale 0.0
$ANDROID_HOME/platform-tools/adb shell settings put global transition_animation_scale 0.0
$ANDROID_HOME/platform-tools/adb shell settings put global animator_duration_scale 0.0
- name: Create MegaApp ${{ env.MEGA_APP_NAME }} and run build on NodeJS ${{ matrix.node-version }}
run: npm run ${{ env.MEGA_APP_NAME }}
shell: bash
working-directory: build-system-tests
- name: Detect Mega App Error in Log
run: npm run checkReactNativeLogs -- --log-file-name ${{ matrix.logfile }} --mega-app-name ${{ env.MEGA_APP_NAME }} --platform ${{ matrix.platform }}
shell: bash
working-directory: build-system-tests
uses: ./.github/workflows/reusable-build-system-test-react-native.yml
with:
dist-tag: latest

log-failure-metric:
# Send a failure data point to metric BuildSystemTestFailure in github-workflows@ us-east-2
Expand Down
124 changes: 3 additions & 121 deletions .github/workflows/build-system-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,127 +11,9 @@ on:

jobs:
build:
runs-on: ubuntu-latest
environment: ci
strategy:
fail-fast: false
matrix:
framework: [react]
framework-version: [latest]
build-tool: [cra, next, vite]
build-tool-version: [latest]
pkg-manager: [npm]
language: [ts]
node-version: [18]
pkg-manager-version: [latest]
include:
- framework: react
framework-version: latest
build-tool: cra
build-tool-version: latest
pkg-manager: npm
language: ts
node-version: 20
- framework: react
framework-version: 16
build-tool: cra
build-tool-version: latest
pkg-manager: npm
language: ts
node-version: 20
- framework: react
framework-version: latest
build-tool: cra
build-tool-version: latest
pkg-manager: npm
language: js
node-version: 20
- framework: react
framework-version: latest
build-tool: cra
build-tool-version: latest
pkg-manager: yarn
pkg-manager-version: 1
language: ts
node-version: 20
- framework: react
framework-version: 18
build-tool: next
build-tool-version: 12
pkg-manager: npm
language: ts
node-version: 20
- framework: react
framework-version: latest
build-tool: vite
build-tool-version: 2
pkg-manager: npm
language: ts
node-version: 20

- framework: angular
framework-version: latest
build-tool: angular-cli
build-tool-version: latest
pkg-manager: npm
language: ts
node-version: 20
- framework: angular
framework-version: 14
build-tool: angular-cli
build-tool-version: 14
pkg-manager: npm
language: ts
node-version: 20

- framework: vue
framework-version: 3 # here use "3" instead of "latest" because .vuerc(preset) doesn't accept "latest" as "vueVersion"
build-tool: vue-cli
build-tool-version: latest
pkg-manager: yarn # vue-cli defualt pkg-manager is yarn. It can't be customized in the preset.json.
language: ts
node-version: 20
- framework: vue
framework-version: latest
build-tool: vite
build-tool-version: latest
pkg-manager: npm
language: ts
node-version: 20
- framework: vue
framework-version: latest
build-tool: vite
build-tool-version: 3
pkg-manager: npm
language: ts
node-version: 20
- framework: vue
framework-version: latest
build-tool: nuxt
build-tool-version: latest
pkg-manager: npm
language: ts
node-version: 20

env:
MEGA_APP_NAME: ${{ matrix.framework }}-${{ matrix.framework-version }}-${{ matrix.build-tool }}-${{ matrix.build-tool-version }}-${{ matrix.language }}

steps:
- name: Checkout Amplify UI
uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017
with:
persist-credentials: false
- name: Setup Node.js ${{ matrix.node-version }} with ${{ matrix.pkg-manager }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 https://github.com/actions/setup-node/commit/60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: ${{ matrix.node-version }}
cache: ${{ matrix.pkg-manager }}
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
- name: Create MegaApp ${{ env.MEGA_APP_NAME }} and run build on NodeJS ${{ matrix.node-version }}
run: npm run ${{ env.MEGA_APP_NAME }}
shell: bash
working-directory: build-system-tests
uses: ./.github/workflows/reusable-build-system-test.yml
with:
dist-tag: latest

log-failure-metric:
# Send a failure data point to metric BuildSystemTestFailure in github-workflows@ us-east-2
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/publish-hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,25 @@ jobs:
run: yarn build
working-directory: ./canary

build-test-v2:
uses: ./.github/workflows/reusable-build-system-test.yml
needs: publish-hotfix
with:
dist-tag: hotfix

build-test-v2-react-native:
uses: ./.github/workflows/reusable-build-system-test-react-native.yml
needs: publish-hotfix
with:
dist-tag: hotfix

publish:
runs-on: ubuntu-latest
environment: deployment
needs: build-test
needs:
- build-test
- build-test-v2
- build-test-v2-react-native
if: ${{ needs.setup.outputs.has-changesets != 'true' }}
steps:
- name: Checkout repo
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/publish-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,25 @@ jobs:
run: yarn build
working-directory: ./canary

build-test-v2:
uses: ./.github/workflows/reusable-build-system-test.yml
needs: setup
with:
dist-tag: next

build-test-v2-react-native:
uses: ./.github/workflows/reusable-build-system-test-react-native.yml
needs: setup
with:
dist-tag: next

publish:
runs-on: ubuntu-latest
environment: deployment
needs: build-test
needs:
- build-test
- build-test-v2
- build-test-v2-react-native
if: ${{ needs.setup.outputs.has-changesets != 'true' }}
steps:
- name: Checkout repo
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ jobs:
env:
ENDPOINT: ${{ secrets.LIVENESS_BETA_SAMPLE_APP_BUILD_TRIGGER }}

build-test-v2:
uses: ./.github/workflows/reusable-build-system-test.yml
needs: publish
with:
dist-tag: next

build-test-v2-react-native:
uses: ./.github/workflows/reusable-build-system-test-react-native.yml
needs: publish
with:
dist-tag: next

build-test:
needs: publish
runs-on: ubuntu-latest
Expand Down Expand Up @@ -121,7 +133,10 @@ jobs:
# Send a failure data point to metric PublishNextFailure in github-workflows@ us-east-2, if it's a failure
runs-on: ubuntu-latest
environment: ci
needs: build-test
needs:
- build-test
- build-test-v2
- build-test-v2-react-native
if: ${{ failure() }}
steps:
- name: Log failure data point to metric PublishNextFailure
Expand All @@ -136,7 +151,10 @@ jobs:
# Send a success data point to metric PublishNextFailure in github-workflows@ us-east-2, if it's a success
runs-on: ubuntu-latest
environment: ci
needs: build-test
needs:
- build-test
- build-test-v2
- build-test-v2-react-native
if: ${{ success() }}
steps:
- name: Log success data point to metric PublishNextFailure
Expand Down
Loading

0 comments on commit 2e3d373

Please sign in to comment.