From 2e3d3733445446fc4d30173b3203dd2d40c5e3fe Mon Sep 17 00:00:00 2001 From: Emma Sauerborn <70536670+esauerbo@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:49:13 -0400 Subject: [PATCH] chore(build-system-test): Run build system tests pre-release and on schedule (#5706) --- .../build-system-test-react-native.yml | 118 +--------------- .github/workflows/build-system-test.yml | 124 +--------------- .github/workflows/publish-hotfix.yml | 17 ++- .github/workflows/publish-latest.yml | 17 ++- .github/workflows/publish-next.yml | 22 ++- ...eusable-build-system-test-react-native.yml | 125 ++++++++++++++++ .../workflows/reusable-build-system-test.yml | 133 ++++++++++++++++++ build-system-tests/package.json | 64 ++++++--- build-system-tests/scripts/build-android.sh | 16 +-- build-system-tests/scripts/build-ios.sh | 20 +-- ...h => install-dependencies-with-retries.sh} | 2 +- build-system-tests/scripts/mega-app-build.sh | 5 - .../scripts/mega-app-copy-files.sh | 5 - .../scripts/mega-app-create-app.sh | 5 - .../scripts/mega-app-install.sh | 41 +++--- build-system-tests/scripts/setup-mega-app.sh | 10 +- 16 files changed, 412 insertions(+), 312 deletions(-) create mode 100644 .github/workflows/reusable-build-system-test-react-native.yml create mode 100644 .github/workflows/reusable-build-system-test.yml rename build-system-tests/scripts/{install-with-retries.sh => install-dependencies-with-retries.sh} (95%) diff --git a/.github/workflows/build-system-test-react-native.yml b/.github/workflows/build-system-test-react-native.yml index 0f350eb8ad3..7a700eae7c9 100644 --- a/.github/workflows/build-system-test-react-native.yml +++ b/.github/workflows/build-system-test-react-native.yml @@ -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 python@3.11 - 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 diff --git a/.github/workflows/build-system-test.yml b/.github/workflows/build-system-test.yml index 6021f044aae..14f0f6e8573 100644 --- a/.github/workflows/build-system-test.yml +++ b/.github/workflows/build-system-test.yml @@ -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 diff --git a/.github/workflows/publish-hotfix.yml b/.github/workflows/publish-hotfix.yml index e637955c6b7..80ccdbc2fc2 100644 --- a/.github/workflows/publish-hotfix.yml +++ b/.github/workflows/publish-hotfix.yml @@ -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 diff --git a/.github/workflows/publish-latest.yml b/.github/workflows/publish-latest.yml index 7b03bcbf156..fc629a39e67 100644 --- a/.github/workflows/publish-latest.yml +++ b/.github/workflows/publish-latest.yml @@ -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 diff --git a/.github/workflows/publish-next.yml b/.github/workflows/publish-next.yml index 5ba3467b3d3..e2070f1d0b4 100644 --- a/.github/workflows/publish-next.yml +++ b/.github/workflows/publish-next.yml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/reusable-build-system-test-react-native.yml b/.github/workflows/reusable-build-system-test-react-native.yml new file mode 100644 index 00000000000..00aa55b54bd --- /dev/null +++ b/.github/workflows/reusable-build-system-test-react-native.yml @@ -0,0 +1,125 @@ +# Description: this is a reusable workflow that runs build on mega-apps that have all the connected components for React Native. +# +# See build-system-test-react-native.yml for usage. +on: + workflow_call: + inputs: + dist-tag: + required: true + type: string + +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 }}-ui-${{ inputs.dist-tag }} + + 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 python@3.11 + 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 diff --git a/.github/workflows/reusable-build-system-test.yml b/.github/workflows/reusable-build-system-test.yml new file mode 100644 index 00000000000..283eede0b53 --- /dev/null +++ b/.github/workflows/reusable-build-system-test.yml @@ -0,0 +1,133 @@ +# Description: this is a reusable workflow that runs build on mega-apps that have all the connected components for React Native. +# +# See build-system-test.yml for usage. +on: + workflow_call: + inputs: + dist-tag: + required: true + type: string + +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 }}-ui-${{ inputs.dist-tag }} + + 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 diff --git a/build-system-tests/package.json b/build-system-tests/package.json index d9d04caf20c..a53652cedcd 100644 --- a/build-system-tests/package.json +++ b/build-system-tests/package.json @@ -23,22 +23,54 @@ "setup:react-native": "./scripts/setup-mega-app.sh -F react-native", "setup:react-native:cli": "./scripts/setup-mega-app.sh -F react-native -B cli", "setup:react-native:expo": "./scripts/setup-mega-app.sh -F react-native -B expo", - "react-latest-cra-latest-ts": "npm run setup:react:cra -- -P yarn", - "react-latest-next-latest-ts": "npm run setup:react:next", - "react-latest-vite-latest-ts": "npm run setup:react:vite", - "react-16-cra-latest-ts": "npm run setup:react:cra -- -f 16", - "react-latest-cra-latest-js": "npm run setup:react:cra -- -l js", - "react-18-next-12-ts": "npm run setup:react:next -- -f 18 -b 12", - "react-latest-vite-2-ts": "npm run setup:react:vite -- -b 2", - "angular-latest-angular-cli-latest-ts": "npm run setup:angular:cli", - "angular-14-angular-cli-14-ts": "npm run setup:angular:cli -- -f 14 -b 14 -n angular-14-angular-cli-14-ts", - "vue-3-vue-cli-latest-ts": "npm run setup:vue:cli -- -f 3 -P yarn", - "vue-latest-vite-latest-ts": "npm run setup:vue:vite", - "vue-latest-vite-3-ts": "npm run setup:vue:vite -- -b 3", - "vue-latest-nuxt-latest-ts": "npm run setup:vue:nuxt", - "rnlatestclilatesttsios": "npm run setup:react-native:cli -- -A ios -n rnLatestCliLatestTsIos", - "rnlatestclilatesttsandroid": "npm run setup:react-native:cli -- -A android -n rnLatestCliLatestTsAndroid", - "rnlatestexpolatesttsandroid": "npm run setup:react-native:expo -- -A android -n rnLatestExpoLatestTsAndroid", + "react-latest-cra-latest-ts-ui-latest": "npm run setup:react:cra -- -P yarn", + "react-latest-cra-latest-ts-ui-next": "npm run setup:react:cra -- -P yarn -t next", + "react-latest-cra-latest-ts-ui-hotfix": "npm run setup:react:cra -- -P yarn -t hotfix", + "react-latest-next-latest-ts-ui-latest": "npm run setup:react:next", + "react-latest-next-latest-ts-ui-next": "npm run setup:react:next -- -t next", + "react-latest-next-latest-ts-ui-hotfix": "npm run setup:react:next -- -t hotfix", + "react-latest-vite-latest-ts-ui-latest": "npm run setup:react:vite", + "react-latest-vite-latest-ts-ui-next": "npm run setup:react:vite -- -t next", + "react-latest-vite-latest-ts-ui-hotfix": "npm run setup:react:vite -- -t hotfix", + "react-16-cra-latest-ts-ui-latest": "npm run setup:react:cra -- -f 16", + "react-16-cra-latest-ts-ui-next": "npm run setup:react:cra -- -f 16 -t next", + "react-16-cra-latest-ts-ui-hotfix": "npm run setup:react:cra -- -f 16 -t hotfix", + "react-latest-cra-latest-js-ui-latest": "npm run setup:react:cra -- -l js", + "react-latest-cra-latest-js-ui-next": "npm run setup:react:cra -- -l js -t next", + "react-latest-cra-latest-js-ui-hotfix": "npm run setup:react:cra -- -l js -t hotfix", + "react-18-next-12-ts-ui-latest": "npm run setup:react:next -- -f 18 -b 12", + "react-18-next-12-ts-ui-next": "npm run setup:react:next -- -f 18 -b 12 -t next", + "react-18-next-12-ts-ui-hotfix": "npm run setup:react:next -- -f 18 -b 12 -t hotfix", + "react-latest-vite-2-ts-ui-latest": "npm run setup:react:vite -- -b 2", + "react-latest-vite-2-ts-ui-next": "npm run setup:react:vite -- -b 2 -t next", + "react-latest-vite-2-ts-ui-hotfix": "npm run setup:react:vite -- -b 2 -t hotfix", + "angular-latest-angular-cli-latest-ts-ui-latest": "npm run setup:angular:cli", + "angular-latest-angular-cli-latest-ts-ui-next": "npm run setup:angular:cli -- -t next", + "angular-latest-angular-cli-latest-ts-ui-hotfix": "npm run setup:angular:cli -- -t hotfix", + "angular-14-angular-cli-14-ts-ui-latest": "npm run setup:angular:cli -- -f 14 -b 14 -n angular-14-angular-cli-14-ts-ui-latest", + "angular-14-angular-cli-14-ts-ui-next": "npm run setup:angular:cli -- -f 14 -b 14 -n angular-14-angular-cli-14-ts-ui-next -t next", + "angular-14-angular-cli-14-ts-ui-hotfix": "npm run setup:angular:cli -- -f 14 -b 14 -n angular-14-angular-cli-14-ts-ui-hotfix -t hotfix", + "vue-3-vue-cli-latest-ts-ui-latest": "npm run setup:vue:cli -- -f 3 -P yarn", + "vue-3-vue-cli-latest-ts-ui-next": "npm run setup:vue:cli -- -f 3 -P yarn -t next", + "vue-3-vue-cli-latest-ts-ui-hotfix": "npm run setup:vue:cli -- -f 3 -P yarn -t hotfix", + "vue-latest-vite-latest-ts-ui-latest": "npm run setup:vue:vite", + "vue-latest-vite-latest-ts-ui-next": "npm run setup:vue:vite -- -t next", + "vue-latest-vite-latest-ts-ui-hotfix": "npm run setup:vue:vite -- -t hotfix", + "vue-latest-vite-3-ts-ui-latest": "npm run setup:vue:vite -- -b 3", + "vue-latest-vite-3-ts-ui-next": "npm run setup:vue:vite -- -b 3 -t next", + "vue-latest-vite-3-ts-ui-hotfix": "npm run setup:vue:vite -- -b 3 -t hotfix", + "vue-latest-nuxt-latest-ts-ui-latest": "npm run setup:vue:nuxt", + "vue-latest-nuxt-latest-ts-ui-next": "npm run setup:vue:nuxt -- -t next", + "vue-latest-nuxt-latest-ts-ui-hotfix": "npm run setup:vue:nuxt -- -t hotfix", + "rn-latest-cli-latest-ts-ios-ui-latest": "npm run setup:react-native:cli -- -A ios", + "rn-latest-cli-latest-ts-ios-ui-next": "npm run setup:react-native:cli -- -A ios -t next", + "rn-latest-cli-latest-ts-ios-ui-hotfix": "npm run setup:react-native:cli -- -A ios -t hotfix", + "rn-latest-cli-latest-ts-android-ui-latest": "npm run setup:react-native:cli -- -A android", + "rn-latest-cli-latest-ts-android-ui-next": "npm run setup:react-native:cli -- -A android -t next", + "rn-latest-cli-latest-ts-android-ui-hotfix": "npm run setup:react-native:cli -- -A android -t hotfix", + "rn-latest-expo-latest-ts-android-ui-latest": "npm run setup:react-native:expo -- -A android -n rn-latest-expo-latest-ts-android-ui-latest", + "rn-latest-expo-latest-ts-android-ui-next": "npm run setup:react-native:expo -- -A android -n rn-latest-expo-latest-ts-android-ui-next -t next", + "rn-latest-expo-latest-ts-android-ui-hotfix": "npm run setup:react-native:expo -- -A android -n rn-latest-expo-latest-ts-android-ui-hotfix -t hotfix", "checkReactNativeLogs": "node --require esbuild-register ./scripts/checkReactNativeLog.ts" } } diff --git a/build-system-tests/scripts/build-android.sh b/build-system-tests/scripts/build-android.sh index 3beb618a6a3..9887f928458 100755 --- a/build-system-tests/scripts/build-android.sh +++ b/build-system-tests/scripts/build-android.sh @@ -32,12 +32,12 @@ if [ $BUILD_TOOL == 'expo' ]; then npm run android -- -p 19000 >$LOG_FILE & npx wait-on -t 20000 tcp:19000 else - log "command" "cd android" - cd android - log "command" "./gradlew clean" # To prevent "installDebug FAILED" https://stackoverflow.com/a/54955869/12610324 - ./gradlew clean - log "command" "cd .." - cd .. - log "command" "npm run android" - npm run android + log "command" "cd android >$LOG_FILE " + cd android >$LOG_FILE + log "command" "./gradlew clean >$LOG_FILE" # To prevent "installDebug FAILED" https://stackoverflow.com/a/54955869/12610324 + ./gradlew clean >$LOG_FILE + log "command" "cd .. >$LOG_FILE" + cd .. >$LOG_FILE + log "command" "npm run android >$LOG_FILE" + npm run android >$LOG_FILE fi diff --git a/build-system-tests/scripts/build-ios.sh b/build-system-tests/scripts/build-ios.sh index bf74080f8e3..f7b26c543c9 100755 --- a/build-system-tests/scripts/build-ios.sh +++ b/build-system-tests/scripts/build-ios.sh @@ -16,22 +16,22 @@ cd mega-apps/$MEGA_APP_NAME # Step 1: Log errors to LOG_FILE in the background log "command" "touch $LOG_FILE" touch $LOG_FILE -log "command" "npm install -D react-native-log-ios" -npm install -D react-native-log-ios +log "command" "npm install -D react-native-log-ios >$LOG_FILE" +npm install -D react-native-log-ios >$LOG_FILE log "command" "npx react-native-log-ios $MEGA_APP_NAME >$LOG_FILE &" npx react-native-log-ios $MEGA_APP_NAME >$LOG_FILE & # Run `npm start` to prevent "no bundle URL present" # details: https://stackoverflow.com/questions/42610070/what-is-the-meaning-of-no-bundle-url-present-in-react-native -log "command" "npm start" -npm start & +log "command" "npm start >$LOG_FILE" +npm start >$LOG_FILE & -# Step 2: Run npm run android in the background -log "command" "npx pod-install" # To prevent "AsyncStorage is null." https://react-native-async-storage.github.io/async-storage/docs/install/ -npx pod-install -log "command" "npm run ios" +# Step 2: Run npm run ios in the background +log "command" "npx pod-install >$LOG_FILE" # To prevent "AsyncStorage is null." https://react-native-async-storage.github.io/async-storage/docs/install/ +npx pod-install >$LOG_FILE +log "command" "npm run ios >$LOG_FILE" if [ $BUILD_TOOL == 'expo' ]; then - npx expo start --ios -p 19001 + npx expo start --ios -p 19001 >$LOG_FILE else - npm run ios + npm run ios >$LOG_FILE fi diff --git a/build-system-tests/scripts/install-with-retries.sh b/build-system-tests/scripts/install-dependencies-with-retries.sh similarity index 95% rename from build-system-tests/scripts/install-with-retries.sh rename to build-system-tests/scripts/install-dependencies-with-retries.sh index bd902f58850..46b402191d3 100644 --- a/build-system-tests/scripts/install-with-retries.sh +++ b/build-system-tests/scripts/install-dependencies-with-retries.sh @@ -3,7 +3,7 @@ # Runs `npm` or `yarn` install with retries # Takes 2 parameters: the package manager and the dependencies to be installed # Usage: install_with_retries npm "$DEPENDENCIES" or install_with_retries yarn "$DEPENDENCIES" -install_with_retries() { +install_dependencies_with_retries() { local retries=3 local attempt=1 while [ $attempt -le $retries ]; do diff --git a/build-system-tests/scripts/mega-app-build.sh b/build-system-tests/scripts/mega-app-build.sh index c550e46b892..d98c2091aa0 100755 --- a/build-system-tests/scripts/mega-app-build.sh +++ b/build-system-tests/scripts/mega-app-build.sh @@ -72,11 +72,6 @@ while [[ $# -gt 0 ]]; do shift done -# Check if MEGA_APP_NAME is provided -if [[ -z "$MEGA_APP_NAME" ]]; then - MEGA_APP_NAME="$FRAMEWORK-$FRAMEWORK_VERSION-$BUILD_TOOL-$BUILD_TOOL_VERSION-$LANGUAGE" -fi - echo "########################" echo "# Start Mega App Build #" echo "########################" diff --git a/build-system-tests/scripts/mega-app-copy-files.sh b/build-system-tests/scripts/mega-app-copy-files.sh index 56e6e603efa..fc5da77ba9f 100755 --- a/build-system-tests/scripts/mega-app-copy-files.sh +++ b/build-system-tests/scripts/mega-app-copy-files.sh @@ -60,11 +60,6 @@ while [[ $# -gt 0 ]]; do shift done -# Check if MEGA_APP_NAME is provided -if [[ -z "$MEGA_APP_NAME" ]]; then - MEGA_APP_NAME="$FRAMEWORK-$FRAMEWORK_VERSION-$BUILD_TOOL-$BUILD_TOOL_VERSION-$LANGUAGE" -fi - echo "#######################" echo "# Start Copying Files #" echo "#######################" diff --git a/build-system-tests/scripts/mega-app-create-app.sh b/build-system-tests/scripts/mega-app-create-app.sh index c5a3aa6b0c1..ca7b7a85038 100755 --- a/build-system-tests/scripts/mega-app-create-app.sh +++ b/build-system-tests/scripts/mega-app-create-app.sh @@ -60,11 +60,6 @@ while [[ $# -gt 0 ]]; do shift done -# Check if MEGA_APP_NAME is provided -if [[ -z "$MEGA_APP_NAME" ]]; then - MEGA_APP_NAME="$FRAMEWORK-$FRAMEWORK_VERSION-$BUILD_TOOL-$BUILD_TOOL_VERSION-$LANGUAGE" -fi - echo "###########################" echo "# Start Creating Mega App #" echo "###########################" diff --git a/build-system-tests/scripts/mega-app-install.sh b/build-system-tests/scripts/mega-app-install.sh index c7d78e367d1..4eefc58d9a7 100755 --- a/build-system-tests/scripts/mega-app-install.sh +++ b/build-system-tests/scripts/mega-app-install.sh @@ -9,9 +9,10 @@ FRAMEWORK="react" FRAMEWORK_VERSION="latest" PKG_MANAGER="npm" PKG_MANAGER_VERSION="latest" +TAG="latest" # Import install function -source "./scripts/install-with-retries.sh" +source "./scripts/install-dependencies-with-retries.sh" # Options # e.g. @@ -53,6 +54,10 @@ while [[ $# -gt 0 ]]; do PKG_MANAGER_VERSION=$2 shift ;; + -t | --tag) + TAG=$2 + shift + ;; -h | --help) echo "Usage: mega-app-create-app.sh [OPTIONS]" echo "Options:" @@ -64,6 +69,7 @@ while [[ $# -gt 0 ]]; do echo " -f, --framework-version Specify the framework version (default: latest)" echo " -P, --pkg-manager Specify the package manager: npm, yarn (default: npm)" echo " -p, --pkg-manager-version Specify the package manager version (default: latest)" + echo " -t, --tag Specify the tag (default: latest)" echo " -h, --help Show help message" exit 0 ;; @@ -75,25 +81,21 @@ while [[ $# -gt 0 ]]; do shift done -# Check if MEGA_APP_NAME is provided -if [[ -z "$MEGA_APP_NAME" ]]; then - MEGA_APP_NAME="$FRAMEWORK-$FRAMEWORK_VERSION-$BUILD_TOOL-$BUILD_TOOL_VERSION-$LANGUAGE" -fi - echo "##########################" echo "# Start Mega App Install #" echo "##########################" -DEPENDENCIES="$FRAMEWORK@$FRAMEWORK_VERSION @aws-amplify/ui-$FRAMEWORK aws-amplify" +TAGGED_UI_FRAMEWORK="@aws-amplify/ui-$FRAMEWORK@$TAG" +DEPENDENCIES="$FRAMEWORK@$FRAMEWORK_VERSION $TAGGED_UI_FRAMEWORK aws-amplify" echo "cd ./mega-apps/${MEGA_APP_NAME}" -cd ./mega-apps/${MEGA_APP_NAME} +cd "./mega-apps/${MEGA_APP_NAME}" if [ "$FRAMEWORK" == 'react' ]; then # add react-dom - echo "DEPENDENCIES='$DEPENDENCIES react-dom@$FRAMEWORK_VERSION @aws-amplify/ui-react-storage @aws-amplify/ui-react-geo @aws-amplify/ui-react-notifications @aws-amplify/geo'" - DEPENDENCIES="$DEPENDENCIES react-dom@$FRAMEWORK_VERSION @aws-amplify/ui-react-storage @aws-amplify/ui-react-geo @aws-amplify/ui-react-notifications @aws-amplify/geo" - + DEPENDENCIES="$DEPENDENCIES react-dom@$FRAMEWORK_VERSION @aws-amplify/ui-react-storage@$TAG @aws-amplify/ui-react-geo@$TAG @aws-amplify/ui-react-notifications@$TAG @aws-amplify/geo" + echo "DEPENDENCIES=$DEPENDENCIES" + if [[ "$BUILD_TOOL" == 'cra' && "$LANGUAGE" == 'ts' ]]; then DEP_TYPES="@types/react@$FRAMEWORK_VERSION @types/react-dom@$FRAMEWORK_VERSION" echo "DEP_TYPES='$DEP_TYPES'" @@ -102,17 +104,15 @@ if [ "$FRAMEWORK" == 'react' ]; then elif [ "$FRAMEWORK" == 'angular' ]; then # remove angular since it's deprecated https://www.npmjs.com/package/angular # We've install @amplify/cli when creating the app - echo "DEPENDENCIES="@aws-amplify/ui-$FRAMEWORK aws-amplify"" - DEPENDENCIES="@aws-amplify/ui-$FRAMEWORK aws-amplify" + DEPENDENCIES="$TAGGED_UI_FRAMEWORK aws-amplify" + echo "DEPENDENCIES=$DEPENDENCIES" fi -echo "Dependencies to be installed: $DEPENDENCIES" - if [ "$PKG_MANAGER" == 'yarn' ]; then echo "yarn version" yarn -v echo "yarn set version $PKG_MANAGER_VERSION" - yarn set version $PKG_MANAGER_VERSION + yarn set version "$PKG_MANAGER_VERSION" echo "yarn version" yarn -v if [[ "$BUILD_TOOL" == 'cra' && "$LANGUAGE" == 'ts' ]]; then @@ -125,7 +125,7 @@ else if [[ "$BUILD_TOOL" == 'cra' && "$LANGUAGE" == 'ts' ]]; then # If not testing the latest React, we need to download its types. # CRA is the only framework that we test React 16. - install_with_retries npm "$DEP_TYPES" + install_dependencies_with_retries npm "$DEP_TYPES" fi if [[ "$BUILD_TOOL" == 'next' && "$BUILD_TOOL_VERSION" == '11' ]]; then @@ -136,14 +136,15 @@ else fi if [[ "$FRAMEWORK" == "react-native" ]]; then - echo "npm install @aws-amplify/ui-react-native @aws-amplify/react-native aws-amplify react-native-safe-area-context @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values react-native-url-polyfill" - npm install @aws-amplify/ui-react-native @aws-amplify/react-native aws-amplify react-native-safe-area-context @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values react-native-url-polyfill + DEPENDENCIES="$TAGGED_UI_FRAMEWORK @aws-amplify/react-native aws-amplify react-native-safe-area-context @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values react-native-url-polyfill" + echo "npm install $DEPENDENCIES" + npm install $DEPENDENCIES if [[ "$BUILD_TOOL" == "expo" ]]; then echo "npx expo install --fix" npx expo install --fix # fix the dependencies that are incompatible with the installed expo versio fi else - install_with_retries npm "$DEPENDENCIES" + install_dependencies_with_retries npm "$DEPENDENCIES" fi fi diff --git a/build-system-tests/scripts/setup-mega-app.sh b/build-system-tests/scripts/setup-mega-app.sh index 22f1cfb6e26..52b0fab5c82 100755 --- a/build-system-tests/scripts/setup-mega-app.sh +++ b/build-system-tests/scripts/setup-mega-app.sh @@ -10,6 +10,7 @@ FRAMEWORK_VERSION="latest" PKG_MANAGER="npm" PKG_MANAGER_VERSION="latest" PLATFORM="android" +TAG="latest" # Options # e.g. @@ -55,6 +56,10 @@ while [[ $# -gt 0 ]]; do PKG_MANAGER_VERSION=$2 shift ;; + -t | --tag) + TAG=$2 + shift + ;; -h | --help) echo "Usage: mega-app-create-app.sh [OPTIONS]" echo "Options:" @@ -67,6 +72,7 @@ while [[ $# -gt 0 ]]; do echo " -f, --framework-version Specify the framework version (default: latest)" echo " -P, --pkg-manager Specify the package manager: npm, yarn (default: npm)" echo " -p, --pkg-manager-version Specify the package manager version (default: latest)" + echo " -t, --tag Specify the Amplify UI version tag (default: latest)" echo " -h, --help Show help message" exit 0 ;; @@ -80,7 +86,7 @@ done # Check if MEGA_APP_NAME is provided if [[ -z "$MEGA_APP_NAME" ]]; then - MEGA_APP_NAME="$FRAMEWORK-$FRAMEWORK_VERSION-$BUILD_TOOL-$BUILD_TOOL_VERSION-$LANGUAGE" + MEGA_APP_NAME="$FRAMEWORK-$FRAMEWORK_VERSION-$BUILD_TOOL-$BUILD_TOOL_VERSION-$LANGUAGE-ui-$TAG" fi echo "##################" @@ -96,7 +102,7 @@ BASE_OPTIONS="--build-tool $BUILD_TOOL --build-tool-version $BUILD_TOOL_VERSION ./scripts/mega-app-copy-files.sh $BASE_OPTIONS # Install dependencies -./scripts/mega-app-install.sh $BASE_OPTIONS --pkg-manager $PKG_MANAGER --pkg-manager-version $PKG_MANAGER_VERSION +./scripts/mega-app-install.sh $BASE_OPTIONS --pkg-manager $PKG_MANAGER --pkg-manager-version $PKG_MANAGER_VERSION --tag $TAG # Build mega app ./scripts/mega-app-build.sh $BASE_OPTIONS --platform $PLATFORM