Skip to content

Commit a8c3cd4

Browse files
Enhance CI workflows for CodeQL and Swift testing with platform-specific configurations and improved coverage reporting
1 parent c68e5a8 commit a8c3cd4

File tree

2 files changed

+62
-14
lines changed

2 files changed

+62
-14
lines changed

.github/workflows/codeql.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,13 @@ jobs:
6464
# or others). This is typically only required for manual builds.
6565
# - name: Setup runtime (example)
6666
# uses: actions/setup-example@v1
67-
- uses: maxim-lobanov/setup-xcode@v1
68-
with:
69-
xcode-version: '26.0-beta'
7067

7168
# Initializes the CodeQL tools for scanning.
7269
- name: Initialize CodeQL
7370
uses: github/codeql-action/init@v3
7471
with:
7572
languages: ${{ matrix.language }}
7673
build-mode: ${{ matrix.build-mode }}
77-
tools: linked
7874
# If you wish to specify custom queries, you can do so here or in a config file.
7975
# By default, queries listed here will override any specified in a config file.
8076
# Prefix the list here with "+" to use these queries and those in the config file.
@@ -89,7 +85,10 @@ jobs:
8985
# ℹ️ Command-line programs to run using the OS shell.
9086
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
9187
- if: matrix.build-mode == 'manual'
92-
run: swift build -v
88+
run: |
89+
xcodebuild \
90+
-scheme ShitLib build \
91+
-destination 'platform=macOS,arch=arm64' \
9392
9493
- name: Perform CodeQL Analysis
9594
uses: github/codeql-action/analyze@v3

.github/workflows/swift.yml

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,67 @@ permissions:
1111

1212
jobs:
1313
test-and-coverage:
14-
name: Test and Coverage
14+
name: Test and Coverage (${{ matrix.platform }})
1515
runs-on: macos-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- platform: "macOS"
22+
destination: "platform=macOS,arch=arm64"
23+
- platform: "iOS"
24+
destination: "platform=iOS Simulator"
25+
- platform: "tvOS"
26+
destination: "platform=tvOS Simulator"
27+
- platform: "watchOS"
28+
destination: "platform=watchOS Simulator"
29+
- platform: "visionOS"
30+
destination: "platform=visionOS Simulator"
31+
- platform: "macCatalyst"
32+
destination: "platform=macOS,variant=Mac Catalyst"
33+
1634
steps:
1735
- uses: actions/checkout@v5
18-
- uses: maxim-lobanov/setup-xcode@v1
19-
with:
20-
xcode-version: '26.0-beta'
21-
- name: Run tests
22-
run: swift test -v --enable-code-coverage
36+
37+
- name: Run tests on ${{ matrix.platform }}
38+
run: |
39+
# Determine full destination specifier
40+
DEST="${{ matrix.destination }}"
41+
if [[ "${{ matrix.platform }}" != "macOS" && "${{ matrix.platform }}" != "macCatalyst" ]]; then
42+
DEVICE_ID=$(xcrun simctl list devices available \
43+
| grep "${{ matrix.platform }} Simulator" \
44+
| head -1 \
45+
| awk -F'[()]' '{print $(NF-3)}')
46+
DEST="${DEST},id=${DEVICE_ID}"
47+
fi
48+
49+
echo "Testing on: $DEST"
50+
xcodebuild test \
51+
-scheme ShitLib \
52+
-destination "$DEST" \
53+
-derivedDataPath DerivedData \
54+
-enableCodeCoverage YES
55+
2356
- name: Export coverage report as Lcov
24-
run: xcrun llvm-cov export -format="lcov" -instr-profile=.build/arm64-apple-macosx/debug/codecov/default.profdata .build/arm64-apple-macosx/debug/ShitLibPackageTests.xctest/Contents/MacOS/ShitLibPackageTests > lcov.info
25-
- uses: codecov/codecov-action@v5
57+
run: |
58+
# Locate profdata and test bundle under DerivedData
59+
PROFILE=$(find DerivedData/Build/ProfileData -name "*.profdata" | head -1)
60+
TEST_BUNDLE=$(find DerivedData/Build/Products -name "*ShitLibPackageTests.xctest" | head -1)
61+
TEST_BINARY="${TEST_BUNDLE}/$(basename "$TEST_BUNDLE" .xctest)"
62+
63+
if [[ -f "$PROFILE" && -f "$TEST_BINARY" ]]; then
64+
echo "Exporting coverage for ${{ matrix.platform }}"
65+
xcrun llvm-cov export -format="lcov" \
66+
-instr-profile="$PROFILE" \
67+
"$TEST_BINARY" > lcov_${{ matrix.platform }}.info
68+
else
69+
echo "Coverage data not found for ${{ matrix.platform }}"
70+
fi
71+
72+
- name: Upload coverage to Codecov
73+
uses: codecov/codecov-action@v5
2674
with:
2775
token: ${{ secrets.CODECOV_TOKEN }}
28-
files: lcov.info
76+
files: lcov_${{ matrix.platform }}.info
77+
flags: ${{ matrix.platform }}

0 commit comments

Comments
 (0)