|
| 1 | +name: 'Code Review' |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: ['main', 'master'] |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize] |
| 7 | + workflow_dispatch: {} |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Setup |
| 17 | + uses: ./.github/actions/setup |
| 18 | + |
| 19 | + - name: Lint files |
| 20 | + run: yarn lint |
| 21 | + |
| 22 | + - name: Typecheck files |
| 23 | + run: yarn typecheck |
| 24 | + |
| 25 | + test: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Setup |
| 32 | + uses: ./.github/actions/setup |
| 33 | + |
| 34 | + - name: Run unit tests |
| 35 | + run: yarn test --maxWorkers=2 --coverage |
| 36 | + |
| 37 | + build-library: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v3 |
| 42 | + |
| 43 | + - name: Setup |
| 44 | + uses: ./.github/actions/setup |
| 45 | + |
| 46 | + - name: Build package |
| 47 | + run: yarn prepack |
| 48 | + |
| 49 | + build-android: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + env: |
| 52 | + TURBO_CACHE_DIR: .turbo/android |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v3 |
| 56 | + |
| 57 | + - name: Setup |
| 58 | + uses: ./.github/actions/setup |
| 59 | + |
| 60 | + - name: Cache turborepo for Android |
| 61 | + uses: actions/cache@v3 |
| 62 | + with: |
| 63 | + path: ${{ env.TURBO_CACHE_DIR }} |
| 64 | + key: ${{ runner.os }}-turborepo-android-${{ hashFiles('**/yarn.lock') }} |
| 65 | + restore-keys: | |
| 66 | + ${{ runner.os }}-turborepo-android- |
| 67 | +
|
| 68 | + - name: Check turborepo cache for Android |
| 69 | + run: | |
| 70 | + TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") |
| 71 | +
|
| 72 | + if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then |
| 73 | + echo "turbo_cache_hit=1" >> $GITHUB_ENV |
| 74 | + fi |
| 75 | +
|
| 76 | + - name: Install JDK |
| 77 | + if: env.turbo_cache_hit != 1 |
| 78 | + uses: actions/setup-java@v3 |
| 79 | + with: |
| 80 | + distribution: 'zulu' |
| 81 | + java-version: '11' |
| 82 | + |
| 83 | + - name: Finalize Android SDK |
| 84 | + if: env.turbo_cache_hit != 1 |
| 85 | + run: | |
| 86 | + /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" |
| 87 | +
|
| 88 | + - name: Cache Gradle |
| 89 | + if: env.turbo_cache_hit != 1 |
| 90 | + uses: actions/cache@v3 |
| 91 | + with: |
| 92 | + path: | |
| 93 | + ~/.gradle/wrapper |
| 94 | + ~/.gradle/caches |
| 95 | + key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }} |
| 96 | + restore-keys: | |
| 97 | + ${{ runner.os }}-gradle- |
| 98 | +
|
| 99 | + - name: Build example for Android |
| 100 | + run: | |
| 101 | + yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" |
| 102 | +
|
| 103 | + build-ios: |
| 104 | + runs-on: macos-latest |
| 105 | + env: |
| 106 | + TURBO_CACHE_DIR: .turbo/ios |
| 107 | + steps: |
| 108 | + - name: Checkout |
| 109 | + uses: actions/checkout@v3 |
| 110 | + |
| 111 | + - name: Setup |
| 112 | + uses: ./.github/actions/setup |
| 113 | + |
| 114 | + - name: Cache turborepo for iOS |
| 115 | + uses: actions/cache@v3 |
| 116 | + with: |
| 117 | + path: ${{ env.TURBO_CACHE_DIR }} |
| 118 | + key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('**/yarn.lock') }} |
| 119 | + restore-keys: | |
| 120 | + ${{ runner.os }}-turborepo-ios- |
| 121 | +
|
| 122 | + - name: Check turborepo cache for iOS |
| 123 | + run: | |
| 124 | + TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status") |
| 125 | +
|
| 126 | + if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then |
| 127 | + echo "turbo_cache_hit=1" >> $GITHUB_ENV |
| 128 | + fi |
| 129 | +
|
| 130 | + - name: Cache cocoapods |
| 131 | + if: env.turbo_cache_hit != 1 |
| 132 | + id: cocoapods-cache |
| 133 | + uses: actions/cache@v3 |
| 134 | + with: |
| 135 | + path: | |
| 136 | + **/ios/Pods |
| 137 | + key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }} |
| 138 | + restore-keys: | |
| 139 | + ${{ runner.os }}-cocoapods- |
| 140 | +
|
| 141 | + - name: Install cocoapods |
| 142 | + if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' |
| 143 | + run: | |
| 144 | + yarn example pods |
| 145 | + env: |
| 146 | + NO_FLIPPER: 1 |
| 147 | + |
| 148 | + - name: Build example for iOS |
| 149 | + run: | |
| 150 | + yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" |
0 commit comments