Skip to content

Commit a75fa8b

Browse files
author
Jake Perkins
committed
e2e-env-action
1 parent 86272c8 commit a75fa8b

1 file changed

Lines changed: 108 additions & 0 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: 'Setup E2E Test Environment'
2+
description: 'Sets up the environment for running E2E tests'
3+
inputs:
4+
platform:
5+
description: 'Platform (ios or android)'
6+
required: true
7+
node-version:
8+
description: 'Node.js version'
9+
required: false
10+
default: '20.18.0'
11+
setup-simulator:
12+
description: 'Whether to setup simulator/emulator'
13+
required: false
14+
default: 'false'
15+
# See https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md#installed-simulators
16+
ios-simulator-device:
17+
description: Name of iOS simulator device to boot (e.g., "iPhone 15")
18+
required: false
19+
default: "iPhone 15"
20+
cache-prefix:
21+
description: 'Cache key prefix'
22+
required: false
23+
default: 'e2e'
24+
ruby-version:
25+
description: Ruby version to use (only for iOS)
26+
required: false
27+
default: "3.1"
28+
xcode-version:
29+
description: Xcode version to select (e.g., 16.0)
30+
required: false
31+
default: "15.0"
32+
33+
34+
runs:
35+
using: "composite"
36+
steps:
37+
38+
## Common Setup ##
39+
- run: echo "Setup E2E Environment started"
40+
shell: bash
41+
42+
- name: Install Yarn
43+
run: corepack enable && corepack prepare yarn@stable --activate
44+
shell: bash
45+
46+
- name: Install Detox CLI
47+
run: yarn global add detox-cli
48+
shell: bash
49+
50+
- name: Install Foundry
51+
run: curl -L https://foundry.paradigm.xyz | bash && ~/.foundry/bin/foundryup
52+
shell: bash
53+
54+
## IOS Setup ##
55+
- name: Setup Ruby
56+
if: ${{ inputs.platform == 'ios' }}
57+
uses: ruby/setup-ruby@v1
58+
with:
59+
ruby-version: ${{ inputs.ruby-version }}
60+
61+
- name: Select Xcode version
62+
if: ${{ inputs.platform == 'ios' }}
63+
run: sudo xcode-select -s /Applications/Xcode_${{ inputs.xcode-version }}.app
64+
shell: bash
65+
66+
- name: Install CocoaPods
67+
if: ${{ inputs.platform == 'ios' }}
68+
run: sudo gem install cocoapods
69+
shell: bash
70+
71+
- name: Install applesimutils
72+
if: ${{ inputs.platform == 'ios' }}
73+
run: brew tap wix/brew && brew install applesimutils
74+
shell: bash
75+
76+
- name: Boot iOS Simulator (if not already booted)
77+
if: ${{ inputs.platform == 'ios' && inputs.setup-simulator == 'true' }}
78+
run: |
79+
echo "Looking for simulator named: ${{ inputs.ios-simulator-device }}"
80+
81+
SIMULATOR_LINE=$(xcrun simctl list devices | grep -m1 "${{ inputs.ios-simulator-device }}")
82+
if [ -z "$SIMULATOR_LINE" ]; then
83+
echo "No simulator found with name '${{ inputs.ios-simulator-device }}'"
84+
exit 1
85+
fi
86+
87+
SIMULATOR_ID=$(echo "$SIMULATOR_LINE" | awk -F '[()]' '{print $2}')
88+
SIMULATOR_STATE=$(echo "$SIMULATOR_LINE" | awk -F '[()]' '{print $NF}')
89+
90+
echo "Simulator ID: $SIMULATOR_ID"
91+
echo "Simulator State: $SIMULATOR_STATE"
92+
93+
if [ "$SIMULATOR_STATE" = "Booted" ]; then
94+
echo "Simulator is already booted. Skipping boot step."
95+
else
96+
echo "Booting simulator..."
97+
xcrun simctl boot "$SIMULATOR_ID"
98+
fi
99+
shell: bash
100+
101+
102+
103+
104+
105+
106+
107+
108+

0 commit comments

Comments
 (0)