Compare commits

...

7 Commits

Author SHA1 Message Date
Joseph Mattello
e9d3060df7 Swift PM switch roxas fork
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
2023-02-26 21:27:42 -05:00
Joseph Mattello
c59043068e Package.swift Roxas use SideStore port
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
2023-02-26 21:27:42 -05:00
Joseph Mattello
65c43d683c Package.swift builds but errors
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
2023-02-26 21:27:42 -05:00
Joseph Mattello
9e6147c860 Add Package.swift for Danger
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
2023-02-26 21:27:42 -05:00
Joseph Mattello
b3074cadf9 Add Danger github action
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
2023-02-26 21:27:42 -05:00
Joseph Mattello
9c5c597ce6 Add Dangerfile copied from Provenance 2023-02-26 21:27:42 -05:00
Joseph Mattello
977a452605 Add Dangerfile.swift
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
2023-02-26 21:27:40 -05:00
10 changed files with 430 additions and 5 deletions

13
.github/workflows/danger.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
name: "Danger Swift"
on: [pull_request]
jobs:
build:
name: Danger JS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Danger Swift
uses: danger/swift@2.0.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@@ -35,6 +35,8 @@ xcuserdata
## AppCode specific ## AppCode specific
.idea/ .idea/
.build
Payload/ Payload/
SideStore.ipa SideStore.ipa
Dependencies/.*-prebuilt-fetch-* Dependencies/.*-prebuilt-fetch-*

137
Dangerfile.swift Normal file
View File

@@ -0,0 +1,137 @@
import Danger
import Foundation
// import SwiftLint
let danger = Danger()
// fileImport: DangerfileExtensions/ChangelogCheck.swift
// checkChangelog()
// Add a CHANGELOG entry for app changes
let hasChangelog = danger.git.modifiedFiles.contains("Changelog.md")
let isTrivial = (danger.github.pullRequest.body + danger.github.pullRequest.title).contains("#trivial")
if (!hasChangelog && !isTrivial) {
warn("Please add a changelog entry for your changes.")
}
// PR Too large
if danger.git.createdFiles.count + danger.git.modifiedFiles.count - danger.git.deletedFiles.count > 600 {
warn("Big PR, try to keep changes smaller if you can")
}
// Check copyright
let swiftFilesWithCopyright = danger.git.createdFiles.filter {
$0.fileType == .swift
&& danger.utils.readFile($0).contains("// Created by")
}
if !swiftFilesWithCopyright.isEmpty {
let files = swiftFilesWithCopyright.joined(separator: ", ")
warn("In Danger JS we don't include copyright headers, found them in: \(files)")
}
// # This is swiftlint plugin. More info: https://github.com/ashfurrow/danger-swiftlint
// #
// # This lints all Swift files and leave comments in PR if
// # there is any issue with linting
let filesToLint = (danger.git.modifiedFiles + danger.git.createdFiles) // .filter { !$0.contains("Documentation/") }
SwiftLint.lint(.files(filesToLint), inline: true)
// Support running via `danger local`
if danger.github != nil {
// These checks only happen on a PR
if danger.github.pullRequest.title.contains("WIP") {
warn("PR is classed as Work in Progress")
}
}
if github.pr_title.contains("WIP") {
warn("PR is classed as Work in Progress")
}
if git.commits.any {
return $0.message.contains("Merge branch '\(github.branch_for_base)'")
} {
fail("Please rebase to get rid of the merge commits in this PR ")
}
if github.pr_body.length > 1000 {
warn("PR body is too long")
}
if github.pr_body.length < 5 {
fail("PR body is too short")
}
let has_app_changes = !git.modified_files.any { $0.contains("AltStore") }
let has_altstorecore_changes = !git.modified_files.any { $0.contains("AltStoreCore") }
// let has_support_test_changes = !git.modified_files.any { $0.contains("AltStoreCore
// Tests") }
// let has_library_changes = !git.modified_files.any { $0.contains("PVLibrary") }
// let has_library_test_changes = !git.modified_files.any { $0.contains("PVLibrary Tests") }
// If changes are more than 10 lines of code, tests need to be updated too
// if (has_core_changes && !has_core_test_changes) ||
// (has_coreui_changes && !has_coreui_test_changes)) &&
// git.lines_of_code > 10 {
// fail("Tests were not updated", sticky: false)
// }
// Info.plist file shouldn't change often. Leave warning if it changes.
let is_plist_change = git.modified_files.any { $0.contains("Info.plist") }
if !is_plist_change
// warn "A Plist was changed"
warn("Plist changed, don't forget to localize your plist values")
end
// gemfile_updated = !git.modified_files.grep(/Gemfile$/).empty?
// # Leave warning, if Gemfile changes
// if gemfile_updated
// warn "The `Gemfile` was updated"
// end
// import xcodebuild
// xcodebuild.json_file = "./fastlane/reports/xcpretty-json-formatter-results.json"
// xcodebuild.parse_warnings() // returns number of warnings
// xcodebuild.parse_errors() // returns number of errors
// // xcodebuild.parse_errors(errors: danger.github.pull_request.body)
// xcodebuild.parse_tests() // returns number of test failures
// xcodebuild.perfect_build() // returns a bool indicating if the build was perfect
func checkSwiftVersions() {
SwiftChecks.check(
files: [
VersionFile(
path: "./\(projectName).xcodeproj/project.pbxproj",
interpreter: .regex("SWIFT_VERSION = (.*);")
),
VersionFile(
path: "./\(projectName).podspec",
interpreter: .regex("\\.swift_version\\s*=\\s*\"(.*)\"")
),
],
versionKind: "Swift"
)
}
func checkProjectVersions() {
SwiftChecks.check(
fileProviders: [
InfoPlistFileProvider(
discoveryMethod: .searchDirectory("./Sources", fileNames: ["Info.plist"]),
plistKey: .versionNumber,
projectFilePath: "./\(projectName).xcodeproj"
),
],
files: [
VersionFile(path: "./\(projectName).podspec", interpreter: .regex("\\.version\\s*=\\s*\"(.*)\"")),
],
versionKind: "framework"
)
}
// checkProjectVersions()
// checkSwiftVersions

61
Package.resolved Normal file
View File

@@ -0,0 +1,61 @@
{
"object": {
"pins": [
{
"package": "Logger",
"repositoryURL": "https://github.com/shibapm/Logger",
"state": {
"branch": null,
"revision": "53c3ecca5abe8cf46697e33901ee774236d94cce",
"version": "0.2.3"
}
},
{
"package": "OctoKit",
"repositoryURL": "https://github.com/nerdishbynature/octokit.swift",
"state": {
"branch": null,
"revision": "f762f1566f7cd0e683b9329f169c28ab6ef993cc",
"version": "0.12.0"
}
},
{
"package": "RequestKit",
"repositoryURL": "https://github.com/nerdishbynature/RequestKit.git",
"state": {
"branch": null,
"revision": "8b0258ea2a4345cbcac90509b764faacea12efb0",
"version": "3.2.1"
}
},
{
"package": "Roxas",
"repositoryURL": "https://github.com/SideStore/Roxas.git",
"state": {
"branch": "swiftpm",
"revision": "fe142efb8b3e0330802aba3f44f508f712c0679f",
"version": null
}
},
{
"package": "danger-swift",
"repositoryURL": "https://github.com/danger/swift.git",
"state": {
"branch": null,
"revision": "579323889f26e6fb1ddb2cc5d98b1ab698bd2578",
"version": "3.14.2"
}
},
{
"package": "Version",
"repositoryURL": "https://github.com/mxcl/Version",
"state": {
"branch": null,
"revision": "1fe824b80d89201652e7eca7c9252269a1d85e25",
"version": "2.0.1"
}
}
]
},
"version": 1
}

212
Package.swift Normal file
View File

@@ -0,0 +1,212 @@
// swift-tools-version:5.6
import PackageDescription
// Version number can be found in Source/Danger/Danger.swift
// switch to false when release
let isDevelop = true
let devProducts: [Product] = isDevelop
? [
.library(name: "DangerDeps", type: .dynamic, targets: ["Danger-Swift"])
] : []
let devDependencies: [Package.Dependency] = isDevelop
? [
// .package(url: "https://github.com/shibapm/Komondor", from: "1.1.4"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.50.7"),
.package(url: "https://github.com/Realm/SwiftLint", branch: "main"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.10.0"),
// .package(url: "https://github.com/shibapm/Rocket", from: "1.2.1")
] : []
let devTargets: [Target] = isDevelop
? [
.testTarget(name: "DangerTests",
dependencies: [
"Danger",
"DangerFixtures",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
]),
.testTarget(name: "RunnerLibTests",
dependencies: [
"RunnerLib",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
], exclude: ["__Snapshots__"]),
.testTarget(name: "DangerDependenciesResolverTests",
dependencies: [
"DangerDependenciesResolver",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
],
exclude: ["__Snapshots__"]),
]
: []
let package = Package(
name: "danger-swift",
products: [
// .library(name: "DangerDeps[SideStore]", type: .dynamic, targets: ["DangerDependencies"]), // dev
.library(name: "SideStore", targets: ["SideStore", "SideStore-ObjC"]),
.library(name: "AltStoreCore", targets: ["AltStoreCore"]),
.library(name: "libimobiledevice", targets: ["libimobiledevice"]),
.library(name: "EmotionalDamage", targets: ["EmotionalDamage"]),
.library(name: "minimuxer", targets: ["minimuxer"]),
],
.library(name: "Danger", targets: ["Danger"]),
.library(name: "DangerFixtures", targets: ["DangerFixtures"]),
.executable(name: "danger-swift", targets: ["Runner"]),
] + devProducts,
dependencies: [
.package(url: "https://github.com/danger/swift.git", from: "3.0.0"), // dev
.package(url: "https://github.com/SideStore/Roxas.git", branch: "swiftpm"),
// Danger Plugins
// .package(url: "https://github.com/username/DangerPlugin.git", from: "0.1.0") // dev
],
.package(url: "https://github.com/shibapm/Logger", from: "0.1.0"),
.package(url: "https://github.com/mxcl/Version", from: "2.0.1"),
.package(name: "OctoKit", url: "https://github.com/nerdishbynature/octokit.swift", from: "0.12.0"),
] + devDependencies,
targets: [
// .target(name: "DangerDependencies", dependencies: ["Danger", "DangerPlugin"], path: "Dependencies/Danger"), // dev
.target(name: "SideStore",
dependencies: ["SideStore-ObjC", "AltStoreCore", "EmotionalDamage", "libimobiledevice", "minimuxer", "em_proxy"],
path: "AltStore",
exclude: ["Operations/Patch App/ALTAppPatcher.m"]),
.target(name: "SideStore-ObjC",
dependencies: ["Roxas"],
path: "AltStore",
sources: ["Operations/Patch App/ALTAppPatcher.m"],
publicHeadersPath: "Operations/Patch App/"),
.target(name: "AltStoreCore",
dependencies: ["AltStoreCore-ObjC"],
path: "AltStoreCore",
exclude: [
"Types/ALTAppPermission.m",
"Types/ALTPatreonBenefitType.m",
"Types/ALTSourceUserInfoKey.m"
]),
.target(name: "AltStoreCore-ObjC",
dependencies: ["Roxas"],
path: "AltStoreCore",
sources: ["Types/ALTAppPermission.m", "Types/ALTPatreonBenefitType.m", "Types/ALTSourceUserInfoKey.m"],
publicHeadersPath: "Types"),
.target(name: "EmotionalDamage",
dependencies: [""],
path: "EmotionalDamage"),
.target(name: "libimobiledevice",
dependencies: [""],
path: "Dependencies/libimobiledevice/src",
publicHeadersPath: "Dependencies/libimobiledevice/include/libimobiledevice"),
.binaryTarget( name: "minimuxer",
path: "Dependencies/minimuxer/target/release/minimuxer.xcframework"),
.binaryTarget( name: "em_proxy",
path: "Dependencies/em_proxy/target/release/em_proxy.xcframework"),
// name: "SideStore",
// // dependencies: [
// // .product(name: "RxSwift", package: "RxSwift")
// // ],
// path: "AltStore",
// exclude: ["Info.plist", "*.m"],
// cSettings: cSettings,
// cxxSettings: cxxSettings),
// .target(
// name: "PVLibrary-ObjC",
// // dependencies: [
// // .product(name: "RxSwift", package: "RxSwift")
// // ],
// path: "PVLibrary",
// exclude: ["Info.plist", "*.swift"],
// cSettings: cSettings,
// cxxSettings: cxxSettings),
]
.target(name: "Danger-Swift", dependencies: ["Danger"], plugins: [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]),
.target(name: "DangerShellExecutor"),
.target(name: "DangerDependenciesResolver", dependencies: ["DangerShellExecutor", "Version", "Logger"]),
.target(name: "Danger", dependencies: ["OctoKit", "Logger", "DangerShellExecutor"]),
.target(name: "RunnerLib", dependencies: ["Logger", "DangerShellExecutor", "Version"]),
.executableTarget(name: "Runner", dependencies: ["RunnerLib", "Logger", "DangerDependenciesResolver"]),
.target(name: "DangerFixtures", dependencies: ["Danger"]),
] + devTargets
)
// #if canImport(PackageConfig)
// import PackageConfig
// let config = PackageConfiguration([
// "komondor": [
// "pre-push": "swift test",
// "pre-commit": [
// "swift test",
// "swift test --generate-linuxmain",
// "swift run swiftformat .",
// "swift run swiftlint autocorrect --path Sources/",
// "git add ."
// ]
// ],
// "rocket": [
// "pre_release_checks": [
// "clean_git"
// ],
// "steps": [
// "Scripts/update_makefile.sh",
// "Scripts/update_danger_version.sh",
// "Scripts/update_changelog.sh",
// "Scripts/change_is_develop.sh false",
// "git_add",
// "commit",
// "tag",
// "push",
// "Scripts/change_is_develop.sh true",
// "git_add",
// ["commit": ["message": "Enable dev depdendencies"]],
// "push",
// "Scripts/create_homebrew_tap.sh"
// ]
// ]
// ]).write()
// #endif
// let package = Package(
// name: "SideStore",
// platforms: [
// .iOS(.v13),
// .tvOS(.v13),
// ],
// products: [
// .library(name: "DangerDeps[SideStore]", type: .dynamic, targets: ["DangerDependencies"]) // dev
// ],
// dependencies: [
// .package(url: "https://github.com/danger/swift.git", from: "3.0.0") // dev
// // Danger Plugins
// // .package(url: "https://github.com/username/DangerPlugin.git", from: "0.1.0") // dev
// ],
// targets: [
// .target(name: "DangerDependencies", dependencies: ["Danger", "DangerPlugin"]) // dev
// // name: "SideStore",
// // // dependencies: [
// // // .product(name: "RxSwift", package: "RxSwift")
// // // ],
// // path: "AltStore",
// // exclude: ["Info.plist", "*.m"],
// // cSettings: cSettings,
// // cxxSettings: cxxSettings),
// // .target(
// // name: "PVLibrary-ObjC",
// // // dependencies: [
// // // .product(name: "RxSwift", package: "RxSwift")
// // // ],
// // path: "PVLibrary",
// // exclude: ["Info.plist", "*.swift"],
// // cSettings: cSettings,
// // cxxSettings: cxxSettings),
// ]
// )