From a7de18c7304a3cbe3b59e6ed82a11240ce95bf4c Mon Sep 17 00:00:00 2001 From: Daniel Dallos Date: Thu, 9 Oct 2025 23:59:45 +0200 Subject: [PATCH 1/4] added podspec validate in PRs --- .github/podspec-validate.yml | 121 +++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 .github/podspec-validate.yml diff --git a/.github/podspec-validate.yml b/.github/podspec-validate.yml new file mode 100644 index 00000000..d0b9b7e2 --- /dev/null +++ b/.github/podspec-validate.yml @@ -0,0 +1,121 @@ +name: Validate CocoaPods (PR) + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: podspec-validate-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +run-name: Validating CocoaPods + +jobs: + cocoapods-validate: + runs-on: macos-14 + + steps: + - name: Log environment + run: | + echo "macOS:" && sw_vers + echo "Xcode:" && xcodebuild -version + echo "Ruby:" && ruby -v + echo "CocoaPods:" && pod --version + + - name: Check out repository + uses: actions/checkout@v4 + + # (Optional but recommended) Ensure recent CocoaPods with include-podspecs support + # - name: Update CocoaPods + # run: sudo gem install cocoapods --no-document + + - name: Build validation plan + id: plan + shell: bash + run: | + set -euo pipefail + # Collect podspecs + shopt -s nullglob + all_specs=( *.podspec ) + + # Skip these completely + blacklist_regex='(VerizonMedia|Nielsen|Yospace)\.podspec$' + + utils="THEOplayer-Connector-Utilities.podspec" + conviva="THEOplayer-Connector-Conviva.podspec" + + list=() + for f in "${all_specs[@]}"; do + [[ $f =~ $blacklist_regex ]] && continue + # We'll handle Utilities + Conviva explicitly later + if [[ "$f" == "$utils" || "$f" == "$conviva" ]]; then + continue + fi + list+=("$f") + done + + echo "utils=$utils" >> "$GITHUB_OUTPUT" + echo "conviva=$conviva" >> "$GITHUB_OUTPUT" + printf 'others<> "$GITHUB_OUTPUT" + + - name: Point podspecs to PR branch (replace :tag => 'vX' with :branch => '') + shell: bash + run: | + set -euo pipefail + branch="$(git rev-parse --abbrev-ref HEAD)" + echo "Using branch: $branch" + for f in *.podspec; do + # macOS/BSD sed needs -i '' + sed -i '' "s|:tag => [^,}]*|:branch => \"$branch\"|g" "$f" + done + + - name: Lint Utilities first + shell: bash + run: | + set -euo pipefail + pod repo update + utils="${{ steps.plan.outputs.utils }}" + if [[ -f "$utils" ]]; then + echo "Linting $utils" + pod spec lint "$utils" --verbose --allow-warnings + else + echo "Utilities podspec not found at: $utils" + exit 1 + fi + + - name: Lint Conviva including local Utilities + shell: bash + run: | + set -euo pipefail + conviva="${{ steps.plan.outputs.conviva }}" + if [[ -f "$conviva" ]]; then + echo "Linting $conviva (with local Utilities)" + pod spec lint "$conviva" \ + --include-podspecs="THEOplayer-Connector-Utilities.podspec" \ + --verbose --allow-warnings + else + echo "Conviva podspec not found at: $conviva" + exit 1 + fi + + - name: Lint remaining podspecs + shell: bash + run: | + set -euo pipefail + mapfile -t others <<< "${{ steps.plan.outputs.others }}" + if (( ${#others[@]} )); then + for spec in "${others[@]}"; do + [[ -z "$spec" ]] && continue + echo "Linting $spec" + pod spec lint "$spec" --verbose --allow-warnings + done + else + echo "No additional podspecs to lint." + fi + + - name: Revert podspec edits + if: always() + shell: bash + run: | + git checkout -- *.podspec || true + From 842bfca10e0b83c0ea517f76a96ac5b08795f49a Mon Sep 17 00:00:00 2001 From: Daniel Dallos Date: Fri, 10 Oct 2025 00:05:10 +0200 Subject: [PATCH 2/4] move workflow file to the right place --- .github/{ => workflows}/podspec-validate.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/podspec-validate.yml (100%) diff --git a/.github/podspec-validate.yml b/.github/workflows/podspec-validate.yml similarity index 100% rename from .github/podspec-validate.yml rename to .github/workflows/podspec-validate.yml From 0aa413166ffac708a720fb8f091325156a8c9e99 Mon Sep 17 00:00:00 2001 From: Daniel Dallos Date: Fri, 10 Oct 2025 00:09:11 +0200 Subject: [PATCH 3/4] fix overrides --- .github/workflows/podspec-validate.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/podspec-validate.yml b/.github/workflows/podspec-validate.yml index d0b9b7e2..16aefea0 100644 --- a/.github/workflows/podspec-validate.yml +++ b/.github/workflows/podspec-validate.yml @@ -58,15 +58,24 @@ jobs: echo "conviva=$conviva" >> "$GITHUB_OUTPUT" printf 'others<> "$GITHUB_OUTPUT" - - name: Point podspecs to PR branch (replace :tag => 'vX' with :branch => '') + - name: Point podspecs to PR branch and fork origin shell: bash run: | set -euo pipefail - branch="$(git rev-parse --abbrev-ref HEAD)" - echo "Using branch: $branch" + + # Prefer the PR branch name from the event; fall back to ref_name or git + branch="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}}" + origin_url="$(git remote get-url origin)" + + echo "Using origin: ${origin_url}" + echo "Using branch: ${branch}" + + # macOS/BSD sed requires -i '' for f in *.podspec; do - # macOS/BSD sed needs -i '' - sed -i '' "s|:tag => [^,}]*|:branch => \"$branch\"|g" "$f" + # 1) Make the source git URL point to this repo (fork or upstream) + sed -i '' -E "s|:git => ['\"][^'\"]+['\"]|:git => '${origin_url}'|g" "$f" + # 2) Replace any :tag => ... with :branch => "" + sed -i '' -E "s|:tag => [^,}]*|:branch => '${branch}'|g" "$f" done - name: Lint Utilities first From 671e4127219b6d818afafbfc97b9c7d697baaf71 Mon Sep 17 00:00:00 2001 From: Daniel Dallos Date: Fri, 10 Oct 2025 00:24:17 +0200 Subject: [PATCH 4/4] use pod lib lint instead of spec lint --- .github/workflows/podspec-validate.yml | 142 +++++++++++++++---------- 1 file changed, 83 insertions(+), 59 deletions(-) diff --git a/.github/workflows/podspec-validate.yml b/.github/workflows/podspec-validate.yml index 16aefea0..10ce8db7 100644 --- a/.github/workflows/podspec-validate.yml +++ b/.github/workflows/podspec-validate.yml @@ -22,48 +22,60 @@ jobs: echo "Ruby:" && ruby -v echo "CocoaPods:" && pod --version - - name: Check out repository + - name: Check out repository (use PR head branch) uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 - # (Optional but recommended) Ensure recent CocoaPods with include-podspecs support - # - name: Update CocoaPods - # run: sudo gem install cocoapods --no-document - - - name: Build validation plan + - name: Build validation set id: plan shell: bash run: | set -euo pipefail - # Collect podspecs shopt -s nullglob + all_specs=( *.podspec ) + if (( ${#all_specs[@]} == 0 )); then + echo "skip=true" >> "$GITHUB_OUTPUT" + exit 0 + fi - # Skip these completely + # Skip these entirely blacklist_regex='(VerizonMedia|Nielsen|Yospace)\.podspec$' - utils="THEOplayer-Connector-Utilities.podspec" - conviva="THEOplayer-Connector-Conviva.podspec" - - list=() + filtered=() for f in "${all_specs[@]}"; do [[ $f =~ $blacklist_regex ]] && continue - # We'll handle Utilities + Conviva explicitly later - if [[ "$f" == "$utils" || "$f" == "$conviva" ]]; then - continue - fi - list+=("$f") + filtered+=("$f") done - echo "utils=$utils" >> "$GITHUB_OUTPUT" - echo "conviva=$conviva" >> "$GITHUB_OUTPUT" - printf 'others<> "$GITHUB_OUTPUT" + if (( ${#filtered[@]} == 0 )); then + echo "skip=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + + # Ensure Utilities goes first if present (often a base dep) + utils="THEOplayer-Connector-Utilities.podspec" + ordered=() + if printf '%s\n' "${filtered[@]}" | grep -qx "$utils"; then + ordered+=("$utils") + for f in "${filtered[@]}"; do + [[ "$f" == "$utils" ]] && continue + ordered+=("$f") + done + else + ordered=("${filtered[@]}") + fi + + printf 'list<> "$GITHUB_OUTPUT" + echo "skip=false" >> "$GITHUB_OUTPUT" - name: Point podspecs to PR branch and fork origin + if: steps.plan.outputs.skip == 'false' shell: bash run: | set -euo pipefail - - # Prefer the PR branch name from the event; fall back to ref_name or git branch="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}}" origin_url="$(git remote get-url origin)" @@ -72,55 +84,64 @@ jobs: # macOS/BSD sed requires -i '' for f in *.podspec; do - # 1) Make the source git URL point to this repo (fork or upstream) + # 1) point source git URL to this repo (fork or upstream) sed -i '' -E "s|:git => ['\"][^'\"]+['\"]|:git => '${origin_url}'|g" "$f" - # 2) Replace any :tag => ... with :branch => "" + # 2) replace any :tag => ... with :branch => "" sed -i '' -E "s|:tag => [^,}]*|:branch => '${branch}'|g" "$f" done - - name: Lint Utilities first - shell: bash - run: | - set -euo pipefail - pod repo update - utils="${{ steps.plan.outputs.utils }}" - if [[ -f "$utils" ]]; then - echo "Linting $utils" - pod spec lint "$utils" --verbose --allow-warnings - else - echo "Utilities podspec not found at: $utils" - exit 1 - fi + - name: pod repo update (resolve remote deps) + if: steps.plan.outputs.skip == 'false' + run: pod repo update - - name: Lint Conviva including local Utilities + - name: Lint all podspecs with local dependencies injected + if: steps.plan.outputs.skip == 'false' shell: bash run: | set -euo pipefail - conviva="${{ steps.plan.outputs.conviva }}" - if [[ -f "$conviva" ]]; then - echo "Linting $conviva (with local Utilities)" - pod spec lint "$conviva" \ - --include-podspecs="THEOplayer-Connector-Utilities.podspec" \ - --verbose --allow-warnings - else - echo "Conviva podspec not found at: $conviva" + + # Verify this CocoaPods supports --include-podspecs for lib lint + if ! pod lib lint --help | grep -q -- '--include-podspecs'; then + echo "::error::Your CocoaPods version doesn't support --include-podspecs on pod lib lint. Consider updating CocoaPods (gem install cocoapods)." exit 1 fi - - name: Lint remaining podspecs - shell: bash - run: | - set -euo pipefail - mapfile -t others <<< "${{ steps.plan.outputs.others }}" - if (( ${#others[@]} )); then - for spec in "${others[@]}"; do - [[ -z "$spec" ]] && continue - echo "Linting $spec" - pod spec lint "$spec" --verbose --allow-warnings + # Read multiline output into an array + specs_str="${{ steps.plan.outputs.list }}" + specs=() + while IFS= read -r line; do + [[ -z "$line" ]] && continue + specs+=("$line") + done <<< "$specs_str" + + printf 'Planned specs:\n- %s\n' "${specs[@]}" + + # For each spec, include *all the other* local podspecs so inter-deps resolve locally + for spec in "${specs[@]}"; do + [[ -z "$spec" ]] && continue + + # Build include list excluding the current spec + includes=() + for other in "${specs[@]}"; do + [[ "$other" == "$spec" ]] && continue + includes+=("$other") done - else - echo "No additional podspecs to lint." - fi + + include_flag=() + if [[ ${#includes[@]} -gt 0 ]]; then + include_csv="$(IFS=,; echo "${includes[*]}")" + include_flag=(--include-podspecs="$include_csv") + fi + + echo "----------------------------------------" + echo "Linting: $spec" + echo "Include: ${include_flag[*]:-(none)}" + echo "----------------------------------------" + + pod lib lint "$spec" \ + "${include_flag[@]}" \ + --verbose --allow-warnings + done - name: Revert podspec edits if: always() @@ -128,3 +149,6 @@ jobs: run: | git checkout -- *.podspec || true + - name: Done + if: steps.plan.outputs.skip == 'true' + run: echo "No podspecs to validate on this PR."