Skip SwiftLint and SwiftFormat runs on CI build
Unfortunately, there seems to be no simpler way to tell a script in Xcode that it runs on CI.
This commit is contained in:
parent
ea304f963c
commit
9b38cc0437
5 changed files with 62 additions and 8 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -69,3 +69,8 @@ fastlane/Preview.html
|
||||||
fastlane/screenshots
|
fastlane/screenshots
|
||||||
fastlane/test_output
|
fastlane/test_output
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
#
|
||||||
|
# The Continuous Integration environment will create this file. It avoids specific "Run Script" phases while building.
|
||||||
|
.ci-env
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,10 @@ addons:
|
||||||
- go
|
- go
|
||||||
- gnupg2
|
- gnupg2
|
||||||
- pass
|
- pass
|
||||||
- swiftformat
|
|
||||||
- swiftlint
|
|
||||||
update: true
|
update: true
|
||||||
before_install:
|
before_install:
|
||||||
- echo -e "machine github.com\n login $GITHUB_ACCESS_TOKEN" >> ~/.netrc
|
- echo -e "machine github.com\n login $GITHUB_ACCESS_TOKEN" >> ~/.netrc
|
||||||
|
- touch .ci-env
|
||||||
install:
|
install:
|
||||||
- gem install bundler
|
- gem install bundler
|
||||||
- bundle install
|
- bundle install
|
||||||
|
|
|
||||||
|
|
@ -1051,8 +1051,8 @@
|
||||||
A26700191EEC450100176B8A /* Embed App Extensions */,
|
A26700191EEC450100176B8A /* Embed App Extensions */,
|
||||||
A26075921EEC6F34005DB03E /* Embed Frameworks */,
|
A26075921EEC6F34005DB03E /* Embed Frameworks */,
|
||||||
9AF6A4F532EB900EE22C80EA /* [CP] Embed Pods Frameworks */,
|
9AF6A4F532EB900EE22C80EA /* [CP] Embed Pods Frameworks */,
|
||||||
3005F34F24A9143C000519B5 /* ShellScript */,
|
3005F34F24A9143C000519B5 /* SwiftFormat */,
|
||||||
308800C124EB0D3600E87ED3 /* ShellScript */,
|
308800C124EB0D3600E87ED3 /* SwiftLint */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
|
|
@ -1279,7 +1279,7 @@
|
||||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||||
showEnvVarsInLog = 0;
|
showEnvVarsInLog = 0;
|
||||||
};
|
};
|
||||||
3005F34F24A9143C000519B5 /* ShellScript */ = {
|
3005F34F24A9143C000519B5 /* SwiftFormat */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
|
@ -1288,15 +1288,16 @@
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
);
|
);
|
||||||
|
name = SwiftFormat;
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
);
|
);
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "SWIFTFORMAT_VERSION=\"0.45.*\"\n\nif which swiftformat > /dev/null; then\n if [[ \"$(swiftformat --version)\" == $SWIFTFORMAT_VERSION ]]; then\n swiftformat .\n else\n echo \"Failure: SwiftFormat $SWIFTFORMAT_VERSION is required. Install it or update the build script to use a newer version.\"\n exit 1\n fi\nelse\n echo \"Failure: SwiftFormat not installed. Get it via 'brew install swiftformat'.\"\n exit 2\nfi\n";
|
shellScript = ". \"${SRCROOT}/scripts/swiftformat.sh\"\n";
|
||||||
};
|
};
|
||||||
308800C124EB0D3600E87ED3 /* ShellScript */ = {
|
308800C124EB0D3600E87ED3 /* SwiftLint */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
|
@ -1305,13 +1306,14 @@
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
);
|
);
|
||||||
|
name = SwiftLint;
|
||||||
outputFileListPaths = (
|
outputFileListPaths = (
|
||||||
);
|
);
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "SWIFTLINT_VERSION=\"0.40.*\"\n\nif which swiftlint > /dev/null; then\n if [[ \"$(swiftlint version)\" == $SWIFTLINT_VERSION ]]; then\n swiftlint\n else\n echo \"Failure: SwiftLint $SWIFTLINT_VERSION is required. Install it or update the build script to use a newer version.\"\n exit 1\n fi\nelse\n echo \"Failure: SwiftLint not installed. Get it via 'brew install swiftlint'.\"\n exit 2\nfi\n";
|
shellScript = ". \"${SRCROOT}/scripts/swiftlint.sh\"\n";
|
||||||
};
|
};
|
||||||
3EFC287772C1D2B2762FAC45 /* [CP] Check Pods Manifest.lock */ = {
|
3EFC287772C1D2B2762FAC45 /* [CP] Check Pods Manifest.lock */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
|
|
||||||
24
scripts/swiftformat.sh
Executable file
24
scripts/swiftformat.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
SWIFTFORMAT_VERSION="0.45.*"
|
||||||
|
|
||||||
|
if [[ -f "${SRCROOT}/.ci-env" ]]; then
|
||||||
|
echo "Running in a Continuous Integration environment. Formatting is skipped."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${CONFIGURATION}" != "Debug" ]]; then
|
||||||
|
echo "Running during a release build. Formatting is skipped."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if which swiftformat > /dev/null; then
|
||||||
|
if [[ "$(swiftformat --version)" == $SWIFTFORMAT_VERSION ]]; then
|
||||||
|
swiftformat .
|
||||||
|
else
|
||||||
|
echo "Failure: SwiftFormat $SWIFTFORMAT_VERSION is required. Install it or update the build script to use a newer version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Failure: SwiftFormat not installed. Get it via 'brew install swiftformat'."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
24
scripts/swiftlint.sh
Executable file
24
scripts/swiftlint.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
SWIFTLINT_VERSION="0.40.*"
|
||||||
|
|
||||||
|
if [[ -f "${SRCROOT}/.ci-env" ]]; then
|
||||||
|
echo "Running in a Continuous Integration environment. Linting is skipped."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${CONFIGURATION}" != "Debug" ]]; then
|
||||||
|
echo "Running during a release build. Linting is skipped."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if which swiftlint > /dev/null; then
|
||||||
|
if [[ "$(swiftlint version)" == $SWIFTLINT_VERSION ]]; then
|
||||||
|
swiftlint --strict
|
||||||
|
else
|
||||||
|
echo "Failure: SwiftLint $SWIFTLINT_VERSION is required. Install it or update the build script to use a newer version."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Failure: SwiftLint not installed. Get it via 'brew install swiftlint'."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue