Merge pull request #48 from 417-72KI/fix-warnings #227
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
paths: | |
- .github/workflows/ci.yml | |
- Package.* | |
- Sources/**/*.swift | |
- Tests/**/*.swift | |
- .github/matrix.json | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: ${{ github.ref_name != 'main' }} | |
jobs: | |
danger: | |
name: Danger | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: 417-72KI/danger-swiftlint@v5.10 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
generate-matrix: | |
name: Generate matrix | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.matrix.outputs.matrix }} | |
latest-xcode: ${{ steps.matrix.outputs.latest-xcode }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract matrix | |
id: matrix | |
run: | | |
echo "latest-xcode=$(cat .github/matrix.json | jq -rc '.xcode_version | max')" >> $GITHUB_OUTPUT | |
echo "matrix=$(cat .github/matrix.json | jq -rc .)" >> $GITHUB_OUTPUT | |
test-linux: | |
name: Test(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.swift') }} | |
restore-keys: | | |
${{ runner.os }}-swift-${{ matrix.swift-version }} | |
${{ runner.os }}-swift | |
${{ runner.os }}- | |
- name: Test | |
run: swift package clean && swift test | |
test-macos: | |
name: Test(macOS) | |
needs: generate-matrix | |
runs-on: macOS-14 | |
strategy: | |
fail-fast: false | |
matrix: | |
xcode-version: ${{ fromJson(needs.generate-matrix.outputs.matrix).xcode_version }} | |
platform: ${{ fromJson(needs.generate-matrix.outputs.matrix).platform }} | |
env: | |
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode-version }}.app/Contents/Developer | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: .build | |
key: ${{ runner.os }}-swift-${{ matrix.xcode-version }}-${{ matrix.platform }}-${{ hashFiles('Package.swift') }} | |
restore-keys: | | |
${{ runner.os }}-swift-${{ matrix.xcode-version }}-${{ matrix.platform }} | |
${{ runner.os }}-swift-${{ matrix.xcode-version }} | |
${{ runner.os }}-swift | |
${{ runner.os }}- | |
- name: Enable macro and plugin | |
run: | | |
defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES | |
defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES | |
- name: Detect destination | |
id: destination | |
run: | | |
echo "value=$(./.github/scripts/detect-destination.sh ${{ matrix.platform }})" >> $GITHUB_OUTPUT | |
- name: Test | |
run: | | |
swift package clean | |
set -o pipefail && xcrun \ | |
xcodebuild \ | |
-enableCodeCoverage YES \ | |
-scheme "StubNetworkKit" \ | |
-destination "${{ steps.destination.outputs.value }}" \ | |
-clonedSourcePackagesDirPath '.build' \ | |
-resultBundlePath 'test_output/test.xcresult' \ | |
clean test | xcpretty | |
- name: Upload artifacts | |
if: matrix.xcode-version == needs.generate-matrix.outputs.latest-xcode && (success() || failure()) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.platform }} | |
path: test_output | |
if-no-files-found: error | |
retention-days: 1 | |
xcodebuild_result: | |
name: Export xcodebuild test result | |
if: success() || failure() | |
needs: test-macos | |
runs-on: macOS-14 | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: test_output | |
- name: Merge xcresult files | |
run: xcrun xcresulttool merge test_output/**/*.xcresult --output-path test_output/TestResults.xcresult | |
- uses: kishikawakatsumi/xcresulttool@v1 | |
with: | |
path: test_output/TestResults.xcresult | |
show-passed-tests: false | |
show-code-coverage: false | |
upload-bundles: true |