Skip to content

CI

CI #265

Workflow file for this run

name: CI
on:
push:
branches: main
paths:
- '**.swift'
- '!Sources/Common/ApplicationInfo.swift'
- '.github/workflows/ci.yml'
pull_request: {}
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
generate-matrix:
name: Generate matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: |
matrix=$(cat .github/matrix.json | jq -c .)
echo "matrix=$matrix" >> $GITHUB_OUTPUT
test:
name: Test
needs: generate-matrix
runs-on: macOS-12
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer
steps:
- uses: actions/checkout@v4
- name: Cache SPM build directory
uses: actions/cache@v3
with:
path: |
.build
Demo/.build
Demo/Tools/.build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.swift') }}
restore-keys: |
${{ runner.os }}-spm-${{ env.cache-name }}-
${{ runner.os }}-spm-
${{ runner.os }}-
- name: Disable SwiftLint Plugin
run: sed -i -e 's/.*SwiftLint.*//g' Package.swift
- name: test via SwiftPM
run: set -o pipefail && swift test
- name: test via xcodebuild
run: |
set -o pipefail && \
xcrun --sdk macosx xcodebuild \
-enableCodeCoverage YES \
-scheme "$(xcrun --sdk macosx xcodebuild -list -json | jq -rc '.workspace.schemes[] | select(. | startswith("BuildConfig"))')" \
-destination "platform=macOS" \
-clonedSourcePackagesDirPath '.build/SourcePackages' \
-resultBundlePath 'test_output/BuildConfig.swift.xcresult' \
clean test | xcpretty
- name: test DemoApp
if: success() || failure()
run: |
set -o pipefail && \
xcrun --sdk macosx swift run --package-path Demo/Tools xcodegen --spec Demo/project.yml && \
PROJECT_PATH=$(find Demo -depth 1 -name '*.xcodeproj' | head -n 1) && \
xcrun --sdk macosx xcodebuild \
-skipPackagePluginValidation \
-enableCodeCoverage YES \
-project "${PROJECT_PATH}" \
-scheme "$(xcrun --sdk macosx xcodebuild -project "${PROJECT_PATH}" -list -json | jq -rc '.project.schemes[] | select(. | contains("Demo"))')" \
-destination 'platform=iOS Simulator,name=iPhone 14 Pro' \
-clonedSourcePackagesDirPath 'Demo/.build/SourcePackages' \
-resultBundlePath 'test_output/BuildConfigDemo.xcresult' \
clean test | xcpretty
- uses: kishikawakatsumi/xcresulttool@v1
with:
path: |
test_output/BuildConfig.swift.xcresult
test_output/BuildConfigDemo.xcresult
show-passed-tests: false
show-code-coverage: false
if: ${{ matrix.xcode_version == fromJson(needs.generate-matrix.outputs.matrix).xcode_version[0] && (success() || failure()) }}
danger:
name: Danger
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Disable SwiftLint Plugin
run: sed -i -e 's/.*SwiftLint.*//g' Package.swift
- name: Copy .swiftlint.yml for demo app
run: sh ./scripts/copy-lint-config.sh
- uses: 417-72KI/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}