Skip to content

Commit

Permalink
stabilize iOS ci (#1613)
Browse files Browse the repository at this point in the history
* don't update root package.json

It should follow generate-blueprint versions.

* retry jest tests

* run iOS test on main

* adjust detox config

* Update .detoxrc.json.ejs

* Update setup.js.ejs

* Update package.json.ejs

* Update .detoxrc.json.ejs

* increase wait

* Update utils.js.ejs

* Update utils.js.ejs

* Update utils.js.ejs

* Update utils.js.ejs

* Update run-detox-tests.sh

* Update run-detox-tests.sh

* Update utils.js.ejs

* Update ios.yml

* Revert "Update ios.yml"

This reverts commit 172edae.

* Revert "Update utils.js.ejs"

This reverts commit 94193cf.

* Revert "Revert "Update ios.yml""

This reverts commit b4f5915.

* Revert "Update run-detox-tests.sh"

This reverts commit 81cd790.
  • Loading branch information
mshima authored Feb 22, 2024
1 parent 45d0350 commit d45e05a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
# Check for npm updates on Wednesday due to Expo updates
day: 'wednesday'
open-pull-requests-limit: 30
- package-ecosystem: 'npm'
directory: '/generators/app/templates/'
schedule:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ on:
default: 'false'
push:
branches:
- '*'
- '!dependabot/**'
- 'main'
pull_request:
defaults:
run:
Expand Down Expand Up @@ -113,7 +112,7 @@ jobs:
with:
name: expo-app-${{ matrix.app_type }}-${{ matrix.jhipster_version }}
path: |
${{ runner.workspace }}/${{ matrix.app_type }}/**/*
${{ runner.workspace }}/${{ matrix.app_type }}/
!${{ runner.workspace }}/${{ matrix.app_type }}/node_modules
!${{ runner.workspace }}/${{ matrix.app_type }}/e2e/Exponent.app
ios-result:
Expand Down
3 changes: 3 additions & 0 deletions generators/app/templates/.detoxrc.json.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"logger": {
"level": "info"
},
"configurations": {
"ios.sim.release": {
"device": "simulator",
Expand Down
18 changes: 11 additions & 7 deletions generators/app/templates/e2e/utils.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const username = process.env.E2E_USERNAME || 'user';
const password = process.env.E2E_PASSWORD || 'user';
const expoPublishedUrl = process.env.E2E_EXPO_URL || 'exp://localhost:8081';

const DEFAULT_VISIBLE_TIMEOUT = 10000;
const DEFAULT_RELOAD_AWAIT = 3000;

const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const waitThenTapButton = async (buttonId, ms = 1000) => {
Expand All @@ -11,6 +14,7 @@ const waitThenTapButton = async (buttonId, ms = 1000) => {
};

const openAndTapDrawerMenuItemByLabel = async (label) => {
await waitForElementToBeVisibleById('drawerButtonWrapper', DEFAULT_VISIBLE_TIMEOUT * 2);
await wait(2000);
// matching the drawer button is flaky, so open it with a swipe from the left
await element(by.id('drawerButtonWrapper')).atIndex(0).swipe('right', 'fast', 0.7, 0.01);
Expand Down Expand Up @@ -97,28 +101,28 @@ const tapFirstElementByLabel = async (label) => {
}
};

const waitForElementToBeVisibleByLabel = async (elementLabel, timeout = 5000) => {
const waitForElementToBeVisibleByLabel = async (elementLabel, timeout = DEFAULT_VISIBLE_TIMEOUT) => {
await waitFor(element(by.label(elementLabel))).toBeVisible().withTimeout(timeout);
}

const waitForElementToBeVisibleById = async (elementId, timeout = 5000) => {
const waitForElementToBeVisibleById = async (elementId, timeout = DEFAULT_VISIBLE_TIMEOUT) => {
await waitFor(element(by.id(elementId))).toBeVisible().withTimeout(timeout);
}

const closeDeveloperMenu = async () => {
await wait(3000);
await wait(DEFAULT_RELOAD_AWAIT);

await waitFor(element(by.text('Continue')))
.toBeVisible()
.withTimeout(3000);
.withTimeout(DEFAULT_VISIBLE_TIMEOUT);
await element(by.text('Continue')).tap();

await waitFor(element(by.text('Reload')))
.toBeVisible()
.withTimeout(3000);
.withTimeout(DEFAULT_VISIBLE_TIMEOUT);
await element(by.text('Reload')).tap();

await wait(3000);
await wait(DEFAULT_RELOAD_AWAIT);
};

const reloadApp = async (bailOnFailure) => {
Expand All @@ -138,7 +142,7 @@ const reloadApp = async (bailOnFailure) => {
await device.launchApp({ url: expoPublishedUrl, newInstance: true, launchArgs: { detoxEnableSynchronization: false } });
await closeDeveloperMenu();
} catch (e) {
console.warn('Reloading app failed, retrying once');
console.warn('Reloading app failed, retrying');
console.warn(e);
}
};
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<%_ } _%>
<%_ if (context.detox) { _%>
"start:e2e": "expo start --no-dev --minify",
"test:e2e": "./e2e/scripts/setup.sh && detox test --configuration ios.sim.release --retries 3 --loglevel trace --debug-synchronization 500",
"test:e2e": "./e2e/scripts/setup.sh && detox test --configuration ios.sim.release --retries 3",
<%_ } _%>
"postinstall": "patch-package",
"prettier": "prettier --write \"{,.,**/,.jhipster/**/}*.{md,json,yml,js,ts,tsx}\"",
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/run-detox-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fi

# run the detox tests
if [ "$PLATFORM" = "ios" ]; then
npm run test:e2e -- --record-videos $DETOX_RECORD_VIDEO --take-screenshots $DETOX_SCREENSHOTS
npm run test:e2e -- --record-videos $DETOX_RECORD_VIDEO
else
bash ${GITHUB_WORKSPACE}/${SCRIPT_DIR}/start-android-emulator.sh
detox test --configuration android.emu.release
Expand Down

0 comments on commit d45e05a

Please sign in to comment.