Repository navigation
101 lines (85 loc) · 2.89 KB
/
Copy pathci.yml
File metadata and controls
101 lines (85 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: CI
on:
push:
branches: [ main, master, develop ]
pull_request:
branches: [ main, master, develop ]
workflow_dispatch:
jobs:
test:
name: Test
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
- name: Verify Swift Version
run: |
swift --version
SWIFT_VERSION=$(swift --version | grep -oE 'Swift version [0-9]+\.[0-9]+' | grep -oE '[0-9]+\.[0-9]+')
echo "Detected Swift version: $SWIFT_VERSION"
MAJOR=$(echo $SWIFT_VERSION | cut -d. -f1)
MINOR=$(echo $SWIFT_VERSION | cut -d. -f2)
if [ "$MAJOR" -lt 6 ] || ([ "$MAJOR" -eq 6 ] && [ "$MINOR" -lt 2 ]); then
echo "Error: Swift 6.2 or later is required, but found $SWIFT_VERSION"
echo "Please update the Xcode version in the workflow or wait for GitHub Actions to provide Swift 6.2"
exit 1
fi
echo "✓ Swift version $SWIFT_VERSION meets requirement (>= 6.2)"
- name: Resolve Dependencies
run: swift package resolve
- name: Build
run: swift build
- name: Build Demo
run: swift build --package-path Examples/Demo --product Demo
- name: Test
run: swift test
env:
SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}
continue-on-error: true
lint:
name: Lint
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
- name: Run SwiftLint
uses: norio-nomura/action-swiftlint@3.2.1
continue-on-error: true
with:
args: --strict
code-coverage:
name: Code Coverage
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest'
- name: Run Tests with Coverage
run: swift test --enable-code-coverage
env:
SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }}
continue-on-error: true
- name: Generate Coverage Report
run: |
bin_path=$(swift build --show-bin-path)
xctest_path=$(find "$bin_path" -name "*.xctest" -type d | head -1)
if [ -n "$xctest_path" ]; then
llvm_cov=$(xcrun -f llvm-cov 2>/dev/null || echo "")
if [ -n "$llvm_cov" ]; then
$llvm_cov report "$xctest_path/Contents/MacOS/SerpApiTests" \
-instr-profile=.build/debug/codecov/default.profdata \
-ignore-filename-regex='.build|Tests' || true
fi
fi
continue-on-error: true