forked from norio-nomura/action-swiftlint
-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yml
56 lines (52 loc) · 2.26 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright (c) 2022 Jaehong Kang
# Licensed under Apache License v2.0
name: 'GitHub Actions for SwiftLint'
description: 'A tool to enforce Swift style and conventions'
author: 'Jaehong Kang <[email protected]>'
branding:
icon: 'shield'
color: 'orange'
inputs:
swiftlint-version:
description: "A SwiftLint version to use."
required: true
default: '0.47.1'
swiftlint-args:
description: "Arguments to SwiftLint."
required: false
working-directory:
required: true
default: ''
runs:
using: "composite"
steps:
- run: |
export SWIFTLINT_PATH="$(cd ${{ github.action_path }} && pwd -L)/SwiftLint"
echo SWIFTLINT_OS_VERSION_HASH="$(uname -prsv | openssl dgst -sha256 -binary | xxd -p -c 256)" >> $GITHUB_ENV
echo SWIFTLINT_PATH="$SWIFTLINT_PATH" >> $GITHUB_ENV
echo SWIFTLINT_PACKAGE_ARGS="--package-path "$SWIFTLINT_PATH" -c release --manifest-cache local --disable-index-store --use-integrated-swift-driver" >> $GITHUB_ENV
shell: bash
- run: |
git init -q "${{ env.SWIFTLINT_PATH }}"
pushd "${{ env.SWIFTLINT_PATH }}"
git remote add origin https://github.com/realm/SwiftLint.git
git fetch --no-tags --prune --progress --no-recurse-submodules --depth 1 origin "${{ inputs.swiftlint-version }}"
git checkout --progress --force FETCH_HEAD
popd
shell: bash
- uses: actions/cache@v3
id: cache
with:
path: '${{ env.SWIFTLINT_PATH }}/.build'
key: sinoru-actions-swiftlint-${{ runner.os }}-${{ env.SWIFTLINT_OS_VERSION_HASH }}-swift-${{ env.SWIFT_VERSION }}-${{ inputs.swiftlint-version }}
restore-keys: |
sinoru-actions-swiftlint-${{ runner.os }}-${{ env.SWIFTLINT_OS_VERSION_HASH }}-swift-${{ env.SWIFT_VERSION }}-
sinoru-actions-swiftlint-${{ runner.os }}-${{ env.SWIFTLINT_OS_VERSION_HASH }}-swift-
- name: swift build
if: steps.cache.outputs.cache-hit != 'true'
run: swift package --package-path "$SWIFTLINT_PATH" reset && swift build $SWIFTLINT_PACKAGE_ARGS --product swiftlint
shell: bash
- name: swift run
run: ${{ github.action_path }}/swiftlint.sh ${{ inputs.swiftlint-args }}
shell: bash
working-directory: '${{ github.workspace }}/${{ inputs.working-directory }}'