Skip to content

Commit 9533e58

Browse files
committed
Merge branch 'release/6.0.0'
2 parents 94c7c77 + 7e2bc1d commit 9533e58

File tree

9 files changed

+186
-165
lines changed

9 files changed

+186
-165
lines changed

.dockerfilelintrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

.dockerignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/docker-build.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.github/workflows/docker-lint.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Copyright (c) 2018 Norio Nomura
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in all
11+
# copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
# SOFTWARE.
20+
#
21+
# Copyright (c) 2022 Jaehong Kang
22+
# Licensed under Apache License v2.0
23+
24+
name: Tests
25+
26+
on:
27+
push:
28+
paths:
29+
- '.github/workflows/tests.yml'
30+
- 'action.yml'
31+
- 'swiftlint.sh'
32+
pull_request:
33+
paths:
34+
- '.github/workflows/tests.yml'
35+
- 'action.yml'
36+
- 'swiftlint.sh'
37+
38+
jobs:
39+
actions-tests:
40+
name: Actions Tests
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
virtual-environment: ["ubuntu-18.04", "ubuntu-20.04", "macos-11", "macos-12"]
45+
swift-version: ["5.5.3", "5.6.1"]
46+
runs-on: ${{ matrix.virtual-environment }}
47+
steps:
48+
- uses: actions/checkout@master
49+
- uses: sinoru/actions-setup-swift@main
50+
with:
51+
swift-version: ${{ matrix.swift-version }}
52+
- uses: ./
53+
with:
54+
working-directory: test/Warnings
55+
56+
swiftlint-tests:
57+
name: SwiftLint Tests
58+
runs-on: ubuntu-latest
59+
env:
60+
SWIFTLINT_VERSION: '0.47.1'
61+
steps:
62+
- uses: actions/checkout@master
63+
- uses: sinoru/actions-setup-swift@main
64+
with:
65+
swift-version: '5.6.1'
66+
- run: |
67+
export SWIFTLINT_PATH="$(cd ${{ github.workspace }} && pwd -L)/SwiftLint"
68+
69+
echo SWIFTLINT_PATH="$SWIFTLINT_PATH" >> $GITHUB_ENV
70+
echo SWIFTLINT_PACKAGE_ARGS="--package-path "$SWIFTLINT_PATH" -c release --manifest-cache local --disable-index-store --use-integrated-swift-driver" >> $GITHUB_ENV
71+
- uses: actions/checkout@v3
72+
with:
73+
repository: 'realm/SwiftLint'
74+
ref: '${{ env.SWIFTLINT_VERSION }}'
75+
path: '${{ env.SWIFTLINT_PATH }}'
76+
- uses: actions/cache@v3
77+
id: cache
78+
with:
79+
path: '${{ env.SWIFTLINT_PATH }}/.build'
80+
key: sinoru-actions-swiftlint-${{ runner.os }}-swift-${{ env.SWIFT_VERSION }}-${{ env.SWIFTLINT_VERSION }}-${{ hashFiles('${{ env.SWIFTLINT_PATH }}/Package.*') }}
81+
restore-keys: |
82+
sinoru-actions-swiftlint-${{ runner.os }}-swift-${{ env.SWIFT_VERSION }}-${{ env.SWIFTLINT_VERSION }}-
83+
sinoru-actions-swiftlint-${{ runner.os }}-swift-${{ env.SWIFT_VERSION }}-
84+
sinoru-actions-swiftlint-${{ runner.os }}-swift-
85+
- name: swift build
86+
run: swift build $SWIFTLINT_PACKAGE_ARGS
87+
88+
- name: Exit Status on Errors
89+
run: |
90+
STATUS=$(${{ github.workspace }}/swiftlint.sh &>/dev/null; echo $?)
91+
echo $STATUS
92+
[[ $STATUS == "2" ]]
93+
shell: bash
94+
working-directory: test/errors
95+
96+
- name: Exit Status on No lintable files
97+
run: |
98+
STATUS=$(${{ github.workspace }}/swiftlint.sh &>/dev/null; echo $?)
99+
echo $STATUS
100+
[[ $STATUS == "1" ]]
101+
shell: bash
102+
working-directory: test/no-lintable-files
103+
104+
- name: Exit Status on Warnings
105+
run: |
106+
STATUS=$(${{ github.workspace }}/swiftlint.sh &>/dev/null; echo $?)
107+
echo $STATUS
108+
[[ $STATUS == "0" ]]
109+
shell: bash
110+
working-directory: test/Warnings
111+
112+
- name: Exit Status on Warnings with `--strict`
113+
run: |
114+
STATUS=$(${{ github.workspace }}/swiftlint.sh --strict &>/dev/null; echo $?)
115+
echo $STATUS
116+
[[ $STATUS == "2" ]]
117+
shell: bash
118+
working-directory: test/Warnings
119+
120+
- name: Output on Errors
121+
run: |
122+
diff <(${{ github.workspace }}/swiftlint.sh|sort) expected.txt
123+
shell: bash
124+
working-directory: test/errors
125+
126+
- name: Output on Warnings
127+
run: |
128+
diff <(${{ github.workspace }}/swiftlint.sh|sort) expected.txt
129+
shell: bash
130+
working-directory: test/Warnings

Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v3
24+
- uses: sinoru/actions-setup-swift@v2
25+
with:
26+
swift-version: '5.6.1'
2427
- name: GitHub Actions for SwiftLint
2528
uses: sinoru/actions-swiftlint@v5
2629
- name: GitHub Actions for SwiftLint with --strict
2730
uses: sinoru/actions-swiftlint@v5
2831
with:
29-
args: --strict
32+
swiftlint-args: --strict
3033
- name: GitHub Actions for SwiftLint (Only files changed in the PR)
3134
uses: sinoru/actions-swiftlint@v5
3235
env:
3336
DIFF_BASE: ${{ github.base_ref }}
3437
- name: GitHub Actions for SwiftLint (Different working directory)
3538
uses: sinoru/actions-swiftlint@v5
36-
env:
37-
WORKING_DIRECTORY: Source
39+
with:
40+
working-directory: Sources
3841
```

action.yml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,52 @@
1+
# Copyright (c) 2022 Jaehong Kang
2+
# Licensed under Apache License v2.0
3+
14
name: 'GitHub Actions for SwiftLint'
25
description: 'A tool to enforce Swift style and conventions'
36
author: 'Jaehong Kang <[email protected]>'
4-
runs:
5-
using: 'docker'
6-
image: 'Dockerfile'
77
branding:
88
icon: 'shield'
99
color: 'orange'
10+
inputs:
11+
swiftlint-version:
12+
description: "A SwiftLint version to use."
13+
required: true
14+
default: '0.47.1'
15+
swiftlint-args:
16+
description: "Arguments to SwiftLint."
17+
required: false
18+
working-directory:
19+
required: true
20+
default: ''
21+
runs:
22+
using: "composite"
23+
steps:
24+
- run: |
25+
export SWIFTLINT_PATH="$(cd ${{ github.action_path }} && pwd -L)/SwiftLint"
26+
27+
echo SWIFTLINT_PATH="$SWIFTLINT_PATH" >> $GITHUB_ENV
28+
echo SWIFTLINT_PACKAGE_ARGS="--package-path "$SWIFTLINT_PATH" -c release --manifest-cache local --disable-index-store --use-integrated-swift-driver" >> $GITHUB_ENV
29+
shell: bash
30+
- uses: actions/checkout@v3
31+
with:
32+
repository: 'realm/SwiftLint'
33+
ref: '${{ inputs.swiftlint-version }}'
34+
path: '${{ env.SWIFTLINT_PATH }}'
35+
- uses: actions/cache@v3
36+
id: cache
37+
with:
38+
path: '${{ env.SWIFTLINT_PATH }}/.build'
39+
key: sinoru-actions-swiftlint-${{ runner.os }}-swift-${{ env.SWIFT_VERSION }}-${{ inputs.swiftlint-version }}-${{ hashFiles('${{ env.SWIFTLINT_PATH }}/Package.*') }}
40+
restore-keys: |
41+
sinoru-actions-swiftlint-${{ runner.os }}-swift-${{ env.SWIFT_VERSION }}-${{ inputs.swiftlint-version }}-
42+
sinoru-actions-swiftlint-${{ runner.os }}-swift-${{ env.SWIFT_VERSION }}-
43+
sinoru-actions-swiftlint-${{ runner.os }}-swift-
44+
- name: swift build
45+
if: steps.cache.outputs.cache-hit != 'true'
46+
run: swift package --package-path "$SWIFTLINT_PATH" reset && swift build $SWIFTLINT_PACKAGE_ARGS --product swiftlint
47+
shell: bash
48+
- name: swift run
49+
run: ${{ github.action_path }}/swiftlint.sh ${{ inputs.swiftlint-args }}
50+
shell: bash
51+
working-directory: '${{ github.workspace }}/${{ inputs.working-directory }}'
52+

0 commit comments

Comments
 (0)