version: 2.1 aliases: - &node-version '22.19.0' - &yarn-version '1.22.22' orbs: node: circleci/node@5.3.0 browser-tools: circleci/browser-tools@1.5.3 android: circleci/android@2.5.0 executors: node: docker: - image: cimg/node:22.19.0 working_directory: ~/react-native-url-polyfill environment: NODE_OPTIONS: '--openssl-legacy-provider' node-browsers: docker: - image: cimg/node:22.19.0-browsers environment: NODE_OPTIONS: '--openssl-legacy-provider' android: docker: - image: cimg/android:2023.12.1-node resource_class: large environment: JAVA_TOOL_OPTIONS: '-Xmx1536m' GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2' NODE_OPTIONS: '--openssl-legacy-provider' commands: save-cache-yarn: steps: - save_cache: key: yarn-packages-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} paths: - ~/.cache/yarn restore-cache-yarn: steps: - restore_cache: name: Restore Yarn Package Cache keys: - yarn-packages-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock" }} save-cache-detox-env: steps: - save_cache: key: detox-env-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "/usr/bin/xcodebuild" }}-{{ .Environment.CIRCLE_WORKING_DIRECTORY }} paths: - /usr/local/Homebrew - ~/Library/Caches/Homebrew restore-cache-detox-env: steps: - restore_cache: name: Restoring Detox Env Cache keys: - detox-env-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "/usr/bin/xcodebuild" }}-{{ .Environment.CIRCLE_WORKING_DIRECTORY }} save-cache-detox-app: steps: - save_cache: key: detox-app-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock"}} paths: - node_modules - ios/Pods restore-cache-detox-app: steps: - restore_cache: name: Restoring Detox App Cache keys: - detox-app-{{ .Environment.CACHE_VERSION }}-{{ checksum "yarn.lock"}} save-android-build-cache: steps: - save_cache: paths: - ~/.gradle/caches - ~/.gradle/wrapper - ~/.android/build-cache key: gradle-build-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}-{{ checksum "yarn.lock" }} when: always # Ensures build assets are cached even on failed builds restore-android-build-cache: steps: - restore_cache: name: Restoring Android & Gradle cache keys: - gradle-build-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}-{{ checksum "yarn.lock" }} attach-workspace: steps: - attach_workspace: at: ~/react-native-url-polyfill install-yarn-dependencies: steps: - run: name: Yarn version command: yarn -v - run: name: Yarn Install command: | yarn install --frozen-lockfile --no-progress --non-interactive --cache-folder ~/.cache/yarn install-detox: steps: - restore-cache-detox-env - run: name: Install Detox command: | brew tap wix/brew brew install applesimutils yarn global add detox-cli - run: name: Clean Detox command: | detox clean-framework-cache && detox build-framework-cache - save-cache-detox-env install-node: parameters: install-yarn: type: boolean default: true steps: - node/install: node-version: *node-version install-yarn: << parameters.install-yarn >> yarn-version: *yarn-version jobs: checkout: executor: node steps: - checkout - restore-cache-yarn - run: name: Yarn version command: yarn -v - run: name: Yarn Install command: | yarn install --frozen-lockfile --no-progress --non-interactive --cache-folder ~/.cache/yarn - save-cache-yarn - persist_to_workspace: root: . paths: - . lint: executor: node steps: - attach-workspace - run: name: Lint command: yarn lint type-check: executor: node steps: - attach-workspace - run: name: Type Check command: yarn type-check test-js: parameters: react-native-version: type: string default: '' executor: node steps: - attach-workspace - when: condition: << parameters.react-native-version >> steps: - run: name: Overriding react-native version command: yarn add --dev react-native@<< parameters.react-native-version >> - run: name: Run Jest command: yarn test test-ios: parameters: react-native-version: type: string xcode-version: type: string install-yarn: type: boolean default: true legacy-pods-install: type: boolean description: Install pods via CocoaPods (deprecated) rather than React Native CLI default: false macos: xcode: << parameters.xcode-version >> environment: HOMEBREW_NO_AUTO_UPDATE: 1 XCODE_VERSION: << parameters.xcode-version >> NODE_OPTIONS: '--openssl-legacy-provider' working_directory: ~/react-native-url-polyfill/platforms/react-native/<< parameters.react-native-version >> steps: - attach-workspace - restore-cache-detox-app - install-node: install-yarn: << parameters.install-yarn >> - install-yarn-dependencies - install-detox - when: condition: <> steps: - run: name: Install Pods command: cd ios && pod install --repo-update - unless: condition: <> steps: - run: name: Install Pods command: yarn ios --only-pods - run: name: Run Detox on iOS command: yarn e2e:ios - save-cache-detox-app test-android: parameters: react-native-version: type: string executor: name: android/android-machine resource-class: large tag: 2023.08.1 working_directory: ~/react-native-url-polyfill/platforms/react-native/<< parameters.react-native-version >> steps: - attach-workspace - install-node - install-yarn-dependencies - run: name: List available SDKs command: sdkmanager --list - android/create-avd: avd-name: TestingAVD install: true system-image: system-images;android-34;default;x86_64 - android/start-emulator: avd-name: TestingAVD no-window: true post-emulator-launch-assemble-command: '' restore-gradle-cache-prefix: v1a - run: name: Run Detox command: yarn e2e:android - android/save-gradle-cache: cache-prefix: v1a test-hermes-android: parameters: react-native-version: type: string executor: android working_directory: ~/react-native-url-polyfill/platforms/react-native/<< parameters.react-native-version >> steps: - attach-workspace - run: name: Enable Hermes command: sed -i "s/enableHermes:\sfalse/enableHermes:\ true/g" android/app/build.gradle - restore-android-build-cache - install-node - install-yarn-dependencies - run: name: Build APK command: cd android && ./gradlew assembleRelease - save-android-build-cache workflows: tests: jobs: - checkout - lint: requires: - checkout - type-check: requires: - checkout - test-js: requires: - checkout - test-ios: name: test-ios-0.72 react-native-version: '0.72' xcode-version: 15.4.0 legacy-pods-install: true requires: - lint - test-js - test-ios: name: test-ios-0.78 react-native-version: '0.78' xcode-version: 16.2.0 legacy-pods-install: true requires: - lint - test-js - test-ios: name: test-ios-0.81 react-native-version: '0.81' xcode-version: 16.4.0 requires: - lint - test-js - test-android: matrix: parameters: react-native-version: ['0.68', '0.72', '0.78'] requires: - lint - test-js - test-hermes-android: matrix: parameters: react-native-version: ['0.68'] requires: - test-android-<< matrix.react-native-version >>