Skip to content

Commit

Permalink
Add vale linting as a build step in Xcode
Browse files Browse the repository at this point in the history
- Add script calling Vale. If vale is not available, pass successful.
- Add docusaurus as a folder tothe xcode project, making sure it is not part of any targets. This allows error reporting to be shown in Xcode
- Add a template file containing an output config that Xcode can interpret
  • Loading branch information
jeroenleenarts committed Apr 3, 2023
1 parent ecf4c4d commit 89ed43a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .styles/xcode-line.tmpl
@@ -0,0 +1,6 @@
{{range .Files}}
{{- $path := .Path -}}
{{- range .Alerts -}}
{{$path}}:{{.Line}}:{{index .Span 0}}: {{.Severity}}: {{.Check}}:{{.Message}}
{{end -}}
{{end -}}
22 changes: 22 additions & 0 deletions StreamChat.xcodeproj/project.pbxproj
Expand Up @@ -2444,6 +2444,7 @@
43F4750B26F4E4FF0009487D /* ChatMessageReactionItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageReactionItemView.swift; sourceTree = "<group>"; };
43F4750D26FB247C0009487D /* ChatReactionPickerReactionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatReactionPickerReactionsView.swift; sourceTree = "<group>"; };
4A4E184528D06CA30062378D /* Documentation.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = Documentation.docc; sourceTree = "<group>"; };
4A51230029D3170C005CEA9B /* docusaurus */ = {isa = PBXFileReference; lastKnownFileType = folder; path = docusaurus; sourceTree = "<group>"; };
640FE0D426A568C3006CE703 /* ListChangeIndexPathResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListChangeIndexPathResolver.swift; sourceTree = "<group>"; };
640FE0F526A57903006CE703 /* ListChangeIndexPathResolver_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListChangeIndexPathResolver_Tests.swift; sourceTree = "<group>"; };
6428DD5426201DCC0065DA1D /* BannerShowingConnectionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BannerShowingConnectionDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5232,6 +5233,7 @@
8AD5EC8522E9A3E8005CFAC9 = {
isa = PBXGroup;
children = (
4A51230029D3170C005CEA9B /* docusaurus */,
4A4E184528D06CA30062378D /* Documentation.docc */,
AD9BE32526680E4200A6D284 /* Stream.playground */,
792E3D6A25C97D920040B0C2 /* Package.swift */,
Expand Down Expand Up @@ -8141,6 +8143,7 @@
799C9418247D2F80001F1104 /* Frameworks */,
799C9419247D2F80001F1104 /* Resources */,
E3C7A0E42858BB10006133C3 /* SwiftLint */,
4A5122FF29D30BE0005CEA9B /* Run Vale */,
);
buildRules = (
);
Expand Down Expand Up @@ -8779,6 +8782,25 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
4A5122FF29D30BE0005CEA9B /* Run Vale */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Run Vale";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n./bin/vale-lint.sh\n";
};
88F0D6EB257E40B300F4B050 /* SwiftGen */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down
17 changes: 17 additions & 0 deletions bin/vale-lint.sh
@@ -0,0 +1,17 @@
if ! which vale >/dev/null; then
if ! which brew >/dev/null; then # If it's not found, check the Homebrew location and update PATH when needed
if test -e "/usr/local/bin/brew"; then # Default Homebrew location (pre M1 era)
PATH="${PATH}:/usr/local/bin"
elif test -e "/opt/homebrew/bin/brew"; then # Default Homebrew location (M1 era)
PATH="${PATH}:/opt/homebrew/bin"
else
echo "warning: Homebrew not found at default location"
fi
fi
fi

if which vale >/dev/null; then
vale --output=./.styles/xcode-line.tmpl docusaurus
else
echo "warning: Vale not installed, download from https://vale.sh"
fi

0 comments on commit 89ed43a

Please sign in to comment.