Skip to content

Commit

Permalink
Check for changes in Package.swift on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Alekseev committed May 15, 2020
1 parent 4e3acb7 commit 9385efb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build & Test
run: make test
run: ON_CI=1 make test
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## 2020-05-15

`Package.swift` file is now generated. All `import` statements are parsed to do that. On CI, the check has been added to verify that `Package.swift` is commited correctly.

New `make gen` command will generate both `Package.swift` and Xcode project.

## 2020-04-22

A new test discovery mode `runtimeExecutableLaunch` is added. The new test discovery mode is similar to `runtimeLogicTest` but instead of loading your xctest bundle in the xctest process of a simulator, it uses your app executable to load the xctest bundle and perform a dump. Such discovery mode is useful for xctest bundles that rely on bundle_loader symbols to be present in the runtime and thus cannot be loaded in an improper executable.
Expand Down
9 changes: 9 additions & 0 deletions PackageGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ func generatePackageSwift(raplacementForTargets: [String]) throws {
of: "<__TARGETS__>",
with: raplacementForTargets.map { " \($0)" }.joined(separator: "\n")
)

if ProcessInfo.processInfo.environment["ON_CI"] != nil {
log("Checking for Package.swift consistency")
let existingContents = try String(contentsOf: URL(fileURLWithPath: "Package.swift"))
if existingContents != templateContents {
fatalError("ON_CI is set, and Package.swift differs. Please update and commit Package.swift!")
}
}

log("Saving Package.swift")
try templateContents.write(to: URL(fileURLWithPath: "Package.swift"), atomically: true, encoding: .utf8)
}
Expand Down

0 comments on commit 9385efb

Please sign in to comment.