|
| 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 |
0 commit comments