1name: Updates e2e 2 3on: 4 workflow_dispatch: {} 5 pull_request: 6 paths: 7 - .github/workflows/updates-e2e.yml 8 - packages/expo-json-utils/** 9 - packages/expo-manifests/** 10 - packages/expo-modules-core/** 11 - packages/expo-structured-headers/** 12 - packages/expo-updates-interface/** 13 - packages/expo-updates/** 14 - packages/expo/android/** 15 - packages/expo/ios/** 16 push: 17 branches: [main, 'sdk-*'] 18 paths: 19 - .github/workflows/updates-e2e.yml 20 - packages/expo-json-utils/** 21 - packages/expo-manifests/** 22 - packages/expo-modules-core/** 23 - packages/expo-structured-headers/** 24 - packages/expo-updates-interface/** 25 - packages/expo-updates/** 26 - packages/expo/android/** 27 - packages/expo/ios/** 28 29concurrency: 30 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} 31 cancel-in-progress: true 32 33jobs: 34 android: 35 runs-on: ubuntu-20.04 36 env: 37 UPDATES_HOST: 10.0.2.2 # special IP that Android emulators map to host machine's localhost 38 UPDATES_PORT: 4747 39 strategy: 40 matrix: 41 api-level: [ 29 ] 42 steps: 43 - name: Checkout 44 uses: actions/checkout@v3 45 - name: ⬢ Setup Node 46 uses: actions/setup-node@v3 47 with: 48 node-version: '14.17' 49 - name: Use JDK 11 50 uses: actions/setup-java@v3 51 with: 52 distribution: 'temurin' 53 java-version: '11' 54 - name: ➕ Add `bin` to GITHUB_PATH 55 run: echo "$(yarn global bin)" >> $GITHUB_PATH 56 - name: ♻️ Restore caches 57 uses: ./.github/actions/expo-caches 58 id: expo-caches 59 with: 60 yarn-workspace: 'true' 61 avd: 'true' 62 avd-api: ${{ matrix.api-level }} 63 - name: Yarn install 64 if: steps.expo-caches.outputs.yarn-workspace-hit != 'true' 65 run: yarn install --frozen-lockfile 66 - name: Install Expo CLI 67 run: yarn global add expo-cli 68 - name: Init new expo app 69 working-directory: ../ 70 run: expo-cli init updates-e2e --yes 71 - name: Add yarn resolutions for local dependencies 72 working-directory: ../updates-e2e 73 run: | 74 # A jq filter to add a "resolutions" field 75 JQ_FILTER=$(cat << EOF 76 . + { 77 resolutions: { 78 "expo-application": "file:../expo/packages/expo-application", 79 "expo-constants": "file:../expo/packages/expo-constants", 80 "expo-eas-client": "file:../expo/packages/expo-eas-client", 81 "expo-error-recovery": "file:../expo/packages/expo-error-recovery", 82 "expo-file-system": "file:../expo/packages/expo-file-system", 83 "expo-font": "file:../expo/packages/expo-font", 84 "expo-json-utils": "file:../expo/packages/expo-json-utils", 85 "expo-keep-awake": "file:../expo/packages/expo-keep-awake", 86 "expo-manifests": "file:../expo/packages/expo-manifests", 87 "expo-modules-core": "file:../expo/packages/expo-modules-core", 88 "expo-structured-headers": "file:../expo/packages/expo-structured-headers", 89 "expo-updates-interface": "file:../expo/packages/expo-updates-interface" 90 } 91 } 92 EOF 93 ) 94 jq "$JQ_FILTER" < package.json > new-package.json 95 mv new-package.json package.json 96 - name: Add local expo packages 97 working-directory: ../updates-e2e 98 run: yarn add file:../expo/packages/expo-updates file:../expo/packages/expo file:../expo/packages/expo-splash-screen file:../expo/packages/expo-status-bar 99 - name: Setup app.config.json 100 working-directory: ../updates-e2e 101 run: echo "{\"name\":\"updates-e2e\",\"runtimeVersion\":\"1.0.0\",\"plugins\":[\"expo-updates\"],\"android\":{\"package\":\"dev.expo.updatese2e\"},\"ios\":{\"bundleIdentifier\":\"dev.expo.updatese2e\"},\"updates\":{\"url\":\"http://$UPDATES_HOST:$UPDATES_PORT/update\"}}" > app.config.json 102 - name: Pack latest bare-minimum template as tarball for expo prebuild 103 working-directory: templates/expo-template-bare-minimum 104 run: echo "$PWD" && npm pack --pack-destination ../../../updates-e2e/ 105 - name: Prebuild 106 working-directory: ../updates-e2e 107 run: expo-cli prebuild --template expo-template-bare-minimum-*.tgz 108 - name: Copy App.js from test fixtures 109 working-directory: ../updates-e2e 110 run: cp ../expo/packages/expo-updates/e2e/__tests__/fixtures/App.js . 111 - name: Set host and port in App.js 112 working-directory: ../updates-e2e 113 run: sed -i -e "s/UPDATES_HOST/$UPDATES_HOST/" ./App.js && sed -i -e "s/UPDATES_PORT/$UPDATES_PORT/" ./App.js 114 - name: Assemble release APK 115 working-directory: ../updates-e2e/android 116 run: ./gradlew assembleRelease 117 - name: Copy APK to working directory 118 run: cp -R ../updates-e2e/android/app/build/outputs/apk artifact 119 - name: Upload test APK artifact 120 uses: actions/upload-artifact@v3 121 with: 122 name: updates-e2e-android-apk 123 path: artifact 124 - name: Get test APK path 125 id: test-apk-path 126 working-directory: ../updates-e2e/android/app/build/outputs/apk/release 127 run: echo "::set-output name=dir::$(pwd)" 128 - name: Export update for test server to host 129 working-directory: ../updates-e2e 130 run: expo export --public-url https://u.expo.dev/dummy-url --platform android 131 - name: Get test update dist path 132 id: test-update-dist-path 133 working-directory: ../updates-e2e/dist 134 run: echo "::set-output name=dir::$(pwd)" 135 - name: Run tests 136 env: 137 TEST_APK_PATH: '${{ steps.test-apk-path.outputs.dir }}/app-release.apk' 138 TEST_UPDATE_DIST_PATH: '${{ steps.test-update-dist-path.outputs.dir }}' 139 timeout-minutes: 30 140 uses: reactivecircus/android-emulator-runner@v2 141 with: 142 api-level: ${{ matrix.api-level }} 143 avd-name: avd-${{ matrix.api-level }} 144 arch: x86_64 145 force-avd-creation: false 146 script: yarn test --config e2e/jest.config.android.js 147 working-directory: packages/expo-updates 148 149 ios: 150 runs-on: macos-11 151 timeout-minutes: 60 152 env: 153 UPDATES_HOST: localhost 154 UPDATES_PORT: 4747 155 steps: 156 - name: Checkout 157 uses: actions/checkout@v3 158 - name: Switch to Xcode 13.0 159 run: sudo xcode-select --switch /Applications/Xcode_13.0.app 160 - name: ➕ Add `bin` to GITHUB_PATH 161 run: echo "$(yarn global bin)" >> $GITHUB_PATH 162 - name: ♻️ Restore caches 163 uses: ./.github/actions/expo-caches 164 id: expo-caches 165 with: 166 yarn-workspace: 'true' 167 - name: Yarn install 168 if: steps.expo-caches.outputs.yarn-workspace-hit != 'true' 169 run: yarn install --frozen-lockfile 170 - name: Install Expo CLI 171 run: yarn global add expo-cli 172 - name: Init new expo app 173 working-directory: ../ 174 run: expo-cli init updates-e2e --yes 175 - name: Add yarn resolutions for local dependencies 176 working-directory: ../updates-e2e 177 run: | 178 # A jq filter to add a "resolutions" field 179 JQ_FILTER=$(cat << EOF 180 . + { 181 resolutions: { 182 "expo-application": "file:../expo/packages/expo-application", 183 "expo-constants": "file:../expo/packages/expo-constants", 184 "expo-eas-client": "file:../expo/packages/expo-eas-client", 185 "expo-error-recovery": "file:../expo/packages/expo-error-recovery", 186 "expo-file-system": "file:../expo/packages/expo-file-system", 187 "expo-font": "file:../expo/packages/expo-font", 188 "expo-json-utils": "file:../expo/packages/expo-json-utils", 189 "expo-keep-awake": "file:../expo/packages/expo-keep-awake", 190 "expo-manifests": "file:../expo/packages/expo-manifests", 191 "expo-modules-core": "file:../expo/packages/expo-modules-core", 192 "expo-structured-headers": "file:../expo/packages/expo-structured-headers", 193 "expo-updates-interface": "file:../expo/packages/expo-updates-interface" 194 } 195 } 196 EOF 197 ) 198 jq "$JQ_FILTER" < package.json > new-package.json 199 mv new-package.json package.json 200 - name: Add local expo packages 201 working-directory: ../updates-e2e 202 run: yarn add file:../expo/packages/expo-updates file:../expo/packages/expo file:../expo/packages/expo-splash-screen file:../expo/packages/expo-status-bar 203 - name: Setup app.config.json 204 working-directory: ../updates-e2e 205 run: echo "{\"name\":\"updates-e2e\",\"runtimeVersion\":\"1.0.0\",\"plugins\":[\"expo-updates\"],\"android\":{\"package\":\"dev.expo.updatese2e\"},\"ios\":{\"bundleIdentifier\":\"dev.expo.updatese2e\"},\"updates\":{\"url\":\"http://$UPDATES_HOST:$UPDATES_PORT/update\"}}" > app.config.json 206 - name: Pack latest bare-minimum template as tarball for expo prebuild 207 working-directory: templates/expo-template-bare-minimum 208 run: npm pack --pack-destination ../../../updates-e2e/ 209 - name: Prebuild --no-install 210 working-directory: ../updates-e2e 211 run: expo-cli prebuild --template expo-template-bare-minimum-*.tgz --no-install && yarn 212 # TODO: not caching pods for now as we don't have a lockfile with which to use in the key 213 # and as this is a minimal project, time savings is not much anyway (~3.5 mins at most) 214 # - name: Restore updates-e2e/ios/Pods from cache 215 # uses: actions/cache@v2 216 # id: pods-cache 217 # with: 218 # path: '../updates-e2e/ios/Pods' 219 # key: ${{ runner.os }}-pods-updatese2e-${{ hashFiles('../updates-e2e/ios/Podfile.lock') }} 220 # # restore-keys: | 221 # # ${{ runner.os }}-pods-updatese2e- 222 - name: Install CocoaPods in `updates-e2e/ios` 223 run: pod install 224 working-directory: ../updates-e2e/ios 225 - name: Copy App.js from test fixtures 226 working-directory: ../updates-e2e 227 run: cp ../expo/packages/expo-updates/e2e/__tests__/fixtures/App.js . 228 - name: Set host and port in App.js 229 working-directory: ../updates-e2e 230 run: sed -i -e "s/UPDATES_HOST/$UPDATES_HOST/" ./App.js && sed -i -e "s/UPDATES_PORT/$UPDATES_PORT/" ./App.js 231 - name: Build release app 232 working-directory: ../updates-e2e/ios 233 run: xcodebuild -workspace updatese2e.xcworkspace -scheme updatese2e -configuration Release -destination "generic/platform=iOS Simulator" -derivedDataPath ./build build 234 - name: Copy app to working directory 235 run: cp -R ../updates-e2e/ios/build/Build/Products/Release-iphonesimulator/updatese2e.app artifact 236 - name: Upload test app artifact 237 uses: actions/upload-artifact@v3 238 with: 239 name: updates-e2e-ios-app 240 path: artifact 241 - name: Get test app path 242 id: test-app-path 243 working-directory: ../updates-e2e/ios/build/Build/Products/Release-iphonesimulator/ 244 run: echo "::set-output name=dir::$(pwd)" 245 - name: Export update for test server to host 246 working-directory: ../updates-e2e 247 run: expo export --public-url https://u.expo.dev/dummy-url --platform ios 248 - name: Get test update dist path 249 id: test-update-dist-path 250 working-directory: ../updates-e2e/dist 251 run: echo "::set-output name=dir::$(pwd)" 252 - name: Start simulator 253 run: | 254 xcrun simctl list devices -j \ 255 | jq -rc '[ .[] | .[] | .[] | select( .name | contains( "iPhone" ) ) | select( .isAvailable == true ) ] | last.udid ' \ 256 | xargs open -a Simulator --args -CurrentDeviceUDID 257 - name: Run tests 258 env: 259 TEST_APP_PATH: '${{ steps.test-app-path.outputs.dir }}/updatese2e.app' 260 TEST_UPDATE_DIST_PATH: '${{ steps.test-update-dist-path.outputs.dir }}' 261 timeout-minutes: 30 262 working-directory: packages/expo-updates 263 run: yarn test --config e2e/jest.config.ios.js 264