From 27da58bc2a6c5197da8120d8ddc70dcbbb44fad3 Mon Sep 17 00:00:00 2001 From: James Jarvis Date: Sat, 17 May 2025 16:20:03 -0700 Subject: [PATCH] feat: add native units ci --- .../workflows/callable-get-package-list.yml | 12 +++++-- .../workflows/callable-native-unit-tests.yml | 36 +++++++++++++++++++ .../callable-release-verification.yml | 4 +++ .github/workflows/pr.yml | 4 +++ packages/rtn-push-notification/package.json | 3 ++ packages/rtn-web-browser/package.json | 3 ++ 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/callable-native-unit-tests.yml diff --git a/.github/workflows/callable-get-package-list.yml b/.github/workflows/callable-get-package-list.yml index d182faddb5a..0486ca5c355 100644 --- a/.github/workflows/callable-get-package-list.yml +++ b/.github/workflows/callable-get-package-list.yml @@ -6,6 +6,9 @@ on: packages: description: The json encoded package list value: ${{ jobs.get-package-list.outputs.packages }} + nativePackages: + description: The json encoded native package list + value: ${{ jobs.get-package-list.outputs.nativePackages }} jobs: get-package-list: name: Get packages list @@ -31,11 +34,14 @@ jobs: - name: Dump Package List if: steps.cache-package-list.outputs.cache-hit != 'true' run: | - echo "packages=$(yarn lerna ll | egrep -v "lerna|Done|yarn" | jq -R -s -c 'split("\n")[:-1] | map({name: split(" ")[0], path: split(" ")[-1]})')" > package-list.json + yarn lerna ll | egrep -v "lerna|Done|yarn" | jq -R -s -c 'split("\n")[:-1] | map({name: split(" ")[0], path: split(" ")[-1]})' > package-list.json - name: Get Package List id: get_package_list run: | - cat package-list.json >> $GITHUB_OUTPUT - cat package-list.json + echo "packages=$(cat package-list.json)" >> $GITHUB_OUTPUT + # temporarily filter to only packages with runnable tests + echo "nativePackages=$(jq -c 'map(select(.name | test("rtn-passkeys|react-native")))' package-list.json)" >> $GITHUB_OUTPUT outputs: packages: ${{ steps.get_package_list.outputs.packages }} + # todo: expand native package list as other tests are made runnable + nativePackages: ${{ steps.get_package_list.outputs.nativePackages }} diff --git a/.github/workflows/callable-native-unit-tests.yml b/.github/workflows/callable-native-unit-tests.yml new file mode 100644 index 00000000000..b474a57c0d9 --- /dev/null +++ b/.github/workflows/callable-native-unit-tests.yml @@ -0,0 +1,36 @@ +name: Native Unit Tests + +on: workflow_call + +jobs: + get-package-list: + uses: ./.github/workflows/callable-get-package-list.yml + unit_test: + name: Native Unit Test - ${{ matrix.package.name }} + runs-on: macos-latest + needs: get-package-list + strategy: + matrix: + package: ${{ fromJSON(needs.get-package-list.outputs.nativePackages) }} + fail-fast: false + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + path: amplify-js + - name: Setup node and build the repository + uses: ./amplify-js/.github/actions/node-and-build + - name: Run iOS Tests + working-directory: ./amplify-js + env: + TEST_PACKAGE: ${{ matrix.package.name }} + run: | + npx lerna exec --scope $TEST_PACKAGE yarn prepare:ios + npx lerna exec --scope $TEST_PACKAGE yarn test:ios + - name: Run Android Tests + working-directory: ./amplify-js + env: + TEST_PACKAGE: ${{ matrix.package.name }} + run: | + npx lerna exec --scope $TEST_PACKAGE yarn prepare:android + npx lerna exec --scope $TEST_PACKAGE yarn test:android diff --git a/.github/workflows/callable-release-verification.yml b/.github/workflows/callable-release-verification.yml index 30fd4b0c7e0..4b2112d8099 100644 --- a/.github/workflows/callable-release-verification.yml +++ b/.github/workflows/callable-release-verification.yml @@ -25,6 +25,10 @@ jobs: needs: - prebuild-ubuntu uses: ./.github/workflows/callable-unit-tests.yml + native-unit-tests: + needs: + - prebuild-macos + uses: ./.github/workflows/callable-native-unit-tests.yml bundle-size-tests: needs: prebuild-ubuntu uses: ./.github/workflows/callable-bundle-size-tests.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f7e0982cc9c..99024c07a14 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -24,6 +24,10 @@ jobs: needs: - prebuild uses: ./.github/workflows/callable-unit-tests.yml + native-unit-tests: + needs: + - prebuild + uses: ./.github/workflows/callable-native-unit-tests.yml bundle-size-tests: needs: prebuild uses: ./.github/workflows/callable-bundle-size-tests.yml diff --git a/packages/rtn-push-notification/package.json b/packages/rtn-push-notification/package.json index 9d5d709ffc3..1634fd722aa 100644 --- a/packages/rtn-push-notification/package.json +++ b/packages/rtn-push-notification/package.json @@ -11,7 +11,10 @@ "access": "public" }, "scripts": { + "prepare:ios": "echo 'no-op'", + "prepare:android": "echo 'no-op'", "test": "npm run lint && jest -w 1 --coverage --logHeapUsage", + "test:ios": "echo 'no-op'", "test:android": "./android/gradlew test -p ./android", "build-with-test": "npm run clean && npm test && tsc", "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs", diff --git a/packages/rtn-web-browser/package.json b/packages/rtn-web-browser/package.json index 70b4b4e5617..e2c35b93cd8 100644 --- a/packages/rtn-web-browser/package.json +++ b/packages/rtn-web-browser/package.json @@ -11,7 +11,10 @@ "access": "public" }, "scripts": { + "prepare:ios": "echo 'no-op'", + "prepare:android": "echo 'no-op'", "test": "echo 'no-op'", + "test:ios": "echo 'no-op'", "test:android": "./android/gradlew test -p ./android", "build-with-test": "npm run clean && npm test && tsc", "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",