Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ policy helpers and the release packaging scripts loaded by Jenkins.
| `build/` | Jenkins platform Groovy entry points call packaging scripts, which use each project's `cloud_build.*` adapters. IPA entry points also depend on external Jenkins configuration. | Run the signing-preflight unit tests below; actual signing, private SDK injection and artifact verification belong to Jenkins. |
| `policy/` | `repository-policy.yml` runs AI asset validation and native template lifecycle regressions; `.git-hooks/` supplies the local credential and commit-message checks. | Follow [AI validation](../../docs/ai/README.md) for venv setup and policy checks. |

After creating the venv described above, run the packaging helper tests from the repository root:
After creating the venv described above, run the packaging helper tests (signing preflight and public/local SDK dependency selection) from the repository root:

```bash
.venv/bin/python -m unittest discover --start-directory .github/ci/build/tests --pattern 'test_check_ios_signing_assets.py'
.venv/bin/python -m unittest discover --start-directory .github/ci/build/tests --pattern 'test_*.py'
```

Keep the Jenkins entry point and `build/` paths stable: external jobs and existing scripts
Expand Down
9 changes: 6 additions & 3 deletions .github/ci/build/modify_podfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, sys
import re
import sys

def modfiy(path, sdk_flag):
with open(path, 'r', encoding='utf-8') as file:
Expand All @@ -7,9 +8,11 @@ def modfiy(path, sdk_flag):
if "pod 'Agora" in line:
if sdk_flag:
line = '\t'+"pod 'sdk', :path => '../../sdk.podspec'" + "\n"
else:
# Without an SDK package, use the declared public pod and version.
line = re.sub(r"^(\s*)#\s*(pod\s)", r"\1\2", line)
elif "pod 'sdk" in line:
if sdk_flag:
line = ""
line = ""
elif 'sh .download_script' in line:
line = line.replace('true', 'false') + "\n"
contents.append(line)
Expand Down
84 changes: 84 additions & 0 deletions .github/ci/build/tests/test_modify_podfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import importlib.util
from pathlib import Path
import re
import subprocess
import tempfile
import unittest


BUILD_DIR = Path(__file__).resolve().parents[1]
REPO_ROOT = BUILD_DIR.parents[2]
SPEC = importlib.util.spec_from_file_location("modify_podfile", BUILD_DIR / "modify_podfile.py")
MODULE = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(MODULE)
PROJECTS = {
"iOS/APIExample": "AgoraRtcEngine_iOS",
"iOS/APIExample-Audio": "AgoraAudio_iOS",
"iOS/APIExample-SwiftUI": "AgoraRtcEngine_iOS",
"iOS/APIExample-OC": "AgoraRtcEngine_iOS",
"macOS": "AgoraRtcEngine_macOS",
}


def active_sdk_dependencies(content):
return re.findall(r"^\s*pod\s+['\"]((?:Agora|sdk)[^'\"]*)['\"](.*)$", content, re.MULTILINE)


class ModifyPodfileTests(unittest.TestCase):
def transform(self, project, supplied_sdk):
original = (REPO_ROOT / project / "Podfile").read_text(encoding="utf-8")
with tempfile.TemporaryDirectory() as directory:
path = Path(directory) / "Podfile"
path.write_text(original, encoding="utf-8")
MODULE.modfiy(str(path), supplied_sdk)
return original, path.read_text(encoding="utf-8")

def test_no_sdk_url_selects_exact_published_sdk(self):
for project, pod in PROJECTS.items():
with self.subTest(project=project):
original, result = self.transform(project, False)
version = re.search(rf"pod '{pod}', '([^']+)'", original).group(1)
self.assertEqual(active_sdk_dependencies(result), [(pod, f", '{version}'")])

def test_supplied_sdk_selects_only_injected_package(self):
for project in PROJECTS:
with self.subTest(project=project):
_, result = self.transform(project, True)
self.assertEqual(active_sdk_dependencies(result), [("sdk", ", :path => '../../sdk.podspec'")])

def test_preserves_non_sdk_configuration_and_disabled_download_hook(self):
for project in PROJECTS:
for supplied_sdk in (False, True):
with self.subTest(project=project, supplied_sdk=supplied_sdk):
original, result = self.transform(project, supplied_sdk)
def unrelated(content):
return [line for line in content.splitlines() if line.strip()
and "pod 'Agora" not in line and "pod 'sdk" not in line
and "sh .download_script" not in line]
self.assertEqual(unrelated(result), unrelated(original))
hooks = [line for line in result.splitlines() if "sh .download_script" in line]
self.assertTrue(hooks)
self.assertTrue(all(line.lstrip().startswith("#") for line in hooks))

def test_public_dependency_selection_is_repeatable(self):
for project in PROJECTS:
with self.subTest(project=project), tempfile.TemporaryDirectory() as directory:
_, result = self.transform(project, False)
path = Path(directory) / "Podfile"
path.write_text(result, encoding="utf-8")
MODULE.modfiy(str(path), False)
self.assertEqual(active_sdk_dependencies(path.read_text()), active_sdk_dependencies(result))

def test_generated_podfiles_have_valid_ruby_syntax(self):
for project in PROJECTS:
for supplied_sdk in (False, True):
with self.subTest(project=project, supplied_sdk=supplied_sdk), tempfile.TemporaryDirectory() as directory:
_, result = self.transform(project, supplied_sdk)
path = Path(directory) / "Podfile"
path.write_text(result, encoding="utf-8")
check = subprocess.run(["ruby", "-c", str(path)], capture_output=True, text=True)
self.assertEqual(check.returncode, 0, check.stdout + check.stderr)


if __name__ == "__main__":
unittest.main()
Loading