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 - templates/expo-template-bare-minimum/** 17 push: 18 branches: [main, 'sdk-*'] 19 paths: 20 - .github/workflows/updates-e2e.yml 21 - packages/expo-json-utils/** 22 - packages/expo-manifests/** 23 - packages/expo-modules-core/** 24 - packages/expo-structured-headers/** 25 - packages/expo-updates-interface/** 26 - packages/expo-updates/** 27 - packages/expo/android/** 28 - packages/expo/ios/** 29 - templates/expo-template-bare-minimum/** 30 31concurrency: 32 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} 33 cancel-in-progress: true 34 35jobs: 36 # (2022-05): we run both iOS and Android tests in a single job in order to avoid taking up 2 macOS 37 # runners each time this workflow runs 38 build: 39 runs-on: macos-11 40 timeout-minutes: 120 41 env: 42 UPDATES_PORT: 4747 43 strategy: 44 matrix: 45 api-level: [31] 46 steps: 47 - name: Checkout 48 uses: actions/checkout@v3 49 - name: ⬢ Setup Node 50 uses: actions/setup-node@v3 51 with: 52 node-version: '14.17' 53 - name: Switch to Xcode 13.2.1 54 run: sudo xcode-select --switch /Applications/Xcode_13.2.1.app 55 - name: Use JDK 11 56 uses: actions/setup-java@v3 57 with: 58 distribution: 'temurin' 59 java-version: '11' 60 - name: ➕ Add `bin` to GITHUB_PATH 61 run: echo "$(yarn global bin)" >> $GITHUB_PATH 62 - name: ♻️ Restore caches 63 uses: ./.github/actions/expo-caches 64 id: expo-caches 65 with: 66 yarn-workspace: 'true' 67 avd: 'true' 68 avd-api: ${{ matrix.api-level }} 69 - name: Yarn install 70 if: steps.expo-caches.outputs.yarn-workspace-hit != 'true' 71 run: yarn install --frozen-lockfile 72 - name: Build expo-updates CLI 73 working-directory: packages/expo-updates 74 run: yarn build:cli 75 - name: Install Expo CLI 76 run: yarn global add expo-cli 77 - name: Init new expo app 78 working-directory: ../ 79 run: expo-cli init updates-e2e --yes 80 - name: Add yarn resolutions for local dependencies 81 working-directory: ../updates-e2e 82 run: | 83 # A jq filter to add a "resolutions" field 84 JQ_FILTER=$(cat << EOF 85 . + { 86 resolutions: { 87 "expo-application": "file:../expo/packages/expo-application", 88 "expo-constants": "file:../expo/packages/expo-constants", 89 "expo-eas-client": "file:../expo/packages/expo-eas-client", 90 "expo-error-recovery": "file:../expo/packages/expo-error-recovery", 91 "expo-file-system": "file:../expo/packages/expo-file-system", 92 "expo-font": "file:../expo/packages/expo-font", 93 "expo-json-utils": "file:../expo/packages/expo-json-utils", 94 "expo-keep-awake": "file:../expo/packages/expo-keep-awake", 95 "expo-manifests": "file:../expo/packages/expo-manifests", 96 "expo-modules-core": "file:../expo/packages/expo-modules-core", 97 "expo-structured-headers": "file:../expo/packages/expo-structured-headers", 98 "expo-updates-interface": "file:../expo/packages/expo-updates-interface" 99 } 100 } 101 EOF 102 ) 103 jq "$JQ_FILTER" < package.json > new-package.json 104 mv new-package.json package.json 105 - name: Add local expo packages 106 working-directory: ../updates-e2e 107 run: yarn add file:../expo/packages/expo-updates file:../expo/packages/expo file:../expo/packages/expo-splash-screen file:../expo/packages/expo-status-bar 108 - name: Get local IP address 109 run: echo "UPDATES_HOST=$(ifconfig -l | xargs -n1 ipconfig getifaddr)" >> $GITHUB_ENV 110 - name: Setup app.config.json 111 working-directory: ../updates-e2e 112 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 113 - name: Generate code signing 114 working-directory: ../updates-e2e 115 run: yarn expo-updates codesigning:generate --key-output-directory keys --certificate-output-directory certs --certificate-validity-duration-years 1 --certificate-common-name "E2E Test App" 116 - name: Configure code signing 117 working-directory: ../updates-e2e 118 run: yarn expo-updates codesigning:configure --certificate-input-directory certs --key-input-directory keys 119 - name: Pack latest bare-minimum template as tarball for expo prebuild 120 working-directory: templates/expo-template-bare-minimum 121 run: echo "$PWD" && npm pack --pack-destination ../../../updates-e2e/ 122 - name: Prebuild 123 working-directory: ../updates-e2e 124 run: expo-cli prebuild --template expo-template-bare-minimum-*.tgz 125 - name: Copy App.js from test fixtures 126 working-directory: ../updates-e2e 127 run: cp ../expo/packages/expo-updates/e2e/__tests__/fixtures/App.js . 128 - name: Set host and port in App.js 129 working-directory: ../updates-e2e 130 run: sed -i -e "s/UPDATES_HOST/$UPDATES_HOST/" ./App.js && sed -i -e "s/UPDATES_PORT/$UPDATES_PORT/" ./App.js 131 - name: Build release app 132 working-directory: ../updates-e2e/ios 133 run: xcodebuild -workspace updatese2e.xcworkspace -scheme updatese2e -configuration Release -destination "generic/platform=iOS Simulator" -derivedDataPath ./build build 134 - name: Copy app to working directory 135 run: cp -R ../updates-e2e/ios/build/Build/Products/Release-iphonesimulator/updatese2e.app artifact 136 - name: Get test app path 137 id: test-app-path 138 working-directory: ../updates-e2e/ios/build/Build/Products/Release-iphonesimulator/ 139 run: echo "::set-output name=dir::$(pwd)" 140 - name: Assemble release APK 141 working-directory: ../updates-e2e/android 142 run: ./gradlew assembleRelease --stacktrace 143 - name: Copy APK to working directory 144 run: cp -R ../updates-e2e/android/app/build/outputs/apk artifact 145 - name: Get test APK path 146 id: test-apk-path 147 working-directory: ../updates-e2e/android/app/build/outputs/apk/release 148 run: echo "::set-output name=dir::$(pwd)" 149 - name: Upload test app artifacts 150 uses: actions/upload-artifact@v3 151 with: 152 name: updates-e2e-artifacts 153 path: artifact 154 - name: Export update for test server to host 155 working-directory: ../updates-e2e 156 run: expo export --public-url https://u.expo.dev/dummy-url 157 - name: Get test update dist path 158 id: test-update-dist-path 159 working-directory: ../updates-e2e/dist 160 run: echo "::set-output name=dir::$(pwd)" 161 - name: Get test code signing private key path 162 id: test-code-signing-private-key-path 163 working-directory: ../updates-e2e/keys 164 run: echo "::set-output name=dir::$(pwd)/private-key.pem" 165 - name: Start simulator 166 run: | 167 xcrun simctl list devices -j \ 168 | jq -rc '[ .[] | .[] | .[] | select( .name | contains( "iPhone" ) ) | select( .isAvailable == true ) ] | last.udid ' \ 169 | xargs open -a Simulator --args -CurrentDeviceUDID 170 - name: Run tests 171 env: 172 TEST_APP_PATH: '${{ steps.test-app-path.outputs.dir }}/updatese2e.app' 173 TEST_UPDATE_DIST_PATH: '${{ steps.test-update-dist-path.outputs.dir }}' 174 TEST_PRIVATE_KEY_PATH: '${{ steps.test-code-signing-private-key-path.outputs.dir }}' 175 timeout-minutes: 30 176 working-directory: packages/expo-updates 177 run: yarn test --config e2e/jest.config.ios.js 178 - name: Start emulator and run tests 179 env: 180 TEST_APK_PATH: '${{ steps.test-apk-path.outputs.dir }}/app-release.apk' 181 TEST_UPDATE_DIST_PATH: '${{ steps.test-update-dist-path.outputs.dir }}' 182 TEST_PRIVATE_KEY_PATH: '${{ steps.test-code-signing-private-key-path.outputs.dir }}' 183 timeout-minutes: 30 184 uses: reactivecircus/android-emulator-runner@v2 185 with: 186 api-level: ${{ matrix.api-level }} 187 avd-name: avd-${{ matrix.api-level }} 188 arch: x86_64 189 force-avd-creation: false 190 script: yarn test --config e2e/jest.config.android.js 191 working-directory: packages/expo-updates 192