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

Add CI check to validate package.resolved #643

Merged
merged 18 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ steps:
permit_on_passed: true
agents:
queue: linter

- label: ":swift: Package.resolved"
plugins: [$CI_TOOLKIT]
notify:
- github_commit_status:
context: "Package.resolved"
command: |
install_gems
bundle exec make validate-package-resolved

#################
# Build and Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "dddfee60d726ac68a5cd796dea6619c69dcce5cc55b1b6d7d75bb308b96243a1",
"originHash" : "ef380bfd827500bb40ef65e62058cb22bbebbf217402a19c327d4201d142ba21",
"pins" : [
{
"identity" : "swift-snapshot-testing",
Expand All @@ -18,15 +18,6 @@
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nicklockwood/SwiftFormat",
"state" : {
"revision" : "86ed20990585f478c0daf309af645c2a528b59d8",
"version" : "0.54.6"
}
}
],
"version" : 3
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ ifndef BUILD_NUMBER
override BUILD_NUMBER = 0
endif

validate-package-resolved: bundle-install
@bundle exec fastlane validate_package_resolved scheme:$(SCHEME_DEMO)

bundle-install:
bundle install

Expand Down
30 changes: 30 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ platform :ios do
)
end

desc 'Checks whether all Package.resolved files are current'
lane :validate_package_resolved do |scheme:|
resolve_package_dependencies_for_project(project: XCODEPROJ_PATH, scheme: scheme)
resolve_package_dependencies_for_spm

if uncommitted_changes.empty?
UI.success('No uncommitted changes found.')
else
UI.user_error!("Uncommitted changes detected: \n #{uncommitted_changes}")
end
end

desc 'Builds the demo app from the given scheme for distribution'
lane :build_demo_for_distribution do |scheme:, build_number:|
UI.user_error! 'Please pass a build number by calling the lane with build_number:VALUE' if build_number.nil? || build_number.empty?
Expand Down Expand Up @@ -219,3 +231,21 @@ def read_from_xcconfig!(key:, xcconfig:)

configs[key]
end

def resolve_package_dependencies_for_project(project:, scheme:)
xcodebuild(
project: project,
scheme: scheme,
configuration: 'Debug',
clean: true,
xcargs: '-resolvePackageDependencies -skipPackageUpdates'
)
end

def resolve_package_dependencies_for_spm
spm(command: 'resolve')
end

def uncommitted_changes
sh('git status --porcelain').strip
end