summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2022-04-05 14:40:13 +0200
committerAndrej Mihajlov <and@mullvad.net>2022-08-03 15:13:33 +0200
commite6addcb8d673312b20ead6f3229a42c14da69934 (patch)
tree2d87106ceb42cec49f28b6c39b1576bda8f0d60d
parent8a094005ac3e1289e416cf2d85fd47b2904505cf (diff)
downloadmullvadvpn-e6addcb8d673312b20ead6f3229a42c14da69934.tar.xz
mullvadvpn-e6addcb8d673312b20ead6f3229a42c14da69934.zip
Add swift-format
-rw-r--r--.github/workflows/ios.yml28
-rw-r--r--ios/.swiftformat14
-rw-r--r--ios/README.md22
3 files changed, 59 insertions, 5 deletions
diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml
index c1defce099..3e4998dc5d 100644
--- a/.github/workflows/ios.yml
+++ b/.github/workflows/ios.yml
@@ -2,11 +2,29 @@ name: iOS app
on:
pull_request:
paths:
- - .github/workflows/ios.yml
- - ios/**
+ - ".github/workflows/ios.yml"
+ - "ios/.swiftformat"
+ - "ios/**/*.swift"
# Build if requested manually from the Actions tab
workflow_dispatch:
jobs:
+ check-formatting:
+ name: Check formatting
+ runs-on: macos-11
+ steps:
+ - name: Install SwiftFormat
+ run: |
+ brew update
+ brew upgrade swiftformat
+
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ - name: Check formatting
+ run: |
+ swiftformat --version
+ swiftformat --lint .
+
test:
name: Unit tests
runs-on: macos-11
@@ -17,10 +35,10 @@ jobs:
source_packages_dir: .spm
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Configure cache
- uses: actions/cache@v2
+ uses: actions/cache@v3
with:
path: ios/${{ env.source_packages_dir }}
key: ${{ runner.os }}-spm-${{ hashFiles('ios/**/Package.resolved') }}
@@ -28,7 +46,7 @@ jobs:
${{ runner.os }}-spm-
- name: Setup go-lang
- uses: actions/setup-go@v2
+ uses: actions/setup-go@v3
with:
go-version: '1.16.5'
diff --git a/ios/.swiftformat b/ios/.swiftformat
new file mode 100644
index 0000000000..ed479f35bd
--- /dev/null
+++ b/ios/.swiftformat
@@ -0,0 +1,14 @@
+# file options
+--exclude Build, .spm, MullvadVPNScreenshots/SnapshotHelper.swift
+
+# general options
+--swiftversion 5.5
+
+# format options
+--indent 4
+--maxwidth 100
+--wraparguments before-first
+--wrapcollections before-first
+--wrapternary before-operators
+--redundanttype inferred
+--disable initCoderUnavailable, redundantReturn, unusedArguments, redundantRawValues, preferKeyPath
diff --git a/ios/README.md b/ios/README.md
index a6ba7a35f9..560c7f4cff 100644
--- a/ios/README.md
+++ b/ios/README.md
@@ -12,6 +12,28 @@ instructions document.
[changelog]: CHANGELOG.md
[Configure Xcode project]: BuildInstructions.md#configure-xcode-project
+## Code formatting
+
+The codebase is formatted using [SwiftFormat](https://github.com/nicklockwood/SwiftFormat). Please
+format all contributions using the latest version of formatter.
+
+```
+swiftformat ios/
+```
+
+Install the latest version of SwiftFormat via Homebrew:
+
+```
+brew install swiftformat
+```
+
+CI uses the latest version available on Homebrew to check formatting, so please keep your local
+installation up to date, if you see it complain:
+
+```
+brew upgrade swiftformat
+```
+
## Screenshots for AppStore
The process of taking AppStore screenshots is automated using a UI Testing bundle and Snapshot tool,