|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ci-${{ github.event.pull_request.number || github.ref }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + check: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + timeout-minutes: 15 |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Setup |
| 24 | + uses: ./.github/actions/setup |
| 25 | + with: |
| 26 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + - name: Lint files |
| 29 | + run: yarn lint |
| 30 | + |
| 31 | + - name: Typecheck files |
| 32 | + run: yarn tsc |
| 33 | + |
| 34 | + - name: Unit tests |
| 35 | + run: yarn test:unit |
| 36 | + |
| 37 | + - name: Build the package |
| 38 | + run: yarn build |
| 39 | + |
| 40 | + # The generated Nitro sources are committed: fail when they are stale. |
| 41 | + - name: Check Nitro specs |
| 42 | + run: yarn specs && git diff --exit-code -- nitrogen |
| 43 | + |
| 44 | + # Validate the semantic-release config without publishing, so a broken |
| 45 | + # .releaserc is caught on PRs rather than at release time. |
| 46 | + - name: Release dry run |
| 47 | + run: yarn semantic-release --dry-run |
| 48 | + env: |
| 49 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + YARN_NPM_AUTH_TOKEN: '' |
| 51 | + NPM_TOKEN: '' |
| 52 | + |
| 53 | + # Builds the example, runs it on a simulator and runs the e2e tests against |
| 54 | + # it (src/__tests__): exports checked with ffprobe and |
| 55 | + # ffmpeg on the host. |
| 56 | + ios: |
| 57 | + runs-on: macos-latest |
| 58 | + timeout-minutes: 60 |
| 59 | + env: |
| 60 | + METRO_PORT: 8081 |
| 61 | + E2E_PORT: 4242 |
| 62 | + IOS_SIMULATOR: webcodecs-ci |
| 63 | + steps: |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Setup |
| 68 | + uses: ./.github/actions/setup |
| 69 | + with: |
| 70 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + |
| 72 | + - name: Install ffmpeg |
| 73 | + run: command -v ffprobe >/dev/null || brew install ffmpeg |
| 74 | + |
| 75 | + # xcpretty is a gem, not part of the macOS runner image. |
| 76 | + - name: Install xcpretty |
| 77 | + run: command -v xcpretty >/dev/null || sudo gem install xcpretty --no-document |
| 78 | + |
| 79 | + - name: Install CocoaPods |
| 80 | + working-directory: example/ios |
| 81 | + run: pod install |
| 82 | + |
| 83 | + - name: Start Package Manager |
| 84 | + working-directory: example |
| 85 | + run: CI=true yarn start --port $METRO_PORT --reset-cache & |
| 86 | + |
| 87 | + - name: Build example for iOS |
| 88 | + working-directory: example/ios |
| 89 | + run: | |
| 90 | + set -o pipefail && xcodebuild \ |
| 91 | + -workspace Example.xcworkspace \ |
| 92 | + -scheme Example \ |
| 93 | + -configuration Debug \ |
| 94 | + -sdk iphonesimulator \ |
| 95 | + -destination "generic/platform=iOS Simulator" \ |
| 96 | + -derivedDataPath build \ |
| 97 | + COMPILER_INDEX_STORE_ENABLE=NO \ |
| 98 | + build | xcpretty |
| 99 | +
|
| 100 | + - name: Prepare iOS simulator |
| 101 | + run: | |
| 102 | + RUNTIME=$(xcrun simctl list runtimes available --json | jq -r ' |
| 103 | + .runtimes | map(select(.platform == "iOS")) |
| 104 | + | sort_by(.version | split(".") | map(tonumber)) | last | .identifier') |
| 105 | + DEVICE_TYPE=$(xcrun simctl list devicetypes --json | jq -r ' |
| 106 | + .devicetypes | map(select(.name | test("^iPhone [0-9]+ Pro$"))) |
| 107 | + | sort_by(.name | capture("^iPhone (?<n>[0-9]+) Pro$").n | tonumber) | last | .identifier') |
| 108 | + UDID=$(xcrun simctl create "$IOS_SIMULATOR" "$DEVICE_TYPE" "$RUNTIME") |
| 109 | + echo "IOS_SIMULATOR_UDID=$UDID" >> $GITHUB_ENV |
| 110 | + echo "SIMULATOR_UDID=$UDID" >> $GITHUB_ENV |
| 111 | + xcrun simctl boot "$UDID" |
| 112 | + xcrun simctl bootstatus "$UDID" -b |
| 113 | +
|
| 114 | + - name: Install and launch app on Simulator |
| 115 | + run: | |
| 116 | + xcrun simctl install "$IOS_SIMULATOR_UDID" example/ios/build/Build/Products/Debug-iphonesimulator/ReactTestApp.app |
| 117 | + xcrun simctl launch "$IOS_SIMULATOR_UDID" com.reactnativewebcodecs.example \ |
| 118 | + -RCT_jsLocation "localhost:$METRO_PORT" |
| 119 | +
|
| 120 | + - name: Run e2e tests |
| 121 | + run: yarn test |
0 commit comments