Skip to content

Commit 1e42ba7

Browse files
committed
run detox with screenshots
1 parent 32bfc67 commit 1e42ba7

File tree

3 files changed

+68
-26
lines changed

3 files changed

+68
-26
lines changed

.github/workflows/callable-e2e-test-detox.yml

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ on:
1717
jobs:
1818
e2e-test:
1919
name: E2E-Detox ${{ inputs.test_name }}
20-
runs-on: macos-latest
20+
runs-on: macos-latest-large
2121
timeout-minutes: ${{ inputs.timeout_minutes }}
2222

2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
25+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2626
with:
2727
path: amplify-js
2828
- name: Setup node and build the repository
2929
uses: ./amplify-js/.github/actions/node-and-build
30+
- name: Set Xcode version
31+
run: |
32+
sudo xcode-select -s /Applications/Xcode_16.4.app
3033
- name: Setup samples staging repository
3134
uses: ./amplify-js/.github/actions/setup-samples-staging
3235
with:
@@ -44,30 +47,9 @@ jobs:
4447
cd ios && pod install
4548
working-directory: ${{ inputs.working_directory }}
4649
shell: bash
47-
- name: Setup iOS Simulator
50+
- name: Start iOS simulator (background)
4851
run: |
49-
# Check if iPhone 15 device exists
50-
if ! xcrun simctl list devices | grep -q "iPhone 15"; then
51-
echo "iPhone 15 device not found, creating one..."
52-
53-
# Get the latest available iOS runtime
54-
RUNTIME=$(xcrun simctl list runtimes | grep iOS | tail -1 | awk '{print $NF}')
55-
echo "Using runtime: $RUNTIME"
56-
57-
# Create iPhone 15 device with available runtime
58-
xcrun simctl create "iPhone 15" "com.apple.CoreSimulator.SimDeviceType.iPhone-15" "$RUNTIME" || \
59-
xcrun simctl create "iPhone 15" "iPhone 15" "$RUNTIME" || \
60-
echo "Could not create iPhone 15, will use available device"
61-
fi
62-
63-
# Boot iPhone 15 if it exists, otherwise use first available iPhone
64-
if xcrun simctl list devices | grep -q "iPhone 15"; then
65-
xcrun simctl boot "iPhone 15" &
66-
else
67-
DEVICE=$(xcrun simctl list devices available | grep "iPhone" | head -1 | sed 's/.*\(iPhone[^(]*\).*/\1/' | xargs)
68-
echo "Using fallback device: $DEVICE"
69-
xcrun simctl boot "$DEVICE" &
70-
fi
52+
xcrun simctl boot "iPhone 16" &
7153
shell: bash
7254
- name: Start Metro Packager (background)
7355
run: |
@@ -96,3 +78,11 @@ jobs:
9678
$GITHUB_WORKSPACE/amplify-js/scripts/retry-yarn-script.sh -s 'detox test -c ios.sim.debug -u' -n 3
9779
working-directory: ${{ inputs.working_directory }}
9880
shell: bash
81+
- name: Upload screenshots on failure
82+
if: failure()
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: detox-screenshots-${{ inputs.test_name }}
86+
path: ${{ inputs.working_directory }}/screenshots/
87+
retention-days: 7
88+
if-no-files-found: ignore

.github/workflows/detox-tests.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Detox E2E Tests
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- ci/v5-stable-node-20
8+
9+
permissions: read-all
10+
11+
jobs:
12+
prebuild-macos:
13+
uses: ./.github/workflows/callable-prebuild-amplify-js.yml
14+
with:
15+
runs_on: macos-latest
16+
17+
prebuild-samples-staging:
18+
secrets: inherit
19+
uses: ./.github/workflows/callable-prebuild-samples-staging.yml
20+
21+
detox-prep:
22+
needs:
23+
- prebuild-macos
24+
- prebuild-samples-staging
25+
name: Load Detox test configurations
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 https://github.com/actions/checkout/commit/24cb9080177205b6e8c946b17badbe402adc938f
30+
with:
31+
path: amplify-js
32+
- name: Read detox config file
33+
id: load_config
34+
run: |
35+
echo "DETOX_INTEG_CONFIG=$(cat .github/integ-config/detox-integ-all.yml | yq -o=json | jq -c .)" >> $GITHUB_OUTPUT
36+
working-directory: ./amplify-js
37+
outputs:
38+
detox-integ-config: ${{ steps.load_config.outputs.DETOX_INTEG_CONFIG }}
39+
40+
detox-e2e-test-runner:
41+
name: Detox E2E - ${{ matrix.integ-config.test_name }}
42+
needs: detox-prep
43+
strategy:
44+
matrix:
45+
integ-config: ${{ fromJson(needs.detox-prep.outputs.detox-integ-config) }}
46+
fail-fast: false
47+
secrets: inherit
48+
uses: ./.github/workflows/callable-e2e-test-detox.yml
49+
with:
50+
test_name: ${{ matrix.integ-config.test_name }}
51+
working_directory: ${{ matrix.integ-config.working_directory }}
52+
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 45 }}

.github/workflows/push-integ-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ concurrency:
88
on:
99
push:
1010
branches:
11-
- ci/v5-stable-node-20
11+
- feat/example-integ-test-branch/main
1212

1313
jobs:
1414
e2e:

0 commit comments

Comments
 (0)