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

[Project] Initial Project Setup #1

Merged
merged 1 commit into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions .github/workflows/gha_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pull Request

on:
pull_request:
branches: [ master ]

jobs:
danger:
runs-on: ubuntu-latest
name: "🚫 Run Danger"
steps:
- uses: actions/checkout@v1
- run: npm install -g danger
- run: swift run danger-swift ci -c release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_SWIFT_GITHUB_TOKEN }}
LINUX_SOURCEKIT_LIB_PATH: /usr/share/swift/usr/lib

linux:
runs-on: ubuntu-latest
name: "🐧 Linux Test & Verify"
steps:
- uses: actions/checkout@v1
- run: npm install -g danger
- run: swift test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

macos:
runs-on: macos-11
name: " MacOS Test & Verify"
steps:
- uses: actions/checkout@v1
- run: npm install -g danger
- run: swift test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 changes: 6 additions & 90 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,90 +1,6 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
.DS_Store
/.build
build
/.swiftpm
/Packages
/*.xcodeproj
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.4
17 changes: 17 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
included:
- Sources
- Tests
excluded:
- Tests/**/XCTestManifests.swift # auto generated file
identifier_name:
excluded:
- ci
- id
- pr
line_length:
warning: 150 # Default 120
error: 300 # Default 200
ignores_comments: true
ignores_urls: true
disabled_rules:
- trailing_comma
39 changes: 39 additions & 0 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Danger
import Foundation

let danger = Danger()

if danger.git.createdFiles.count + danger.git.modifiedFiles.count - danger.git.deletedFiles.count > 300 {
warn("Big PR, try to keep changes smaller if you can")
}

let swiftFilesWithCopyright = danger.git.createdFiles.filter {
$0.fileType == .swift && danger.utils.readFile($0).contains("// Created by")
}

if swiftFilesWithCopyright.isEmpty == false {
let files = swiftFilesWithCopyright.joined(separator: ", ")
warn("In DangerSwiftCommitLint we don't include copyright headers, found them in: \(files)")
}

let filesToLint = (danger.git.modifiedFiles + danger.git.createdFiles)
.filter { URL(fileURLWithPath: $0).pathExtension == "swift" }

SwiftLint.lint(.files(filesToLint), inline: true)

// Only run GitHub related checks when GitHub dsl is available. This allows `danger-swift local` to work.
guard let github = danger.github else {
warn("Unable to parse GitHub DSL response, the GitHub related checks will be skipped. (i.e. running `danger-swift local`).")
exit(0)
}

// These checks only happen on a PR
let foundWIPMessageInTitle = github.pullRequest.title.contains("Work In Progress")
|| github.pullRequest.title.contains("WIP")
let foundWIPLabel = github.issue.labels.contains {
$0.name.contains("Work In Progress")
}

if foundWIPMessageInTitle || foundWIPLabel {
warn("PR is classed as Work in Progress")
}
151 changes: 151 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"object": {
"pins": [
{
"package": "Komondor",
"repositoryURL": "https://github.com/shibapm/Komondor",
"state": {
"branch": null,
"revision": "1bb467ad7ad57e94af82d73fa0fe063cb0b8ddd5",
"version": "1.1.0"
}
},
{
"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": "9521cdff919053868ab13cd08a228f7bc1bde2a9",
"version": "0.11.0"
}
},
{
"package": "PackageConfig",
"repositoryURL": "https://github.com/shibapm/PackageConfig.git",
"state": {
"branch": null,
"revision": "bf90dc69fa0792894b08a0b74cf34029694ae486",
"version": "0.13.0"
}
},
{
"package": "RequestKit",
"repositoryURL": "https://github.com/nerdishbynature/RequestKit.git",
"state": {
"branch": null,
"revision": "fd5e9e99aada7432170366c9e95967011ce13bad",
"version": "2.4.0"
}
},
{
"package": "Rocket",
"repositoryURL": "https://github.com/shibapm/Rocket",
"state": {
"branch": null,
"revision": "51a77ce5fa66c42715c14dcc542c01cd7a60fb27",
"version": "1.2.0"
}
},
{
"package": "ShellOut",
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
"state": {
"branch": null,
"revision": "e1577acf2b6e90086d01a6d5e2b8efdaae033568",
"version": "2.3.0"
}
},
{
"package": "SourceKitten",
"repositoryURL": "https://github.com/jpsim/SourceKitten.git",
"state": {
"branch": null,
"revision": "7f4be006fe73211b0fd9666c73dc2f2303ffa756",
"version": "0.31.0"
}
},
{
"package": "danger-swift",
"repositoryURL": "https://github.com/danger/swift",
"state": {
"branch": null,
"revision": "f743dd1ed76f4ae99a39f5a7acb4cfd60c6aaa71",
"version": "3.11.0"
}
},
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser.git",
"state": {
"branch": null,
"revision": "9564d61b08a5335ae0a36f789a7d71493eacadfc",
"version": "0.3.2"
}
},
{
"package": "SwiftFormat",
"repositoryURL": "https://github.com/nicklockwood/SwiftFormat",
"state": {
"branch": null,
"revision": "a9bdfd2548ebe518a693a5c6341d27c42b7e7a0a",
"version": "0.48.11"
}
},
{
"package": "SwiftLint",
"repositoryURL": "https://github.com/realm/SwiftLint",
"state": {
"branch": null,
"revision": "180d94132758dd183124ab1e63d6aa8e10023ec2",
"version": "0.43.1"
}
},
{
"package": "SwiftShell",
"repositoryURL": "https://github.com/kareman/SwiftShell",
"state": {
"branch": null,
"revision": "a6014fe94c3dbff0ad500e8da4f251a5d336530b",
"version": "5.1.0-beta.1"
}
},
{
"package": "SwiftyTextTable",
"repositoryURL": "https://github.com/scottrhoyt/SwiftyTextTable.git",
"state": {
"branch": null,
"revision": "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
"version": "0.9.0"
}
},
{
"package": "SWXMLHash",
"repositoryURL": "https://github.com/drmohundro/SWXMLHash.git",
"state": {
"branch": null,
"revision": "9183170d20857753d4f331b0ca63f73c60764bf3",
"version": "5.0.2"
}
},
{
"package": "Version",
"repositoryURL": "https://github.com/mxcl/Version",
"state": {
"branch": null,
"revision": "200046c93f6d5d78a6d72bfd9c0b27a95e9c0a2b",
"version": "1.2.0"
}
}
]
},
"version": 1
}
50 changes: 50 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// swift-tools-version:5.4

import PackageDescription

let package = Package(
name: "DangerSwiftCommitLint",
products: [
.library(name: "DangerSwiftCommitLint", targets: ["DangerSwiftCommitLint"]),
.library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]), // dev
],
dependencies: [
.package(name: "danger-swift", url: "https://github.com/danger/swift", from: "3.0.0"),
// Dev dependencies.
.package(url: "https://github.com/shibapm/Komondor", from: "1.0.0"), // dev
.package(url: "https://github.com/shibapm/Rocket", from: "1.2.0"), // dev
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.48.0"), // dev
.package(url: "https://github.com/realm/SwiftLint", from: "0.43.0"), // dev
],
targets: [
.target(name: "DangerDependencies", dependencies: [.product(name: "Danger", package: "danger-swift")]), // dev
.target(name: "DangerSwiftCommitLint", dependencies: [.product(name: "Danger", package: "danger-swift")]),
.testTarget(
name: "DangerSwiftCommitLintTests",
dependencies: [
"DangerSwiftCommitLint",
.product(name: "DangerFixtures", package: "danger-swift"),
]
),
]
)

#if canImport(PackageConfig)
import PackageConfig

let config = PackageConfiguration([
"komondor": [
"pre-commit": [
"swift test --generate-linuxmain",
"swift run swiftformat .",
"swift run swiftlint autocorrect --path Sources/",
"git add .",
],
],
"rocket": [
"after": [
"push",
],
],
]).write()
#endif
Loading