Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 6389fd0

Browse files
compnerdainu-bot
andauthored
CI: add swift-format based linting/auto-formatting (#931)
* CI: add swift-format based linting/auto-formatting Introduce swift-format based auto-formatting of PRs on the repository via GitHub actions. This will automatically perform the required style changes and commit them to the PR. * Fix code style issues with swift-format Co-authored-by: Swift for TensorFlow <ainu-bot@google.com>
1 parent 36b75a7 commit 6389fd0

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

.github/workflows/swift-format.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: swift-format
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
jobs:
8+
swift-format:
9+
runs-on: ubuntu-latest
10+
continue-on-error: true
11+
steps:
12+
- uses: actions/checkout@v2.1.0
13+
14+
- uses: actions/checkout@v2.1.0
15+
with:
16+
repository: apple/swift-format
17+
path: ${{ github.workspace }}/swift-format
18+
ref: swift-5.2-branch
19+
20+
- uses: actions/cache@v1.1.2
21+
with:
22+
path: ${{ github.workspace }}/swift-format/.build
23+
key: ${{ runner.os }}-swift-format-${{ hashFiles('**/Package.resolved') }}
24+
restore-keys: |
25+
${{ runner.os }}-swift-format-
26+
27+
- name: build swift-format
28+
run: |
29+
pushd ${{ github.workspace }}/swift-format
30+
swift build -c release
31+
echo "::add-path::${PWD}/.build/release"
32+
popd
33+
34+
- uses: samuelmeuli/lint-action@v1.5.0
35+
with:
36+
auto_fix: true
37+
swift_format_official: true
38+
git_name: Swift for TensorFlow
39+
git_email: ainu-bot@google.com
40+
github_token: ${{ secrets.GITHUB_TOKEN }}

Sources/TensorFlow/Epochs/Algorithms.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
/// points to be used from other algorithms defined on
3232
/// `MutableCollectionAlgorithms`.
3333
public protocol MutableCollectionAlgorithms: MutableCollection
34-
where SubSequence: MutableCollectionAlgorithms
35-
{
34+
where SubSequence: MutableCollectionAlgorithms {
3635
/// Rotates the elements of the collection so that the element
3736
/// at `middle` ends up first.
3837
///

Tests/TensorFlowTests/EpochsTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ final class EpochsTests: XCTestCase {
187187
// Elements are not accessed until we do something with `batch` so only
188188
// `i * batchSize` elements have been accessed yet.
189189
XCTAssertEqual(
190-
dataset.accessed.filter() { $0 }.count, i * batchSize,
190+
dataset.accessed.filter { $0 }.count, i * batchSize,
191191
"Should have accessed \(i * batchSize) elements.")
192192
let _ = Array(batch)
193193
XCTAssertEqual(
194-
dataset.accessed.filter() { $0 }.count, (i + 1) * batchSize,
194+
dataset.accessed.filter { $0 }.count, (i + 1) * batchSize,
195195
"Should have accessed \((i + 1) * batchSize) elements.")
196196
}
197197
}

0 commit comments

Comments
 (0)