-
Notifications
You must be signed in to change notification settings - Fork 3
157 lines (129 loc) · 4.91 KB
/
podspec-validate.yml
File metadata and controls
157 lines (129 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2.0'
- name: Log environment
run: |
echo "macOS:" && sw_vers
echo "Xcode:" && xcodebuild -version
echo "Ruby:" && ruby -v
echo "CocoaPods:" && pod --version
- name: Check out repository (use PR head branch)
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Build validation set
id: plan
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
all_specs=( *.podspec )
if (( ${#all_specs[@]} == 0 )); then
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Skip these entirely
blacklist_regex='(VerizonMedia|Nielsen|Yospace)\.podspec$'
filtered=()
for f in "${all_specs[@]}"; do
[[ $f =~ $blacklist_regex ]] && continue
filtered+=("$f")
done
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<<EOF\n%s\nEOF\n' "$(printf '%s\n' "${ordered[@]}")" >> "$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
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
# 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 => "<branch>"
sed -i '' -E "s|:tag => [^,}]*|:branch => '${branch}'|g" "$f"
done
- name: pod repo update (resolve remote deps)
if: steps.plan.outputs.skip == 'false'
run: pod repo update
- name: Lint all podspecs with local dependencies injected
if: steps.plan.outputs.skip == 'false'
shell: bash
run: |
set -euo pipefail
# 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
# 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
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()
shell: bash
run: |
git checkout -- *.podspec || true
- name: Done
if: steps.plan.outputs.skip == 'true'
run: echo "No podspecs to validate on this PR."