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

Change directory to nested Package.swift #44

Merged
merged 1 commit into from
Aug 3, 2021
Merged

Change directory to nested Package.swift #44

merged 1 commit into from
Aug 3, 2021

Conversation

vknabel
Copy link
Contributor

@vknabel vknabel commented Jul 14, 2021

We had the same use as in #40.
We have a Package in ./BuildTools which includes Komondor among other tools.

To set up we run cd BuildTools && swift run komondor install. Though in the current master Komondor would head to the repositories' root and wouldn't find any Package.swift-file.

With this PR it would insert a simple cd ./BuildTools before looking for the manifest.
Therefore hooks will also be executed relative to the swift manifest.


An example of such a package in BuildTools/Package.swift:

// swift-tools-version:5.4
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "BuildTools",
    platforms: [.macOS(.v10_11)],
    dependencies: [
        .package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.48.6"),
        .package(url: "https://github.com/shibapm/Komondor.git", from: "1.0.6"),
        .package(url: "https://github.com/realm/SwiftLint.git", from: "0.43.1"),
        .package(url: "https://github.com/SwiftGen/SwiftGen.git", from: "6.4.0")
    ],
    targets: []
)

#if canImport(PackageConfig)
    import PackageConfig

    let config = PackageConfiguration([
        "komondor": [
            "pre-commit": [
                "cd .. && swift run -c release --package-path BuildTools swiftgen",
                "cd .. && swift run -c release --package-path BuildTools swiftformat --config .swiftformat ./**/*.swift",
                "cd .. && swift run -c release --package-path BuildTools swiftlint autocorrect",
                "cd .. && git add ."
            ]
        ]
    ]).write()
#endif

@@ -1,4 +1,4 @@
@testable import komondor
@testable import Komondor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When trying to commit I receive an error:

Komondor/Tests/KomondorTests/KomondorTests.swift:1:18: error: no such module 'Komondor'
@testable import Komondor
                 ^
note: module 'Komondor' is the main module of an executable, and cannot be imported by tests and other targets

I could extract all code except main.swift into a separate target (e.g. KomondorKit) if you like.

@orta
Copy link
Member

orta commented Aug 3, 2021

I like this strategy, I think it makes sense - thanks

@orta orta merged commit c468a3d into shibapm:master Aug 3, 2021
@vknabel
Copy link
Contributor Author

vknabel commented Aug 3, 2021

Thanks for the merge and all your work!

@orta
Copy link
Member

orta commented Aug 3, 2021

I think @f-meloni might need to deploy, my swift build env seems to be real broken

@orta
Copy link
Member

orta commented Aug 3, 2021

I did fix the dog pic in the README tho

@vknabel
Copy link
Contributor Author

vknabel commented Aug 4, 2021

If I can take some work off you, just tell me.

@f-meloni
Copy link
Member

f-meloni commented Aug 8, 2021

I've released the version 1.1.0, let me know if everything is ok

@vknabel
Copy link
Contributor Author

vknabel commented Aug 19, 2021

Thank you very much! The release works fine 👍
(Sorry for the late response – took some time off)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants