Skip to content

Commit

Permalink
RUMM-1204 Linter not run for carthage builds
Browse files Browse the repository at this point in the history
Linter works as a Xcode build phase only
If CARTHAGE flag is set for xcodebuild,
build phase is skipped
  • Loading branch information
buranmert committed Mar 26, 2021
1 parent 2b48044 commit afa856c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 57 deletions.
24 changes: 2 additions & 22 deletions Datadog/Datadog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2854,9 +2854,9 @@
buildConfigurationList = 61133B96242393DE00786299 /* Build configuration list for PBXNativeTarget "Datadog" */;
buildPhases = (
61133B7D242393DE00786299 /* Headers */,
61133C772423A4C300786299 /* ⚙️ Run linter */,
61133B7E242393DE00786299 /* Sources */,
61133B80242393DE00786299 /* Resources */,
61133C772423A4C300786299 /* ⚙️ Run linter */,
61569793256CF6C300C6AADA /* Frameworks */,
);
buildRules = (
Expand Down Expand Up @@ -2978,7 +2978,6 @@
61B7884F25C180CB002675B5 /* Headers */,
61B7885025C180CB002675B5 /* Sources */,
61B7885225C180CB002675B5 /* Resources */,
6170DC2325C18762003AED5C /* ⚙️ Run linter */,
61B7885125C180CB002675B5 /* Frameworks */,
);
buildRules = (
Expand Down Expand Up @@ -3170,26 +3169,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n";
showEnvVarsInLog = 0;
};
6170DC2325C18762003AED5C /* ⚙️ Run linter */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "⚙️ Run linter";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n";
shellScript = "if [ \"$CARTHAGE\" == \"YES\" ]; then\n echo \"Skipping linting for carthage build...\"\nelif which swiftlint >/dev/null; then\n echo \"Linting...\"\n \n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n";
showEnvVarsInLog = 0;
};
6170DC2425C18784003AED5C /* ⚙️ Run linter */ = {
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export DD_SDK_BASE_XCCONFIG

dependencies:
@echo "⚙️ Installing dependencies..."
@brew install swiftlint
@brew upgrade carthage
@carthage bootstrap --platform iOS --use-xcframeworks
@echo $$DD_SDK_BASE_XCCONFIG > xcconfigs/Base.local.xcconfig;
Expand Down
9 changes: 4 additions & 5 deletions Sources/Datadog/Datadog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ public class Datadog {
let bundleVersion = mainBundle.object(forInfoDictionaryKey: "CFBundleVersion") as? String
let bundleShortVersion = mainBundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String

self.init(
bundleType: mainBundle.bundlePath.hasSuffix(".appex") ? .iOSAppExtension : .iOSApp,
bundleIdentifier: mainBundle.bundleIdentifier,
bundleVersion: bundleShortVersion ?? bundleVersion,
bundleName: mainBundle.object(forInfoDictionaryKey: "CFBundleExecutable") as? String
self.init(bundleType: mainBundle.bundlePath.hasSuffix(".appex") ? .iOSAppExtension : .iOSApp,
bundleIdentifier: mainBundle.bundleIdentifier,
bundleVersion: bundleShortVersion ?? bundleVersion,
bundleName: mainBundle.object(forInfoDictionaryKey: "CFBundleExecutable") as? String
)
}

Expand Down
21 changes: 3 additions & 18 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workflows:
push_to_any_branch:
after_run:
- _make_dependencies
- run_linter
- run_check_tools
- run_unit_tests
- run_integration_tests
- check_dependency_managers
Expand All @@ -34,25 +34,10 @@ workflows:
steps:
- deploy-to-bitrise-io: {}

run_linter:
run_check_tools:
description: |-
Runs swiftlint and license check for all source and test files.
Runs internal tools to check the project.
steps:
- [email protected]:
title: Lint Sources/*
inputs:
- strict: 'yes'
- lint_config_file: "$BITRISE_SOURCE_DIR/tools/lint/sources.swiftlint.yml"
- linting_path: "$BITRISE_SOURCE_DIR"
- reporter: emoji
- [email protected]:
title: Lint Tests/*
is_always_run: true
inputs:
- strict: 'yes'
- linting_path: "$BITRISE_SOURCE_DIR"
- lint_config_file: "$BITRISE_SOURCE_DIR/tools/lint/tests.swiftlint.yml"
- reporter: emoji
- script:
title: Check license headers
is_always_run: true
Expand Down
14 changes: 4 additions & 10 deletions tools/lint/run-linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ if [ ! -f "Package.swift" ]; then
echo "\`run-linter.sh\` must be run in repository root folder: \`./tools/lint/run-linter.sh\`"; exit 1
fi

if [[ -z "${XCODE_VERSION_ACTUAL}" ]]; then
# when run from command line
set -e # exit with error code if `swiftlint lint` fails
swiftlint lint --config ./tools/lint/sources.swiftlint.yml --reporter "emoji" --strict
swiftlint lint --config ./tools/lint/tests.swiftlint.yml --reporter "emoji" --strict
else
# when run by Xcode in Build Phase
swiftlint lint --config ./tools/lint/sources.swiftlint.yml --reporter "xcode"
swiftlint lint --config ./tools/lint/tests.swiftlint.yml --reporter "xcode"
fi
set -e # exit with error code if `swiftlint lint` fails
# if CI fails due to linting, open the project and build Datadog target and you will see the error location
swiftlint lint --config ./tools/lint/sources.swiftlint.yml --reporter "xcode" --strict
swiftlint lint --config ./tools/lint/tests.swiftlint.yml --reporter "xcode" --strict
2 changes: 1 addition & 1 deletion tools/lint/sources.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of Swift Lint rules enforced for Swift code under `Sources/*` directory

whitelist_rules: # we enable lint rules explicitly - only the ones listed below are active
only_rules: # we enable lint rules explicitly - only the ones listed below are active
- attributes
- closing_brace
- closure_end_indentation
Expand Down
2 changes: 1 addition & 1 deletion tools/lint/tests.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of Swift Lint rules enforced for Swift code under `Tests/*` directory

whitelist_rules: # we enable lint rules explicitly - only the ones listed below are active
only_rules: # we enable lint rules explicitly - only the ones listed below are active
- attributes
- closing_brace
- closure_end_indentation
Expand Down

0 comments on commit afa856c

Please sign in to comment.