|
| 1 | +name: CocoaPods |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + paths: |
| 7 | + - '.github/workflows/cocoapods2.yml' |
| 8 | + pull_request: |
| 9 | + branches: [ main ] |
| 10 | + paths: |
| 11 | + - '.github/workflows/cocoapods2.yml' |
| 12 | + |
| 13 | +jobs: |
| 14 | + pod-lib-lint-subspecs: |
| 15 | + # If we run one `pod lib lint` it takes a really long time, and activity |
| 16 | + # monitor show it has not really using the machines resources. So fan |
| 17 | + # this out into a few "chunks" and also use run things within the |
| 18 | + # chunk in parallel to speed things up. We use "3" jobs in parallel |
| 19 | + # based on the cpu count per vm: |
| 20 | + # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories |
| 21 | + name: CocoaPods lib lint SubSpecs |
| 22 | + runs-on: macos-15 |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + pod_configuration: ["Debug", "Release"] |
| 27 | + # Number of chunks and then a run per chunk |
| 28 | + num_chunks: ["3"] |
| 29 | + chunk: ["1", "2", "3"] |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - name: "macOS" |
| 33 | + run: | |
| 34 | + set -eu |
| 35 | + |
| 36 | + # Calculate this chunk of subspecs |
| 37 | + SUBSPECS=$(sed -n -e "s/[^']*subspec '\([^']*\).*/\1/p" GoogleAPIClientForREST.podspec) |
| 38 | + NUM_SUBSPECS=$(echo "${SUBSPECS}" | wc -l) |
| 39 | + LINES_PER_CHUNK=$((NUM_SUBSPECS / ${{ matrix.num_chunks }})) |
| 40 | + START_LINE=$(( (${{ matrix.chunk }} - 1) * LINES_PER_CHUNK + 1 )) |
| 41 | + END_LINE=$(( ${{ matrix.chunk }} * LINES_PER_CHUNK )) |
| 42 | +
|
| 43 | + if [ "${{ matrix.chunk }}" -eq "${{ matrix.num_chunks }}" ]; then |
| 44 | + SED_PATTERN="${START_LINE},${NUM_SUBSPECS}p" |
| 45 | + else |
| 46 | + SED_PATTERN="${START_LINE},${END_LINE}p" |
| 47 | + fi |
| 48 | +
|
| 49 | + # `pod` only supports one subspec at a time. |
| 50 | + echo "${SUBSPECS}" | sed -n "${SED_PATTERN}" \ |
| 51 | + xargs -I % -P 3 \ |
| 52 | + pod lib lint \ |
| 53 | + --subspec=% \ |
| 54 | + --configuration=${{ matrix.pod_configuration }} \ |
| 55 | + --platforms=macos \ |
| 56 | + --skip-tests \ |
| 57 | + GoogleAPIClientForREST.podspec |
0 commit comments