Skip to content

Commit

Permalink
Use swiftformat command instead of a bash script to format the project (
Browse files Browse the repository at this point in the history
#1597)

We aim to provide the same results for `swiftformat` running locally and
on CI

This change:
- removes internal format.sh script usage and relies on `swiftformat`
command itself that is running against project folder. By default it
uses `.swiftformat.yml` and this is exact behavior that helps us to
align with CI.
- splits Lint and Format build phase script into two: SwiftLint and
SwiftFormat. It could make CI debug easier
- removes linting and formatting steps from all targets but
`AdyenUIHost` (Demo app) and `AdyenSwiftUIHost` and appliy formatting to
the whole project.
  • Loading branch information
atmamont authored Mar 28, 2024
1 parent b8e2baf commit b5be51a
Show file tree
Hide file tree
Showing 780 changed files with 919 additions and 1,163 deletions.
1 change: 1 addition & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
--ranges nospace
--trimwhitespace nonblank-lines
--decimalgrouping none
--header "\nCopyright (c) {created.year} Adyen N.V.\n\nThis file is open source and available under the MIT license. See the LICENSE file for more info.\n"
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ opt_in_rules:

excluded:
- Tests
- UITests
- Internal
- Docs
- Demo
Expand Down
202 changes: 21 additions & 181 deletions Adyen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5441,7 +5441,6 @@
A04F8C1A29E5950100F3F62B /* Sources */,
A04F8C1B29E5950100F3F62B /* Frameworks */,
A04F8C1C29E5950100F3F62B /* Resources */,
A020EC5029E6F2C30050B2FE /* Format and lint */,
);
buildRules = (
);
Expand All @@ -5465,7 +5464,6 @@
E2C0E02F22097917008616F6 /* Sources */,
E2C0E03022097917008616F6 /* Frameworks */,
E2C0E03122097917008616F6 /* Resources */,
F9A4A3012373235800D774E8 /* Format and lint */,
);
buildRules = (
);
Expand Down Expand Up @@ -5508,7 +5506,6 @@
E2C0E05B220982AE008616F6 /* Sources */,
E2C0E05C220982AE008616F6 /* Frameworks */,
E2C0E05D220982AE008616F6 /* Resources */,
F9A4A302237323DE00D774E8 /* Format and lint */,
);
buildRules = (
);
Expand All @@ -5530,7 +5527,8 @@
E2C0E07A220B0399008616F6 /* Frameworks */,
E2C0E07B220B0399008616F6 /* Resources */,
E2C0E0A8220B0827008616F6 /* Embed Frameworks */,
F9A4A304237323EE00D774E8 /* Format and lint */,
F9A4A304237323EE00D774E8 /* SwiftFormat */,
B64285622BB45D4A005C88C7 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -5567,7 +5565,6 @@
E9B36CA72243B2FE00EAA368 /* Sources */,
E9B36CA82243B2FE00EAA368 /* Frameworks */,
E9B36CA92243B2FE00EAA368 /* Resources */,
F9A4A303237323E700D774E8 /* Format and lint */,
);
buildRules = (
);
Expand All @@ -5586,7 +5583,6 @@
F9175E51259393E800D653BE /* Sources */,
F9175E52259393E800D653BE /* Frameworks */,
F9175E53259393E800D653BE /* Resources */,
F9175E662593942E00D653BE /* Format and lint */,
);
buildRules = (
);
Expand All @@ -5609,7 +5605,6 @@
F9175F882594986900D653BE /* Sources */,
F9175F892594986900D653BE /* Frameworks */,
F9175F8A2594986900D653BE /* Resources */,
F9175F9F259498EA00D653BE /* Format and lint */,
);
buildRules = (
);
Expand All @@ -5631,7 +5626,6 @@
F92326A825A3669E002C5BC4 /* Sources */,
F92326A925A3669E002C5BC4 /* Frameworks */,
F92326AA25A3669E002C5BC4 /* Resources */,
E7388FC1260B68C400291DE7 /* Format and lint */,
);
buildRules = (
);
Expand All @@ -5651,7 +5645,6 @@
F92980A227CE2B33000CA5CA /* Sources */,
F92980A327CE2B33000CA5CA /* Frameworks */,
F92980A427CE2B33000CA5CA /* Resources */,
F92980C027CF5149000CA5CA /* Format and lint */,
);
buildRules = (
);
Expand Down Expand Up @@ -5693,7 +5686,6 @@
F95899C225FA524100E4113F /* Sources */,
F95899C325FA524100E4113F /* Frameworks */,
F95899C425FA524100E4113F /* Resources */,
E7388FC2260B68DE00291DE7 /* Format and lint */,
);
buildRules = (
);
Expand All @@ -5713,7 +5705,8 @@
F95B6D922527454E002C9062 /* Frameworks */,
F95B6D932527454E002C9062 /* Resources */,
F95B6DC52527565C002C9062 /* Embed Frameworks */,
F95B6DD2252B1F6A002C9062 /* Format and lint */,
F95B6DD2252B1F6A002C9062 /* SwiftFormat */,
B64285632BB4682A005C88C7 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -5767,7 +5760,6 @@
F9620D7E23C73B0D005209FC /* Sources */,
F9620D7F23C73B0D005209FC /* Frameworks */,
F9620D8023C73B0D005209FC /* Resources */,
F9620DA223C747BD005209FC /* Format and lint */,
);
buildRules = (
);
Expand Down Expand Up @@ -6084,7 +6076,7 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
A020EC5029E6F2C30050B2FE /* Format and lint */ = {
B64285622BB45D4A005C88C7 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
Expand All @@ -6094,16 +6086,16 @@
);
inputPaths = (
);
name = "Format and lint";
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
C96A8E2C26CA801E000BB8C6 /* Update Localization strings files */ = {
B64285632BB4682A005C88C7 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
Expand All @@ -6112,38 +6104,17 @@
inputFileListPaths = (
);
inputPaths = (
"",
);
name = "Update Localization strings files";
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
"",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/bin/bash\n\nif [ ! -f $SRCROOT/Internal/localization.sh ]; then\n exit 0\nfi\n\n$SRCROOT/Internal/localization.sh\n";
shellScript = "if [ -f $SRCROOT/Internal/swiftlint ]; then\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
E7388FC1260B68C400291DE7 /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
E7388FC2260B68DE00291DE7 /* Format and lint */ = {
C96A8E2C26CA801E000BB8C6 /* Update Localization strings files */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
Expand All @@ -6152,15 +6123,17 @@
inputFileListPaths = (
);
inputPaths = (
"",
);
name = "Format and lint";
name = "Update Localization strings files";
outputFileListPaths = (
);
outputPaths = (
"",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
shellScript = "#!/bin/bash\n\nif [ ! -f $SRCROOT/Internal/localization.sh ]; then\n exit 0\nfi\n\n$SRCROOT/Internal/localization.sh\n";
};
F91664F123E42D2D00C10738 /* AdyenUIHost configuration */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -6181,64 +6154,7 @@
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/post-commit ]; then\n $SRCROOT/Internal/post-commit\nfi\n";
};
F9175E662593942E00D653BE /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
F9175F9F259498EA00D653BE /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
F92980C027CF5149000CA5CA /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
F95B6DD2252B1F6A002C9062 /* Format and lint */ = {
F95B6DD2252B1F6A002C9062 /* SwiftFormat */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand All @@ -6247,14 +6163,14 @@
);
inputPaths = (
);
name = "Format and lint";
name = SwiftFormat;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/Demo\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/Demo\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
shellScript = "swiftformatPath=/usr/local/adyen/bin/swiftformat\n\nif [ ! -f $swiftformatPath ]; then\n echo \"swiftformat CLI is not installed on your machine at $swiftformatPath, please contact IS to install it for you at /usr/local/adyen/bin/ .\"\n exit\nfi\n \n$swiftformatPath $SRCROOT\n";
};
F9615FBC252DE30B00FA8EDD /* AdyenSwiftUI configuration */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -6275,25 +6191,6 @@
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/post-commit ]; then\n $SRCROOT/Internal/post-commit\nfi\n";
};
F9620DA223C747BD005209FC /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
F986B551285B4208002A471C /* Update the LocalizationKey.swift file */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand All @@ -6315,64 +6212,7 @@
shellPath = /bin/sh;
shellScript = "#!/bin/bash\n\nif [ ! -f $SRCROOT/Internal/generate_localization_keys.swift ]; then\n exit 0\nfi\n\nif [ ! -z $(git diff HEAD --name-only $SCRIPT_INPUT_FILE_0) ]\nthen\n echo \"Detected changes in Localizable.strings. Generating new LocalizationKey.swift\"\n swift $SRCROOT/Internal/generate_localization_keys.swift $SCRIPT_INPUT_FILE_0 $SCRIPT_OUTPUT_FILE_0\nfi\n";
};
F9A4A3012373235800D774E8 /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
F9A4A302237323DE00D774E8 /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
F9A4A303237323E700D774E8 /* Format and lint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Format and lint";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/$TARGETNAME\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/$TARGETNAME\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
};
F9A4A304237323EE00D774E8 /* Format and lint */ = {
F9A4A304237323EE00D774E8 /* SwiftFormat */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
Expand All @@ -6382,14 +6222,14 @@
);
inputPaths = (
);
name = "Format and lint";
name = SwiftFormat;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ -f $SRCROOT/Internal/format.sh ]; then\n $SRCROOT/Internal/format.sh \"$SRCROOT/Demo\"\nfi\n\nif [ -f $SRCROOT/Internal/swiftlint ]; then\n cd \"$SRCROOT/Demo\"\n $SRCROOT/Internal/swiftlint --config \"$SRCROOT/.swiftlint.yml\"\nfi\n";
shellScript = "swiftformatPath=/usr/local/adyen/bin/swiftformat\n\nif [ ! -f $swiftformatPath ]; then\n echo \"swiftformat CLI is not installed on your machine at $swiftformatPath, please contact IS to install it for you at /usr/local/adyen/bin/ .\"\n exit\nfi\n \n$swiftformatPath $SRCROOT\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
Loading

0 comments on commit b5be51a

Please sign in to comment.