Skip to content

Commit

Permalink
Migrate to Bitrise & Danger-Swift (#52)
Browse files Browse the repository at this point in the history
* Migrate to use Bitrise and Danger-Swift

* Make class final

* Update CI

* Reference master of WeTransfer-iOS-CI
  • Loading branch information
AvdLee authored Jan 28, 2020
1 parent ada293a commit ff1793c
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "Submodules/WeTransfer-iOS-CI"]
path = Submodules/WeTransfer-iOS-CI
url=https://github.com/WeTransfer/WeTransfer-iOS-CI.git
url = https://github.com/WeTransfer/WeTransfer-iOS-CI.git
branch = master
5 changes: 5 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://help.github.com/en/articles/about-code-owners
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence, they
# will be requested for review when someone opens a PR.
* @Boris-Em @kairadiagne @AvdLee
5 changes: 0 additions & 5 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
## Changelog

### Next
- Add charset utf-8 to html head

### 1.3.0
- Make sure to check whether there's enough space left to save new logs (#37)
- Added public static method `DiagnosticsLogger.isSetUp()` (#41)
Expand Down
4 changes: 4 additions & 0 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Danger
import WeTransferPRLinter

WeTransferPRLinter.lint()
2 changes: 1 addition & 1 deletion Diagnostics.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -z \"$CI\" ]; then\n if which swiftlint >/dev/null; then\n swiftlint --config \"${SRCROOT}/Submodules/WeTransfer-iOS-CI/SwiftLint/.swiftlint-source.yml\"\n swiftlint --config \"${SRCROOT}/Submodules/WeTransfer-iOS-CI/SwiftLint/.swiftlint-tests.yml\"\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n";
shellScript = "./Submodules/WeTransfer-iOS-CI/SwiftLint/swiftlint.sh\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
import Diagnostics

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
final class AppDelegate: UIResponder, UIApplicationDelegate {

enum ExampleError: Error {
case missingData
Expand All @@ -28,7 +28,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
do {
try DiagnosticsLogger.setup()
} catch {
// swiftlint:disable nslog_prohibited
print("Failed to setup the Diagnostics Logger")
}

Expand Down
15 changes: 2 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
# frozen_string_literal: true
source "https://rubygems.org"

# Needed for Fastlane & Danger
gem 'danger'
gem 'danger-junit'
gem 'danger-swiftlint'
gem 'danger-xcode_summary'
gem 'danger-xcov'
gem 'fastlane'
gem 'xcpretty'
gem 'xcpretty-json-formatter'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
ci_gems_path = File.join(File.dirname(__FILE__), "Submodules/WeTransfer-iOS-CI/Gemfile")
eval_gemfile(ci_gems_path) if File.exist?(ci_gems_path)
115 changes: 115 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.0)
claide (1.0.3)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
coderay (1.1.2)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (6.2.0)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (~> 0.9)
faraday-http-cache (~> 2.0)
git (~> 1.5)
kramdown (~> 2.0)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
danger-junit (1.0.0)
danger (> 2.0)
ox (~> 2.0)
danger-rubocop (0.7.1)
danger
rubocop
diff-lcs (1.3)
docile (1.1.5)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday-http-cache (2.0.0)
faraday (~> 0.8)
git (1.5.0)
json (2.3.0)
kramdown (2.1.0)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
method_source (0.9.2)
multipart-post (2.1.1)
nap (1.1.0)
no_proxy_fix (0.1.2)
octokit (4.15.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
ox (2.12.1)
parallel (1.19.1)
parser (2.7.0.2)
ast (~> 2.4.0)
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.3)
rainbow (2.2.2)
rake
rake (13.0.1)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.2)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.10.1)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.6.1)

PLATFORMS
ruby

DEPENDENCIES
danger
danger-junit
danger-rubocop
pry
rspec
rspec_junit_formatter (~> 0.2)
rubocop (~> 0.49.0)
simplecov (~> 0.12.0)

BUNDLED WITH
2.1.4
17 changes: 13 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
// We're hiding dev, test, and danger dependencies with // dev to make sure they're not fetched by users of this package.

import PackageDescription

Expand All @@ -9,8 +10,16 @@ let package = Package(name: "Diagnostics",
.iOS(.v10),
.tvOS(.v12),
.watchOS(.v6)],
products: [.library(name: "Diagnostics",
targets: ["Diagnostics"])],
targets: [.target(name: "Diagnostics",
path: "Sources")],
products: [
// dev .library(name: "DangerDeps", type: .dynamic, targets: ["DangerDependencies"]),
.library(name: "Diagnostics", targets: ["Diagnostics"])
],
dependencies: [
// dev .package(url: "https://github.com/danger/swift", from: "3.0.0"),
// dev .package(path: "Submodules/WeTransfer-iOS-CI/Danger-Swift")
],
targets: [
// dev .target(name: "DangerDependencies", dependencies: ["Danger", "WeTransferPRLinter"], path: "Submodules/WeTransfer-iOS-CI/Danger-Swift", sources: ["DangerFakeSource.swift"]),
.target(name: "Diagnostics", path: "Sources")
],
swiftLanguageVersions: [.v5])
2 changes: 0 additions & 2 deletions Sources/DiagnosticsReport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ public extension DiagnosticsReport {
let filePath = folderPath + filename
try? FileManager.default.createDirectory(atPath: folderPath, withIntermediateDirectories: true, attributes: nil)
guard FileManager.default.createFile(atPath: filePath, contents: data, attributes: [FileAttributeKey.type: mimeType.rawValue]) else {
// swiftlint:disable nslog_prohibited
print("Diagnostics Report could not be saved to: \(filePath)")
return
}

// swiftlint:disable nslog_prohibited
print("Diagnostics Report saved to: \(filePath)")
}
}
2 changes: 1 addition & 1 deletion Submodules/WeTransfer-iOS-CI
Submodule WeTransfer-iOS-CI updated 41 files
+7 −1 .gitignore
+0 −3 .rspec
+0 −7 .travis.yml
+ Assets/bitrise_env_vars.png
+ Assets/runscript.png
+46 −0 Bitrise/tag_releasing_bitrise.yml
+79 −0 Bitrise/testing_bitrise.yml
+5 −0 CODEOWNERS
+3 −3 Changelog.md
+6 −0 Danger-Swift/.gitignore
+3 −0 Danger-Swift/DangerFakeSource.swift
+28 −0 Danger-Swift/Package.swift
+37 −0 Danger-Swift/Sources/WeTransferPRLinter/CoverageReporter.swift
+24 −0 Danger-Swift/Sources/WeTransferPRLinter/SwiftLintExecutor.swift
+199 −0 Danger-Swift/Sources/WeTransferPRLinter/WeTransferPRLinter.swift
+59 −0 Danger-Swift/Sources/WeTransferPRLinter/XcodeSummaryReporter.swift
+33 −0 Danger-Swift/Tests/WeTransferPRLinterTests/TestHelpers/DangerTestExtensions.swift
+36 −0 Danger-Swift/Tests/WeTransferPRLinterTests/TestHelpers/Mocks.swift
+2,131 −0 Danger-Swift/Tests/WeTransferPRLinterTests/TestHelpers/TestGithubDSL.swift
+51 −0 Danger-Swift/Tests/WeTransferPRLinterTests/TestHelpers/TestXcodeSummaryJSON.swift
+331 −0 Danger-Swift/Tests/WeTransferPRLinterTests/WeTransferLinterTests.swift
+9 −0 Danger-Swift/Tests/WeTransferPRLinterTests/XCTestManifests.swift
+0 −17 Danger/.rubocop.yml
+0 −209 Danger/DangerTests.swift
+0 −112 Danger/Dangerfile
+0 −14 Danger/ext/.rubocop.yml
+0 −126 Danger/ext/git_swift_linter.rb
+0 −18 Dangerfile
+4 −0 Dangerfile.swift
+180 −11 Fastlane/Fastfile
+4 −8 Gemfile
+223 −0 Gemfile.lock
+19 −0 Package.swift
+101 −54 README.md
+0 −6 Scripts/travis.sh
+2 −9 SwiftLint/.swiftlint-source.yml
+2 −0 SwiftLint/.swiftlint-tests.yml
+11 −0 SwiftLint/swiftlint.sh
+0 −11 spec/.rubocop.yml
+0 −261 spec/git_swift_linter_spec.rb
+0 −37 spec/spec_helper.rb
36 changes: 4 additions & 32 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,11 @@
# Fastlane requirements
fastlane_version "1.109.0"
generated_fastfile_id "0121e253-f9e2-40ac-b489-f17f36e24ec6"

import "./../Submodules/WeTransfer-iOS-CI/Fastlane/Fastfile"

desc "Clean the derived data, run tests validate the changes"
desc "Run the tests and prepare for Danger"
lane :test do |options|
# Set timeout to prevent xcodebuild -list -project to take to much retries.
ENV["FASTLANE_XCODE_LIST_TIMEOUT"] = "120"

begin
ENV["XCPRETTY_JSON_FILE_OUTPUT"] = "build/reports/#{options[:scheme]}_Tests.json"
scan(
scheme: options[:project_name],
project: "#{options[:project_name]}.xcodeproj",
device: "iPhone 11",
code_coverage: true,
disable_concurrent_testing: true,
fail_build: false,
skip_slack: true,
clean: true,
formatter: "xcpretty-json-formatter",
xcargs: "-UseNewBuildSystem=YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO",
result_bundle: true,
output_directory: "build/reports/"
)
rescue => ex
UI.important("Tests failed for #{ex}")
end

begin
trainer(path: "build/reports/", output_directory: "build/reports/", extension: ".xml", fail_build: false)
rescue => ex
UI.important("Trainer report generation failed #{ex}")
end

validate_changes(project_name: options[:project_name])
test_project(
project_name: "Diagnostics",
scheme: "Diagnostics")
end
5 changes: 0 additions & 5 deletions fastlane/Pluginfile

This file was deleted.

0 comments on commit ff1793c

Please sign in to comment.