Skip to content

Instantly share code, notes, and snippets.

@ydnar
Created April 5, 2020 19:42
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ydnar/17da5a1a3941d7674bad4a2548c38e95 to your computer and use it in GitHub Desktop.
Save ydnar/17da5a1a3941d7674bad4a2548c38e95 to your computer and use it in GitHub Desktop.
SwiftFormat with GitHub Actions
name: Swift
on:
push:
branches:
- master
paths:
- ".github/workflows/swift.yaml"
- "**.swift"
- "**/Package.resolved"
pull_request:
paths:
- ".github/workflows/swift.yaml"
- "**.swift"
- "**/Package.resolved"
jobs:
swiftformat:
name: Check swiftformat
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: recursive
- name: Update PATH
run: echo ::add-path::$HOME/bin
- name: Cache packages/Tools/.build
uses: actions/cache@v1
with:
path: packages/Tools/.build
key: ${{ runner.os }}-swift-tools-build-${{ hashFiles('packages/Tools/Package.resolved') }}
restore-keys: |
${{ runner.os }}-swift-tools-build-
- name: Cache ~/bin
uses: actions/cache@v1
with:
path: ~/bin
key: ${{ runner.os }}-home-bin-${{ hashFiles('packages/Tools/Package.resolved') }}
restore-keys: |
${{ runner.os }}-home-bin-
- name: Install Swift tools
run: make swift-tools
- name: Format Swift code
run: swiftformat --verbose .
- name: Verify formatted code is unchanged
run: git diff --exit-code HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment