Skip to content

Commit ff9749c

Browse files
committed
ci: codecov
1 parent 91e6be3 commit ff9749c

3 files changed

Lines changed: 86 additions & 4 deletions

File tree

.github/workflows/codecov.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Code Coverage
2+
3+
# Only run on pushes to main branch
4+
on:
5+
push:
6+
branches: [ main ]
7+
8+
# Cancel any in-progress workflow runs for the same branch
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
15+
16+
jobs:
17+
# Test Coverage
18+
test-coverage:
19+
name: Test Coverage
20+
runs-on: macos-latest
21+
strategy:
22+
matrix:
23+
platform:
24+
- { name: "iOS", scheme: "iOS Example", destination: "platform=iOS Simulator,name=iPhone 15,OS=latest" }
25+
- { name: "macOS", scheme: "macOS Example", destination: "platform=macOS" }
26+
- { name: "tvOS", scheme: "tvOS Example", destination: "platform=tvOS Simulator,name=Apple TV,OS=latest" }
27+
28+
steps:
29+
- name: Checkout Repository
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Xcode
33+
uses: maxim-lobanov/setup-xcode@v1
34+
with:
35+
xcode-version: latest
36+
37+
- name: Run Tests with Coverage
38+
run: |
39+
xcodebuild test \
40+
-workspace EFQRCode.xcworkspace \
41+
-scheme "${{ matrix.platform.scheme }}" \
42+
-destination "${{ matrix.platform.destination }}" \
43+
-enableCodeCoverage YES \
44+
-derivedDataPath ./DerivedData-${{ matrix.platform.name }} \
45+
CODE_SIGN_IDENTITY="" \
46+
CODE_SIGNING_REQUIRED=NO
47+
48+
- name: Generate Coverage Report
49+
run: |
50+
xcrun xccov view --report --json ./DerivedData-${{ matrix.platform.name }}/Logs/Test/*.xcresult > coverage-${{ matrix.platform.name }}.json
51+
52+
- name: Upload Coverage to Codecov
53+
uses: codecov/codecov-action@v4
54+
with:
55+
token: ${{ secrets.CODECOV_TOKEN }}
56+
files: ./coverage-${{ matrix.platform.name }}.json
57+
flags: unittests,${{ matrix.platform.name }}
58+
name: codecov-${{ matrix.platform.name }}
59+
fail_ci_if_error: true
60+
61+
# Status Check
62+
status-check:
63+
name: Coverage Status Check
64+
runs-on: macos-latest
65+
needs: [test-coverage]
66+
if: always()
67+
68+
steps:
69+
- name: Check Results
70+
run: |
71+
if [[ "${{ needs.test-coverage.result }}" != "success" ]]; then
72+
echo "❌ Code coverage collection failed"
73+
exit 1
74+
fi
75+
76+
echo "✅ Code coverage successfully uploaded to Codecov!"

EFQRCode.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@
999999
PRODUCT_NAME = "$(TARGET_NAME)";
10001000
SDKROOT = appletvos;
10011001
SWIFT_VERSION = 5.0;
1002+
TVOS_DEPLOYMENT_TARGET = 13;
10021003
};
10031004
name = Debug;
10041005
};
@@ -1019,6 +1020,7 @@
10191020
PRODUCT_NAME = "$(TARGET_NAME)";
10201021
SDKROOT = appletvos;
10211022
SWIFT_VERSION = 5.0;
1023+
TVOS_DEPLOYMENT_TARGET = 13;
10221024
};
10231025
name = Release;
10241026
};
@@ -1348,6 +1350,7 @@
13481350
"$(inherited)",
13491351
);
13501352
INFOPLIST_FILE = Tests/Info.plist;
1353+
IPHONEOS_DEPLOYMENT_TARGET = 13;
13511354
LD_RUNPATH_SEARCH_PATHS = (
13521355
"$(inherited)",
13531356
"@executable_path/Frameworks",
@@ -1367,6 +1370,7 @@
13671370
DEVELOPMENT_TEAM = "";
13681371
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
13691372
INFOPLIST_FILE = Tests/Info.plist;
1373+
IPHONEOS_DEPLOYMENT_TARGET = 13;
13701374
LD_RUNPATH_SEARCH_PATHS = (
13711375
"$(inherited)",
13721376
"@executable_path/Frameworks",
@@ -1401,6 +1405,7 @@
14011405
"@executable_path/../Frameworks",
14021406
"@loader_path/../Frameworks",
14031407
);
1408+
MACOSX_DEPLOYMENT_TARGET = 10.15;
14041409
PRODUCT_BUNDLE_IDENTIFIER = "org.eyrefree.$(PRODUCT_NAME:rfc1034identifier)";
14051410
PRODUCT_NAME = "$(TARGET_NAME)";
14061411
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1429,6 +1434,7 @@
14291434
"@executable_path/../Frameworks",
14301435
"@loader_path/../Frameworks",
14311436
);
1437+
MACOSX_DEPLOYMENT_TARGET = 10.15;
14321438
PRODUCT_BUNDLE_IDENTIFIER = "org.eyrefree.$(PRODUCT_NAME:rfc1034identifier)";
14331439
PRODUCT_NAME = "$(TARGET_NAME)";
14341440
PROVISIONING_PROFILE_SPECIFIER = "";

Tests/Tests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Tests: XCTestCase {
5252
// This is an example of EFQRCodeGenerator test case.
5353
let content = "https://github.com/EFPrefix/EFQRCode"
5454
let generator = try? EFQRCode.Generator(content, style: .basic(params: .init()))
55-
let testResult = try? generator?.toImage(width: 256).cgImage
55+
let testResult = try? generator?.toImage(width: 256).cgImage()
5656
XCTAssertNotNil(testResult, "testResult is nil!")
5757

5858
// This is an example of EFQRCodeRecognizer test case.
@@ -65,7 +65,7 @@ class Tests: XCTestCase {
6565
// This is an example of EFQRCodeGenerator test case.
6666
let content = ""
6767
let generator = try? EFQRCode.Generator(content, style: .bubble(params: .init()))
68-
let testResult = try? generator?.toImage(width: 180).cgImage
68+
let testResult = try? generator?.toImage(width: 180).cgImage()
6969
XCTAssertNotNil(testResult, "testResult is nil!")
7070

7171
// This is an example of EFQRCodeRecognizer test case.
@@ -78,7 +78,7 @@ class Tests: XCTestCase {
7878
// This is an example of EFQRCodeGenerator test case.
7979
let content = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989"
8080
let generator = try? EFQRCode.Generator(content, style: .bubble(params: .init()))
81-
let testResult = try? generator?.toImage(width: 180).cgImage
81+
let testResult = try? generator?.toImage(width: 1200).cgImage()
8282
XCTAssertNotNil(testResult, "testResult is nil!")
8383

8484
// This is an example of EFQRCodeRecognizer test case.
@@ -96,7 +96,7 @@ class Tests: XCTestCase {
9696
image: .init(image: .static(image: getImage()), allowTransparent: true))
9797
)
9898
)
99-
let testResult = try? generator?.toImage(width: 180).cgImage
99+
let testResult = try? generator?.toImage(width: 180).cgImage()
100100
XCTAssertNotNil(testResult, "testResult is nil!")
101101
}
102102

0 commit comments

Comments
 (0)