Skip to content

Commit 7edc968

Browse files
authored
test: add coveralls integration (#123)
1 parent 6455d58 commit 7edc968

File tree

3 files changed

+72
-9
lines changed

3 files changed

+72
-9
lines changed

.github/workflows/build.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Build
2+
name: Build and test
33

44
on:
55
push:
@@ -12,6 +12,10 @@ concurrency:
1212
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1313
cancel-in-progress: true
1414

15+
env:
16+
HOMEBREW_NO_AUTO_UPDATE: 1
17+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
18+
1519
jobs:
1620
lint:
1721
name: build
@@ -34,16 +38,18 @@ jobs:
3438
- name: Adding Known Hosts
3539
run: ssh-keyscan -H github.com >> ~/.ssh/known_hosts
3640

37-
- name: Build
41+
- name: Install lcov
42+
run: brew install lcov
43+
44+
- name: Build and test
3845
env:
3946
GITHUB_ACTOR: ${{ github.actor }}
4047
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
run: xcodebuild build test -scheme "AtalaPRISMSDK-Package" -destination "platform=iOS Simulator,name=IPhone 14" -resultBundlePath TestResults
48+
run: ./build_test.sh
4249

43-
- name: Publish tests results
44-
uses: kishikawakatsumi/[email protected]
50+
- name: Publish to coveralls
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
uses: coverallsapp/github-action@v2
4554
with:
46-
path: TestResults.xcresult
47-
token: ${{ secrets.GITHUB_TOKEN }}
48-
show-code-coverage: true
49-
if: success() || failure()
55+
file: "lcov.info"

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Coverage Status](https://coveralls.io/repos/github/input-output-hk/atala-prism-wallet-sdk-swift/badge.svg?branch=main)](https://coveralls.io/github/input-output-hk/atala-prism-wallet-sdk-swift?branch=main)
2+
13
# Welcome to Atala PRISM Swift SDK
24

35
The following will explain how to use the SDK in your project, how to prepare your development environment if you wish to contribute and some basic considerations around the project.

build_test.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DERIVED_DATA_DIR="$HOME/.derivedData"
6+
DESTINATION="platform=iOS Simulator,name=IPhone 14"
7+
SCHEME="AtalaPRISMSDK-Package"
8+
LCOV_DIR="$DERIVED_DATA_DIR/lcov"
9+
10+
echo "Derived data directory: $DERIVED_DATA_DIR"
11+
echo "lcov partials directory: $LCOV_DIR"
12+
13+
# Clean derived data dir
14+
echo "Cleaning derived data directory"
15+
rm -rf "$DERIVED_DATA_DIR"
16+
mkdir "$DERIVED_DATA_DIR"
17+
18+
# Clean lcov dir
19+
echo "Cleaning lcov partials directory"
20+
rm -rf "$LCOV_DIR"
21+
mkdir "$LCOV_DIR"
22+
23+
# Run build and test
24+
echo "Running build and test"
25+
xcodebuild -scheme "AtalaPRISMSDK-Package" \
26+
-destination "$DESTINATION" \
27+
-derivedDataPath "$DERIVED_DATA_DIR" \
28+
-enableCodeCoverage YES \
29+
clean build test | xcpretty
30+
echo "Execution completed"
31+
32+
# Find profdata
33+
PROF_DATA=$(find "$DERIVED_DATA_DIR" -name Coverage.profdata)
34+
echo "Profdata found: $PROF_DATA"
35+
36+
# Find all binaries
37+
BINARIES=$(find ~/.derivedData -type f -name "*Tests")
38+
39+
# Print all binaries found
40+
for BINARY in $BINARIES; do
41+
echo "Binary found: $BINARY"
42+
done
43+
44+
# Generate lcov for each target
45+
for BINARY in $BINARIES; do
46+
BASE_NAME=$(basename "$BINARY")
47+
echo "Generating coverage for $BASE_NAME"
48+
LCOV_NAME="${BASE_NAME}.lcov"
49+
xcrun llvm-cov export --format=lcov \
50+
-instr-profile "$PROF_DATA" "$BINARY" > "$LCOV_DIR/$LCOV_NAME"
51+
done
52+
53+
# Merge all coverage
54+
echo "Merging partials to lcov.info"
55+
lcov -o lcov.info -a "$LCOV_DIR/*.lcov" --include AtalaPrismSDK/ --exclude Tests > /dev/null

0 commit comments

Comments
 (0)