Skip to content

Commit 7ddc333

Browse files
committed
ci: add CI/CD pipeline actions
1 parent 2b6c8c7 commit 7ddc333

File tree

10 files changed

+255
-20
lines changed

10 files changed

+255
-20
lines changed

.github/FUNDING.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [soumyamahunt] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
enable-beta-ecosystems: true
3+
updates:
4+
# - package-ecosystem: swift-package
5+
# directory: /
6+
# schedule:
7+
# interval: weekly
8+
# commit-message:
9+
# prefix: 'deps: '
10+
11+
- package-ecosystem: github-actions
12+
directory: /
13+
schedule:
14+
interval: monthly
15+
commit-message:
16+
prefix: 'ci(Deps): '
17+
18+
- package-ecosystem: npm
19+
directory: /
20+
schedule:
21+
interval: monthly
22+
commit-message:
23+
prefix: 'ci(Deps): '

.github/workflows/main.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
# schedule:
9+
# - cron: '0 0 * * *'
10+
workflow_dispatch:
11+
inputs:
12+
release:
13+
description: Create release
14+
required: false
15+
type: boolean
16+
version:
17+
description: New version to release
18+
required: false
19+
type: string
20+
21+
concurrency:
22+
group: ci/cd-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
# analyze:
27+
# name: Analyze
28+
# if: github.event_name != 'workflow_dispatch'
29+
# uses: SwiftyLab/ci/.github/workflows/codeql-analysis.yml@main
30+
# permissions:
31+
# actions: read
32+
# contents: read
33+
# security-events: write
34+
35+
# spell-check:
36+
# name: Run spell check
37+
# runs-on: ubuntu-latest
38+
# steps:
39+
# - name: Checkout repository
40+
# uses: actions/checkout@v3
41+
42+
# - name: Spellcheck Action
43+
# uses: rojopolis/[email protected]
44+
# with:
45+
# config_path: .github/config/spellcheck.yml
46+
47+
swift-package-test:
48+
name: Swift Package
49+
uses: SwiftyLab/ci/.github/workflows/swift-package.yml@main
50+
secrets: inherit
51+
with:
52+
codecov-swift: '5.7'
53+
codecov-os: ubuntu-latest
54+
matrix: >
55+
{
56+
"include": [
57+
{
58+
"os": "ubuntu-latest",
59+
"swift": "5.7"
60+
},
61+
{
62+
"os": "ubuntu-latest",
63+
"swift": "5.2"
64+
}
65+
]
66+
}
67+
# {
68+
# "os": "macos-12",
69+
# "xcode": "latest-stable",
70+
# "swift": "5.6"
71+
# },
72+
# {
73+
# "os": "windows-latest",
74+
# "swift": "5.6"
75+
# },
76+
# {
77+
# "os": "windows-latest",
78+
# "swift": "5.3"
79+
# }
80+
81+
cocoapods-test:
82+
name: CocoaPods
83+
uses: SwiftyLab/ci/.github/workflows/cocoapods.yml@main
84+
with:
85+
matrix: >
86+
{
87+
"include": [
88+
{
89+
"os": "macos-12",
90+
"xcode": "13.4",
91+
"platform": "macos"
92+
},
93+
{
94+
"os": "macos-12",
95+
"xcode": "13.4",
96+
"platform": "watchos"
97+
},
98+
{
99+
"os": "macos-12",
100+
"xcode": "13.4",
101+
"platform": "tvos"
102+
},
103+
{
104+
"os": "macos-12",
105+
"xcode": "13.4",
106+
"platform": "ios"
107+
}
108+
]
109+
}
110+
111+
xcode-test:
112+
name: Xcode
113+
uses: SwiftyLab/ci/.github/workflows/xcode.yml@main
114+
with:
115+
matrix: >
116+
{
117+
"include": [
118+
{
119+
"os": "macos-10.15",
120+
"xcode": "11.3.1",
121+
"platform": "macOS"
122+
},
123+
{
124+
"os": "macos-10.15",
125+
"xcode": "11.3.1",
126+
"platform": "watchOS"
127+
},
128+
{
129+
"os": "macos-10.15",
130+
"xcode": "11.3.1",
131+
"platform": "tvOS"
132+
},
133+
{
134+
"os": "macos-10.15",
135+
"xcode": "11.3.1",
136+
"platform": "iOS"
137+
},
138+
{
139+
"os": "macos-10.15",
140+
"xcode": "11.3.1",
141+
"platform": "mac-catalyst"
142+
}
143+
]
144+
}
145+
146+
ci:
147+
name: CI
148+
if: github.event_name == 'push'
149+
needs: [swift-package-test, xcode-test, cocoapods-test]
150+
# needs: [analyze, swift-package-test, xcode-test, cocoapods-test]
151+
uses: SwiftyLab/ci/.github/workflows/ci.yml@main
152+
153+
cd:
154+
name: CD
155+
if: |
156+
(github.event_name == 'push' && needs.ci.outputs.release == 'true') ||
157+
(always() &&
158+
github.event_name == 'workflow_dispatch' &&
159+
github.event.inputs.release == 'true' &&
160+
needs.swift-package-test.result == 'success' &&
161+
needs.xcode-test.result == 'success' &&
162+
needs.cocoapods-test.result == 'success' &&
163+
(needs.ci.result == 'success' || needs.ci.result == 'skipped'))
164+
# (needs.analyze.result == 'success' || needs.analyze.result == 'skipped')
165+
needs: [ci, swift-package-test, xcode-test, cocoapods-test]
166+
# needs: [ci, analyze, swift-package-test, xcode-test, cocoapods-test]
167+
uses: SwiftyLab/ci/.github/workflows/cd.yml@main
168+
with:
169+
os: macos-12
170+
version: ${{ github.event.inputs.version }}
171+
secrets:
172+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

Package.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ let package = Package(
99
.macOS(.v10_10),
1010
.tvOS(.v9),
1111
.watchOS(.v2),
12-
.macCatalyst(.v13)
1312
],
1413
products: [
1514
.library(name: "ValidatableKit", targets: ["ValidatableKit"]),

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let package = Package(
99
.macOS(.v10_10),
1010
.tvOS(.v9),
1111
.watchOS(.v2),
12-
.macCatalyst(.v13)
12+
.macCatalyst(.v13),
1313
],
1414
products: [
1515
.library(name: "ValidatableKit", targets: ["ValidatableKit"]),

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let package = Package(
1212
.macOS(.v10_10),
1313
.tvOS(.v9),
1414
.watchOS(.v2),
15-
.macCatalyst(.v13)
15+
.macCatalyst(.v13),
1616
],
1717
products: [
1818
.library(name: "ValidatableKit", targets: ["ValidatableKit"]),

[email protected]

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// swift-tools-version: 5.7
2+
3+
import PackageDescription
4+
5+
let github = "https://github.com"
6+
let appleGitHub = "\(github)/apple"
7+
8+
let package = Package(
9+
name: "ValidatableKit",
10+
platforms: [
11+
.iOS(.v8),
12+
.macOS(.v10_10),
13+
.tvOS(.v9),
14+
.watchOS(.v2),
15+
.macCatalyst(.v13),
16+
],
17+
products: [
18+
.library(name: "ValidatableKit", targets: ["ValidatableKit"]),
19+
],
20+
dependencies: [
21+
.package(url: "\(appleGitHub)/swift-docc-plugin", from: "1.0.0"),
22+
.package(url: "\(appleGitHub)/swift-format", from: "0.50700.0"),
23+
],
24+
targets: [
25+
.target(name: "ValidatableKit", dependencies: []),
26+
.testTarget(name: "ValidatableKitTests", dependencies: ["ValidatableKit"]),
27+
],
28+
swiftLanguageVersions: [.v5]
29+
)

Sources/ValidatableKit/Validations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Validations<T> {
1212
[:]
1313

1414
public var isFailure: Bool {
15-
return self.results.first(where: \.value.isFailure) != nil
15+
return self.results.first { $1.isFailure } != nil
1616
}
1717

1818
public var successDescriptions: [String] {

Sources/ValidatableKit/Validators/Regex.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#if canImport(RegexBuilder)
1+
#if canImport(_StringProcessing)
2+
import _StringProcessing
3+
24
public extension Validator
35
where T: BidirectionalCollection, T.SubSequence == Substring {
46
/// Validates whether current string matches provided regular expression
@@ -29,7 +31,7 @@ where T: BidirectionalCollection, T.SubSequence == Substring {
2931
case .custom(let matcher):
3032
match = matcher($0, regex)
3133
}
32-
guard let match = match else {
34+
guard match != nil else {
3335
return ValidatorResults.Regex(matched: false)
3436
}
3537

@@ -39,7 +41,7 @@ where T: BidirectionalCollection, T.SubSequence == Substring {
3941
},
4042
&&
4143
)
42-
return validator.validate(match.output)
44+
return validator.validate(match!.output)
4345
}
4446
}
4547
}

Tests/ValidatableKitTests/RegexValidatorTests.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#if canImport(RegexBuilder)
1+
#if canImport(_StringProcessing) && canImport(RegexBuilder)
22
import XCTest
33
import RegexBuilder
4+
import _StringProcessing
45
@testable import ValidatableKit
56

67
@available(swift 5.7)
@@ -103,22 +104,18 @@ final class RegexValidatorTests: XCTestCase {
103104
let regex = Regex {
104105
"name:"
105106
OneOrMore(" ")
106-
Capture {
107-
OneOrMore {
108-
CharacterClass(.digit, .word, .whitespace)
109-
}
110-
} transform: {
111-
String($0)
112-
}
107+
Capture(
108+
{ OneOrMore { CharacterClass(.digit, .word, .whitespace) } },
109+
transform: { String($0) }
110+
)
113111
","
114112
OneOrMore(" ")
115113
"user_id:"
116114
OneOrMore(" ")
117-
TryCapture {
118-
OneOrMore(.digit)
119-
} transform: {
120-
Int($0)
121-
}
115+
TryCapture(
116+
{ OneOrMore(.digit) },
117+
transform: { Int($0) }
118+
)
122119
}
123120

124121
let successResult = Validator<String>.matching(

0 commit comments

Comments
 (0)