Skip to content

Commit 671e412

Browse files
Daniel Dalloswvanhaevre
authored andcommitted
use pod lib lint instead of spec lint
1 parent 0aa4131 commit 671e412

1 file changed

Lines changed: 83 additions & 59 deletions

File tree

.github/workflows/podspec-validate.yml

Lines changed: 83 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,60 @@ jobs:
2222
echo "Ruby:" && ruby -v
2323
echo "CocoaPods:" && pod --version
2424
25-
- name: Check out repository
25+
- name: Check out repository (use PR head branch)
2626
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ github.head_ref }}
29+
fetch-depth: 0
2730

28-
# (Optional but recommended) Ensure recent CocoaPods with include-podspecs support
29-
# - name: Update CocoaPods
30-
# run: sudo gem install cocoapods --no-document
31-
32-
- name: Build validation plan
31+
- name: Build validation set
3332
id: plan
3433
shell: bash
3534
run: |
3635
set -euo pipefail
37-
# Collect podspecs
3836
shopt -s nullglob
37+
3938
all_specs=( *.podspec )
39+
if (( ${#all_specs[@]} == 0 )); then
40+
echo "skip=true" >> "$GITHUB_OUTPUT"
41+
exit 0
42+
fi
4043
41-
# Skip these completely
44+
# Skip these entirely
4245
blacklist_regex='(VerizonMedia|Nielsen|Yospace)\.podspec$'
4346
44-
utils="THEOplayer-Connector-Utilities.podspec"
45-
conviva="THEOplayer-Connector-Conviva.podspec"
46-
47-
list=()
47+
filtered=()
4848
for f in "${all_specs[@]}"; do
4949
[[ $f =~ $blacklist_regex ]] && continue
50-
# We'll handle Utilities + Conviva explicitly later
51-
if [[ "$f" == "$utils" || "$f" == "$conviva" ]]; then
52-
continue
53-
fi
54-
list+=("$f")
50+
filtered+=("$f")
5551
done
5652
57-
echo "utils=$utils" >> "$GITHUB_OUTPUT"
58-
echo "conviva=$conviva" >> "$GITHUB_OUTPUT"
59-
printf 'others<<EOF\n%s\nEOF\n' "$(printf '%s\n' "${list[@]}")" >> "$GITHUB_OUTPUT"
53+
if (( ${#filtered[@]} == 0 )); then
54+
echo "skip=true" >> "$GITHUB_OUTPUT"
55+
exit 0
56+
fi
57+
58+
# Ensure Utilities goes first if present (often a base dep)
59+
utils="THEOplayer-Connector-Utilities.podspec"
60+
ordered=()
61+
if printf '%s\n' "${filtered[@]}" | grep -qx "$utils"; then
62+
ordered+=("$utils")
63+
for f in "${filtered[@]}"; do
64+
[[ "$f" == "$utils" ]] && continue
65+
ordered+=("$f")
66+
done
67+
else
68+
ordered=("${filtered[@]}")
69+
fi
70+
71+
printf 'list<<EOF\n%s\nEOF\n' "$(printf '%s\n' "${ordered[@]}")" >> "$GITHUB_OUTPUT"
72+
echo "skip=false" >> "$GITHUB_OUTPUT"
6073
6174
- name: Point podspecs to PR branch and fork origin
75+
if: steps.plan.outputs.skip == 'false'
6276
shell: bash
6377
run: |
6478
set -euo pipefail
65-
66-
# Prefer the PR branch name from the event; fall back to ref_name or git
6779
branch="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}}"
6880
origin_url="$(git remote get-url origin)"
6981
@@ -72,59 +84,71 @@ jobs:
7284
7385
# macOS/BSD sed requires -i ''
7486
for f in *.podspec; do
75-
# 1) Make the source git URL point to this repo (fork or upstream)
87+
# 1) point source git URL to this repo (fork or upstream)
7688
sed -i '' -E "s|:git => ['\"][^'\"]+['\"]|:git => '${origin_url}'|g" "$f"
77-
# 2) Replace any :tag => ... with :branch => "<branch>"
89+
# 2) replace any :tag => ... with :branch => "<branch>"
7890
sed -i '' -E "s|:tag => [^,}]*|:branch => '${branch}'|g" "$f"
7991
done
8092
81-
- name: Lint Utilities first
82-
shell: bash
83-
run: |
84-
set -euo pipefail
85-
pod repo update
86-
utils="${{ steps.plan.outputs.utils }}"
87-
if [[ -f "$utils" ]]; then
88-
echo "Linting $utils"
89-
pod spec lint "$utils" --verbose --allow-warnings
90-
else
91-
echo "Utilities podspec not found at: $utils"
92-
exit 1
93-
fi
93+
- name: pod repo update (resolve remote deps)
94+
if: steps.plan.outputs.skip == 'false'
95+
run: pod repo update
9496

95-
- name: Lint Conviva including local Utilities
97+
- name: Lint all podspecs with local dependencies injected
98+
if: steps.plan.outputs.skip == 'false'
9699
shell: bash
97100
run: |
98101
set -euo pipefail
99-
conviva="${{ steps.plan.outputs.conviva }}"
100-
if [[ -f "$conviva" ]]; then
101-
echo "Linting $conviva (with local Utilities)"
102-
pod spec lint "$conviva" \
103-
--include-podspecs="THEOplayer-Connector-Utilities.podspec" \
104-
--verbose --allow-warnings
105-
else
106-
echo "Conviva podspec not found at: $conviva"
102+
103+
# Verify this CocoaPods supports --include-podspecs for lib lint
104+
if ! pod lib lint --help | grep -q -- '--include-podspecs'; then
105+
echo "::error::Your CocoaPods version doesn't support --include-podspecs on pod lib lint. Consider updating CocoaPods (gem install cocoapods)."
107106
exit 1
108107
fi
109108
110-
- name: Lint remaining podspecs
111-
shell: bash
112-
run: |
113-
set -euo pipefail
114-
mapfile -t others <<< "${{ steps.plan.outputs.others }}"
115-
if (( ${#others[@]} )); then
116-
for spec in "${others[@]}"; do
117-
[[ -z "$spec" ]] && continue
118-
echo "Linting $spec"
119-
pod spec lint "$spec" --verbose --allow-warnings
109+
# Read multiline output into an array
110+
specs_str="${{ steps.plan.outputs.list }}"
111+
specs=()
112+
while IFS= read -r line; do
113+
[[ -z "$line" ]] && continue
114+
specs+=("$line")
115+
done <<< "$specs_str"
116+
117+
printf 'Planned specs:\n- %s\n' "${specs[@]}"
118+
119+
# For each spec, include *all the other* local podspecs so inter-deps resolve locally
120+
for spec in "${specs[@]}"; do
121+
[[ -z "$spec" ]] && continue
122+
123+
# Build include list excluding the current spec
124+
includes=()
125+
for other in "${specs[@]}"; do
126+
[[ "$other" == "$spec" ]] && continue
127+
includes+=("$other")
120128
done
121-
else
122-
echo "No additional podspecs to lint."
123-
fi
129+
130+
include_flag=()
131+
if [[ ${#includes[@]} -gt 0 ]]; then
132+
include_csv="$(IFS=,; echo "${includes[*]}")"
133+
include_flag=(--include-podspecs="$include_csv")
134+
fi
135+
136+
echo "----------------------------------------"
137+
echo "Linting: $spec"
138+
echo "Include: ${include_flag[*]:-(none)}"
139+
echo "----------------------------------------"
140+
141+
pod lib lint "$spec" \
142+
"${include_flag[@]}" \
143+
--verbose --allow-warnings
144+
done
124145
125146
- name: Revert podspec edits
126147
if: always()
127148
shell: bash
128149
run: |
129150
git checkout -- *.podspec || true
130151
152+
- name: Done
153+
if: steps.plan.outputs.skip == 'true'
154+
run: echo "No podspecs to validate on this PR."

0 commit comments

Comments
 (0)