Skip to content

Commit b7fc3a1

Browse files
Add documentation for Packages in CI (#3154)
motivation: document how to use SwiftPM in CI changes: add a doc about CI rdar://65206398
1 parent 1eb1342 commit b7fc3a1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Documentation/ContinousIntegration.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Building Swift Packages or Apps that Use Them in Continuous Integration Workflows
2+
3+
Build Swift packages with an existing continuous integration setup and prepare apps that consume package dependencies within an existing CI pipeline.
4+
5+
## Overview
6+
7+
*Continuous integration* (*CI*) is the process of automating and streamlining the building, analyzing, testing, archiving, and publishing of your apps to ensure that they're always in a releasable state.
8+
Most projects that contain or depend on Swift packages don't require additional configuration.
9+
10+
## Use the Expected Version of a Package Dependency
11+
12+
To ensure the *CI* workflow’s reliability, make sure it uses the appropriate version of package dependencies.
13+
SwiftPM records the result of dependency resolution in `Package.resolved` (at the top-level of the package) and it's used when performing dependency resolution (rather than having SwiftPM searching the latest eligible version of each package). Running `swift package update` updates all dependencies to the latest eligible versions and updates the `Package.resolved`. You can commit `Package.resolved` to your *Git* repository to ensure it’s always up-to-date on the *CI* environment to prevent the *CI* from building your project with unexpected versions of package dependencies. Otherwise you can choose to add `Package.resolved` file to `.gitignore` file and have `swift package resolve` command in charge of resolving the dependencies (`swift package resolve` is invoked by most SwiftPM commands).
14+
15+
## Provide Credentials
16+
17+
To resolve package dependencies that require authentication, such as private packages, you need to provide credentials to your CI setup.
18+
SwiftPM honors the machine's SSH configuration - there's no additional setup required on SwiftPM side. For private package, use the SSH-based Git URLs and configure SSH credentials. You may also need to set up a known_hosts file in the ~/.ssh directory of the user that runs your CI tasks.
19+
20+
CI services like [Jenkins](https://www.jenkins.io/doc/book/using/using-credentials), [Github Action](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow), [TravisCI](https://docs.travis-ci.com/user/private-dependencies), [CircleCI](https://circleci.com/docs/2.0/gh-bb-integration/#security) provide ways to set up SSH keys or other techniques to access private repositories. Since SwiftPM uses git to clone the repositories there's no additional setup required on SwiftPM side, and SwiftPM will honor the machine's SSH and Git configuration.
21+
22+
## Using xcodebuild
23+
When building on macOS based CI hosts you can use the command-line tool `xcodebuild`.
24+
`xcodebuild` uses Xcode's built-in Git tooling to connect to repositories. In many cases, you don't need to make changes to how xcodebuild connects to them. However, some use cases require you use the configuration you set for your Mac's Git installation (Some examples: URL remapping, Proxy configurations, Advanced SSH configurations). To have xcodebuild use your Mac's Git installation and configuration instead of Xcode's built-in Git tooling, pass `-scmProvider system` to the xcodebuild command.
25+
26+
For more information on using xcodebuild in continuous integration workflows, visit [this link](https://developer.apple.com/documentation/swift_packages/building_swift_packages_or_apps_that_use_them_in_continuous_integration_workflows).

Documentation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ We’ve designed the system to make it really easy to share packages on services
1717
* [Dependency Hell](#dependency-hell)
1818
* [Usage](Usage.md)
1919
* [PackageDescription API](PackageDescription.md)
20+
* [Continous Integration](ContinousIntegration.md)
2021
* [libSwiftPM](libSwiftPM.md)
2122
* [Resources](Resources.md)
2223

0 commit comments

Comments
 (0)