Skip to content

add SwiftLint Plugin #30

add SwiftLint Plugin

add SwiftLint Plugin #30

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, synchronize, edited]
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
needs-test:
name: Needs Test
runs-on: ubuntu-latest
steps:
- name: Detect files from diff to run tests
id: detect-swift-files
run: |
DIFF="$(gh pr view ${{ github.event.pull_request.html_url }} --json files --jq '.files | map(.path)' | jq -rc '.[]')"
value=false
for file in $(echo '[".swift", "Package.resolved", ".github/workflows/ci.yml", ".github/versions.json"]' | jq -r '.[]'); do
if [ $(echo "$DIFF" | grep "$file" | wc -l | tr -d ' ') -gt 0 ]; then
value=true
break
fi
done
echo result=$value >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
outputs:
result: ${{ steps.detect-swift-files.outputs.result }}
generate-matrix:
name: Generate matrix
needs: needs-test
if: ${{ fromJson(needs.needs-test.outputs.result) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: |
matrix=$(cat .github/versions.json | jq -rc .)
echo "matrix=$matrix" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
macOS:
name: macOS
needs: generate-matrix
runs-on: macOS-latest
env:
DEVELOPER_DIR: /Applications/Xcode_${{ fromJson(needs.generate-matrix.outputs.matrix).xcode_version }}.app/Contents/Developer
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-swift-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-swift
${{ runner.os }}-
- name: test
run: |
swift package clean
set -o pipefail && xcrun --sdk macosx \
xcodebuild \
"OTHER_LDFLAGS=\$(OTHER_LDFLAGS) -Wl -weak-lswift_Concurrency -Wl -rpath /usr/lib/swift" \
-enableCodeCoverage YES \
-scheme "$(xcrun --sdk macosx xcodebuild -list -json | jq -r '.workspace.schemes[0]' 2>/dev/null)" \
-destination "platform=macOS" \
-clonedSourcePackagesDirPath '.build' \
-resultBundlePath 'test_output/SSGH.xcresult' \
clean test | xcpretty
- uses: kishikawakatsumi/xcresulttool@v1
if: success() || failure()
with:
path: test_output/SSGH.xcresult
show-passed-tests: false
show-code-coverage: false
linux:
name: Linux
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift_version: ${{ fromJson(needs.generate-matrix.outputs.matrix).swift_version }}
container:
image: swift:${{ matrix.swift_version }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-swift-${{ matrix.swift_version }}-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-swift-${{ matrix.swift_version }}
${{ runner.os }}-swift
${{ runner.os }}-
- name: build
run: swift build
- name: test
run: swift package clean && swift test
danger:
name: Danger
needs: [macOS, linux]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Danger
uses: 417-72KI/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}