Skip to content
Open
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
19 changes: 19 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ jobs:
lint_markdown_files:
uses: ./.github/workflows/lint_markdown.yml

# Errors fail the job; warnings are reported but don't (Sources only, like the DemoSwiftApp build phase)
swiftlint:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
SWIFTLINT_VERSION: 0.65.1
# sha256 of swiftlint_linux_amd64.zip for the version above; update both together
SWIFTLINT_SHA256: caeed6f4a679c35539ffaf124f6c4ab4a8416917f7d8796279dc52b74026059d
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download SwiftLint
run: |
curl -fsSL -o swiftlint.zip "https://github.com/realm/SwiftLint/releases/download/$SWIFTLINT_VERSION/swiftlint_linux_amd64.zip"
echo "$SWIFTLINT_SHA256 swiftlint.zip" | sha256sum -c -
unzip -q swiftlint.zip swiftlint-static -d .swiftlint-bin
- run: .swiftlint-bin/swiftlint-static Sources --reporter github-actions-logging

integration_tests:
# ci-helper-tools' trigger script only understands push and pull_request events
if: github.event_name != 'workflow_dispatch'
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ We welcome contributions and feedback! All contributors must sign our [Contribut
1. Create a branch off of `master`: `git checkout -b YOUR_NAME/branch_name`.
2. Commit your changes. We follow the [commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines) from Angular.
3. Make sure to add tests!
4. Run `swift build` and SwiftLint ([install via Homebrew](https://github.com/realm/SwiftLint#installation): `brew install swiftlint`).
4. Run `swift build` and SwiftLint ([install via Homebrew](https://github.com/realm/SwiftLint#installation): `brew install swiftlint`). CI pins SwiftLint 0.65.1, so a different local version may report different results.
5. Run the relevant `xcodebuild test -project OptimizelySwiftSDK.xcodeproj ...` commands for the platforms you changed.
6. `git push` your changes to GitHub.
7. Make sure that all unit tests are passing and that there are no merge conflicts between your branch and `master`.
Expand Down
1 change: 1 addition & 0 deletions Sources/Implementation/DefaultDecisionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,18 @@
var variation: Variation?
var cmabError: Bool = false
var cmabUUID: String?
var holdout: ExperimentCore? = nil // If variation came from a holdout, store the holdout here

Check warning on line 49 in Sources/Implementation/DefaultDecisionService.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Optional should be implicitly initialized without nil (implicit_optional_initialization)
}

struct DeliveryRuleDecision {
var variation: Variation?
var skipToEveryoneElse: Bool
var holdout: ExperimentCore? = nil // If variation came from a holdout, store the holdout here

Check warning on line 55 in Sources/Implementation/DefaultDecisionService.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Optional should be implicitly initialized without nil (implicit_optional_initialization)
}

typealias UserProfile = OPTUserProfileService.UPProfile

// swiftlint:disable:next type_body_length
class DefaultDecisionService: OPTDecisionService {
let bucketer: OPTBucketer
let userProfileService: OPTUserProfileService
Expand Down Expand Up @@ -146,12 +147,12 @@
let response = cmabService.getDecision(config: config, userContext: user, ruleId: experiment.id, options: options ?? [])
var cmabDecision: CmabDecision?
switch response {
case .success(let decision):

Check warning on line 150 in Sources/Implementation/DefaultDecisionService.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Case statements should vertically aligned with their closing brace (switch_case_alignment)
cmabDecision = decision
let info = LogMessage.cmabFetchSuccess(decision.variationId, decision.cmabUUID, _expKey: experiment.key)
self.logger.d(info)
reasons.addInfo(info)
case .failure:

Check warning on line 155 in Sources/Implementation/DefaultDecisionService.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Case statements should vertically aligned with their closing brace (switch_case_alignment)
let info = LogMessage.cmabFetchFailed(experiment.key)
self.logger.e(info)
reasons.addError(info)
Expand Down Expand Up @@ -193,7 +194,7 @@
// isAsync to `false` for backward compatibility
let response = getVariation(config: config, experiment: experiment, user: user, isAsync: false, userProfileTracker: profileTracker)

if (!ignoreUPS) {

Check warning on line 197 in Sources/Implementation/DefaultDecisionService.swift

View workflow job for this annotation

GitHub Actions / swiftlint

`if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses (control_statement)
profileTracker?.save()
}

Expand Down Expand Up @@ -861,14 +862,14 @@
return LogMessage.evaluatingAudiencesCombined(evType, finalLoggingKey, Utils.getConditionString(conditions: conditions)).description
}
switch conditions {
case .array(let arrConditions):

Check warning on line 865 in Sources/Implementation/DefaultDecisionService.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Case statements should vertically aligned with their closing brace (switch_case_alignment)
if arrConditions.count > 0 {
result = try conditions.evaluate(project: config.project, user: user)
} else {
// empty conditions (backward compatibility with "audienceIds" is ignored if exists even though empty
result = true
}
case .leaf:

Check warning on line 872 in Sources/Implementation/DefaultDecisionService.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Case statements should vertically aligned with their closing brace (switch_case_alignment)
result = try conditions.evaluate(project: config.project, user: user)
default:
result = true
Expand Down
1 change: 1 addition & 0 deletions Sources/Optimizely/OptimizelyClient+ObjC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ extension OptimizelyClient {
}

// MARK: - ObjC protocols
// swiftlint:disable:next type_name
@objc(OPTEventDispatcher) public protocol _ObjcOPTEventDispatcher {
func dispatchEvent(event: EventForDispatch, completionHandler: ((Data?, NSError?) -> Void)?)

Expand Down
Loading