gpt4 book ai didi

react-native - 世博会 + 排毒 + CircleCI

转载 作者:行者123 更新时间:2023-12-03 09:27:34 26 4
gpt4 key购买 nike

在过去的两天里,我一直在寻找使用 Expo + Detox + CircleCI 的良好设置,以便应用程序可以在 CI 过程中构建。

在本地,我可以通过下载 Exponent.app 并放入 bin 并运行 expo start(在不同的终端中)来使 Expo + Detox 工作。然而,expo start 在 Circle CI 中是阻塞的,所以有没有一种有效的方法来实现这一点。

我查看了很多示例,但没有找到一个带有更新示例的明确回应,考虑到 Expo 的受欢迎程度,这是一种耻辱。

如果有人有您可以共享的示例 CircleCI 文件,那就太好了!或者确实有助于解释实现这一目标的流程。

我很欣赏这也是 Detox 和 CircleCI 的问题,但我想我会在这里添加它,因为许多人可能也想知道答案?

我目前的 Circle-CI 代码,我一直在反复尝试找到一个有效的解决方案......

# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2

defaults: &defaults
working_directory: ~/iynk-react-app

jobs:

test:
<<: *defaults

docker:
- image: circleci/node:10

steps:
- checkout

- run:
name: Update npm
command: 'sudo npm install -g npm@latest'

- run:
name: Install Firebase Tools
command: sudo npm install -g firebase-tools@latest

- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}

- run:
name: Install Dependencies
command: yarn install --frozen-lockfile

- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn

- run: yarn test

- run:
name: Install modules in functions
command: yarn --cwd ./functions --ignore-engines

e2e:
<<: *defaults

macos:
xcode: "10.2.1"

steps:
- run:
# Note: the [ character is necessary to uniquely identify the iPhone 8 simulator, as the phone + watch simulator is also present in the build image:
# Will show what looks like an error - Instruments Usage Error: Unknown device specified: "iPhone 8 (12.2) [") - but it launch
name: Pre-start simulator first to ensure that it is open
command: xcrun instruments -w "iPhone 8 (12.2) [" || true

- checkout

- restore_cache:
key: yarn-v1-{{ checksum "yarn.lock" }}-{{ arch }}

- restore_cache:
key: node-v1-{{ checksum "package.json" }}-{{ arch }}

- run: yarn install --ignore-engines

- save_cache:
key: yarn-v1-{{ checksum "yarn.lock" }}-{{ arch }}
paths:
- ~/.cache/yarn

- save_cache:
key: node-v1-{{ checksum "package.json" }}-{{ arch }}
paths:
- node_modules

- run:
name: Install applesimutils
command: |
brew tap wix/brew
brew install applesimutils

- run:
name: Install react-native, detox CLI and expo CLI
command: |
npm install -g react-native-cli
npm install -g detox-cli
npm install -g expo-cli

- run:
name: Prepare detox environment
command: |
detox clean-framework-cache &&
detox build-framework-cache

- run:
name: Download Exponent.app into bin
command: |
brew install wget
./scripts/setup.sh

# - run:
# name: Install the downloaded version of the expo iOS app on the Simulator
# command: |
# xcrun simctl install booted ./bin/Exponent.app

# - run:
# name: Login into Expo and publish to staging
# command: |
# npx expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD
# npx expo publish --non-interactive --max-workers 1 --release-channel staging

- run:
name: Run expo locally using (&) Run detox tests
# shell: /bin/sh
command: |
yarn test:e2e &
expo start -c

workflows:
version: 2

build_and_test:
jobs:
- test
- e2e

我的包裹:
"detox": "12.3.0",
"detox-expo-helpers": "^0.6.0",
"expo-detox-hook": "^1.0.10",

本地作品

我的本地设置运行并且测试通过。目前的流程是这样的:

确保本地环境已设置:
brew update
brew tap wix/brew
brew install --HEAD applesimutils
npm install -g detox-cli

运行安装脚本:
./setup.sh

然后开始世博。
expo start -c

启动您计划用于测试的模拟器(因此,如果您选择了 iPhone X,请启动 iPhone X 等)。您不需要运行 i从博览会虽然,只需打开模拟器程序。
open -a Simulator.app

最后,从不同的终端运行排毒测试:
yarn test:e2e

已知的问题
  • Detox + Expo + jest:打开应用超时 https://github.com/wix/Detox/issues/1422

  • 我不认为这是相关的,因为我可以让我的设置在本地运行......

    2019 年 7 月 2 日更新

    如果我在我的圈子 ci 中构建,我可以通过以下测试:
          - run:
    name: Login into Expo and publish to staging (could update with $CIRCLE_BRANCH)
    command: |
    npx expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD --non-interactive
    npx expo publish --non-interactive --max-workers 1 --release-channel testing

    然后从该发布 channel 加载 e2e/init.js 文件:
    beforeAll(async () => {
    await detox.init(config);

    // Run from the remote build if in CI
    if (__CI__) {
    const url = 'exp://exp.host/@alexpchin/iynk?release-channel=testing';
    await device.relaunchApp({ url, sourceApp: 'host.exp.exponent' });
    await expect(element(by.label('Got it'))).toBeVisible();
    await element(by.label('Got it')).tap();
    }
    });

    但是,如果我使用它,我不能使用来自 detox-expo-helpers(在 e2e/init.js 中)的 reloadApp:
    beforeEach(async () => {
    await adapter.beforeEach();
    // If not CI, use `reloadApp` from `detox-expo-helpers`
    if (!__CI__) {
    await reloadApp();
    }
    });

    这显然真的很慢,因为每次要测试 UI 时都必须创建一个新构建,而不是从分支代码运行...

    最佳答案

    仍然没有答案或更新,所以我会尽量提供我的。
    据我了解,您想要自动化的流程是 test on Simulator .所附链接中列出了步骤。

    即对于 iOS

    expo build:ios -t simulator
    expo build:status (or expo url:ipa)
    tar -xvzf your-app.tar.gz
    open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID `xcrun instruments -s | grep "iPhone 7 (12.2)" -m1 | cut -d "[" -f2 | cut -d "]" -f1`
    xcrun simctl install booted <app path>
    xcrun simctl launch booted <app identifier>

    关于react-native - 世博会 + 排毒 + CircleCI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56817500/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com