Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dogfood tool to support new format of package.resolved #800

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
20 changes: 13 additions & 7 deletions tools/distribution/dogfood.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import traceback
from tempfile import TemporaryDirectory
from src.dogfood.package_resolved import PackageResolvedFile
from src.dogfood.package_resolved import PackageResolvedFile, PackageID
from src.dogfood.dogfooded_commit import DogfoodedCommit
from src.dogfood.repository import Repository
from src.utils import remember_cwd
Expand All @@ -28,6 +28,12 @@ def dogfood(dry_run: bool, repository_url: str, repository_name: str, repository
os.system(f'swift package --package-path {dd_sdk_package_path} resolve')
dd_sdk_ios_package = PackageResolvedFile(path=f'{dd_sdk_package_path}/Package.resolved')

if dd_sdk_ios_package.version != 1:
raise Exception(
f'`dogfood.py` expects the `package.resolved` in `dd-sdk-ios` to use version 1 ' +
f'but version {dd_sdk_ios_package.version} was detected. Update `dogfood.py` to use this version.'
)

# Clone dependant repo to temporary location and update its `Package.resolved` (one or many) so it points
# to the current `dd-sdk-ios` commit. After that, push changes to dependant repo and create dogfooding PR.
with TemporaryDirectory() as temp_dir:
Expand All @@ -46,26 +52,26 @@ def dogfood(dry_run: bool, repository_url: str, repository_name: str, repository
# Update version of `dd-sdk-ios`:
for package in packages:
package.update_dependency(
package_name='DatadogSDK',
package_id=PackageID(v1='DatadogSDK', v2='dd-sdk-ios'),
new_branch='dogfooding',
new_revision=dd_sdk_ios_commit.hash,
new_version=None
)

# Add or update `dd-sdk-ios` dependencies
for dependency_name in dd_sdk_ios_package.read_dependency_names():
dependency = dd_sdk_ios_package.read_dependency(package_name=dependency_name)
for dependency_id in dd_sdk_ios_package.read_dependency_ids():
dependency = dd_sdk_ios_package.read_dependency(package_id=dependency_id)

if package.has_dependency(package_name=dependency_name):
if package.has_dependency(package_id=dependency_id):
package.update_dependency(
package_name=dependency_name,
package_id=dependency_id,
new_branch=dependency['state']['branch'],
new_revision=dependency['state']['revision'],
new_version=dependency['state']['version'],
)
else:
package.add_dependency(
package_name=dependency_name,
package_id=dependency_id,
repository_url=dependency['repositoryURL'],
branch=dependency['state']['branch'],
revision=dependency['state']['revision'],
Expand Down
Loading