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

feat: danger #13

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: CI

on:
push:
branches: [ "main" ]
pull_request:

jobs:
test:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- name: Run tests
run: |
swift --version
swift test
- name: Danger
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
brew install danger/tap/danger-swift
cd Danger
swift run danger-swift ci --cwd ../
22 changes: 0 additions & 22 deletions .github/workflows/test.yml

This file was deleted.

145 changes: 145 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Last-Checked SwiftLint Version: x.y.z

# Configuration

allow_zero_lintable_files: true

# Overall Rules:

excluded: # paths to ignore during linting. Takes precedence over `included`.
# SwiftLint is using Darwin.glob to resolve file paths, and Darwin.glob simply doesn't support `"**"` as recursive path wildcard.
# https://github.com/realm/SwiftLint/issues/3586#issuecomment-1026861753
- "*/.build"
- ".build"
- "*/DerivedData"
- "Build"
- "DerivedData"
- "Carthage"
- "Pods"
- "vendor"
- "*/SupportingFiles"
- "Danger"
- "Tests"

disabled_rules:
# Rules below are just exceptions under scratch phase and should be re-enabled in the future.
- todo
- inclusive_language

opt_in_rules:
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- empty_collection_literal
- empty_count
- empty_string
- enum_case_associated_values_count
- extension_access_modifier
- fatal_error_message
- file_name
- file_name_no_space
- file_types_order
- first_where
- flatmap_over_map_reduce
- identical_operands
- implicitly_unwrapped_optional
# - indentation_width
- last_where
- legacy_multiple
- legacy_random
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- multiline_arguments_brackets
- multiline_literal_brackets
- multiline_parameters_brackets
- number_separator
- object_literal
- operator_usage_whitespace
- optional_enum_case_matching
- overridden_super_call
- prefer_self_type_over_type_of_self
- prefer_zero_over_explicit_init
- private_action
- private_outlet
- prohibited_super_call
- reduce_into
- single_test_class
- sorted_first_last
- static_operator
- switch_case_on_newline
- test_case_accessibility
- toggle_bool
# - type_contents_order # SwiftUI で init を body の前に置くため
- vertical_parameter_alignment_on_call
- vertical_whitespace_between_cases
- xct_specific_matcher
- yoda_condition

analyzer_rules:
- unused_declaration
- unused_import

# Single-Rule Configurations:

file_name:
excluded:
- Dangerfile.swift
suffix_pattern: "Extensions?|\\+.*"

force_try:
severity: warning

function_parameter_count:
warning: 7
error: 10

identifier_name:
max_length: 50
excluded:
- i
- x
- y
- id
- on
- to
- us
- at
- vc
- ok
- ci

line_length:
ignores_function_declarations: true
ignores_comments: true
warning: 175
error: 300

nesting:
type_level:
warning: 2
function_level:
warning: 5

trailing_comma:
mandatory_comma: true

trailing_whitespace:
ignores_empty_lines: true

number_separator:
minimum_length: 6

type_name:
max_length: 50

vertical_whitespace:
max_empty_lines: 3

cyclomatic_complexity:
ignores_case_statements: true
15 changes: 15 additions & 0 deletions Danger/Dangerfile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation
import Danger
import DangerSwiftEda

// MARK: - チェックルーチン
let danger = Danger()

// SwiftLint のワーニング等確認
SwiftLint.lint(.modifiedAndCreatedFiles(directory: nil), inline: true, swiftlintPath: .swiftPackage("$(pwd)/Danger"))

// PR ルーチンチェック
let configuration = GitHubFlow.Configuration(
suggestsChangeLogUpdate: .no
)
danger.eda.checkPR(workflow: GitHubFlow(configuration: configuration))
32 changes: 32 additions & 0 deletions Danger/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Dangerfile",
platforms: [.macOS("10.15")],
products: [
.library(
name: "DangerDepsProduct",
type: .dynamic,
targets: ["DangerDependencies"]
),
],
dependencies: [
.package(url: "https://github.com/realm/SwiftLint", from: "0.53.0"),
// Danger
.package(name: "danger-swift", url: "https://github.com/danger/swift.git", from: "3.17.1"),
novr marked this conversation as resolved.
Show resolved Hide resolved
// Danger Plugins
.package(name: "DangerSwiftEda", url: "https://github.com/yumemi-inc/danger-swift-eda", from: "0.2.0"),
],
targets: [
.target(
name: "DangerDependencies",
dependencies: [
.product(name: "Danger", package: "danger-swift"),
"DangerSwiftEda",
]
),
]
)
1 change: 1 addition & 0 deletions Danger/Sources/DangerDependencies/Fake.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Only in order to keep this directory tracked by git so SwiftPM can work
1 change: 1 addition & 0 deletions Danger/Sources/SwiftLintDependencies/Fake.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Only in order to keep this directory tracked by git so SwiftPM can work
15 changes: 15 additions & 0 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation
import Danger
import DangerSwiftEda // package: https://github.com/yumemi-inc/danger-swift-eda.git

// MARK: - チェックルーチン
let danger = Danger()

// SwiftLint のワーニング等確認
SwiftLint.lint(.modifiedAndCreatedFiles(directory: nil), inline: true)

// PR ルーチンチェック
let configuration = GitHubFlow.Configuration(
suggestsChangeLogUpdate: .no
)
danger.eda.checkPR(workflow: GitHubFlow(configuration: configuration))
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build](https://github.com/yumemi-inc/danger-swift-shoki/actions/workflows/test.yml/badge.svg)](https://github.com/yumemi-inc/danger-swift-shoki/actions/workflows/test.yml)
[![CI](https://github.com/yumemi-inc/danger-swift-shoki/actions/workflows/ci.yml/badge.svg)](https://github.com/yumemi-inc/danger-swift-shoki/actions/workflows/ci.yml)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fyumemi-inc%2Fdanger-swift-shoki%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/yumemi-inc/danger-swift-shoki)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fyumemi-inc%2Fdanger-swift-shoki%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/yumemi-inc/danger-swift-shoki)

Expand Down