Skip to content

Instantly share code, notes, and snippets.

@ghiculescu
Last active September 7, 2022 13:18
Show Gist options
  • Save ghiculescu/ad03483060110fee944791ecd31496f2 to your computer and use it in GitHub Desktop.
Save ghiculescu/ad03483060110fee944791ecd31496f2 to your computer and use it in GitHub Desktop.
Github Actions CI steps for Turbo Android and Turbo iOS apps
name: ktlint
on: [pull_request]
jobs:
ktlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: ktlint
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
fail_on_error: true
android: true
name: SwiftLint
on: [pull_request]
jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run swiftlint
uses: norio-nomura/[email protected]
name: Test
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Test with Gradle
run: ./gradlew testDebug --info
name: Tests
on: [pull_request]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: xcodebuild clean test -workspace "work-ios.xcworkspace" -scheme "work-ios" -destination "platform=iOS Simulator,name=iPhone 12 Pro,OS=latest" | xcpretty && exit ${PIPESTATUS[0]}
@ghiculescu
Copy link
Author

ghiculescu commented Aug 8, 2022

@jayohms @joemasilotti is there anything you'd add to these?

@joemasilotti
Copy link

Ohh, very nice! Thanks for this.

Can you add or document instructions on how to lint locally before submitting a PR?

@ghiculescu
Copy link
Author

ghiculescu commented Aug 8, 2022

I usually just let CI handle it, but...

iOS:

Pods/SwiftLint/swiftlint lint --fix

Android:

ktlint --android

@joemasilotti
Copy link

So you would need swiftlint installed via CocoaPods? Is it not available be SPM?

Also, is swiftlint the go-to standard? I thought Apple had their own listing tool now. I've also been using SwiftFormat.

@ghiculescu
Copy link
Author

ghiculescu commented Aug 8, 2022

TIL about SwiftFormat. tbh I don't have a strong preference on linter. I just like having one. And yeah, I prefer Cocoapods over SPM but it should work either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment