Skip to content

Commit

Permalink
ci: enable codecov uploading again (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian authored Sep 19, 2023
1 parent 9c55d9a commit 0ab6e44
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 78 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@ jobs:
with:
lane: 'scan'

# Read generate script file to learn more about this CI step.
- name: Generate code coverage report from .xcresult/
run: ./scripts/generate-code-coverage-report.sh
# https://about.codecov.io/blog/pre-converting-xcresult-files-for-codecov-using-xcresultparser/
- name: Generate code coverage report from .xcresult/ that can be converted to codecov format
run: |
brew tap a7ex/homebrew-formulae && brew install xcresultparser
xcresultparser --output-format cobertura "Customer.io-Package.xcresult" > ".build/coverage.xml"
# Disable uploading code coverage for now until we investigate the 500 errors we're getting from Codecov.
# - name: Upload code coverage report
# uses: codecov/codecov-action@v2
# with:
# token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} # not required for public repos, but sometimes uploads fail without it so include it anyway
# fail_ci_if_error: true # fail if upload fails so we can catch it and fix it right away.
# verbose: true
# directory: .build/generated
- name: Upload code coverage report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }} # not required for public repos, but sometimes uploads fail without it so include it anyway
files: .build/coverage.xml
fail_ci_if_error: true # fail if upload fails so we can catch it and fix it right away.
verbose: true

- name: Upload test report
uses: actions/upload-artifact@v3
Expand Down
35 changes: 25 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
// swift-tools-version:5.3

/**
Resources for this file:
Manifest file for Swift Package Manager. This file defines our Swift Package for customers to install our SDK modules into their app.

Resources to learn more about this file:
* https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html
* https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md
*/

import PackageDescription
import Foundation

// Swift Package Manager products are public-facing modules that developers can install into their app.
// All .library() products will be visible to customers in Xcode when they install our SDK into their app.
// Therefore, it's important that we only expose modules that we want customers to use. Internal modules should not be included in this array.
var products: [PackageDescription.Product] = [
.library(name: "Tracking", targets: ["CioTracking"]),
.library(name: "MessagingPushAPN", targets: ["CioMessagingPushAPN"]),
.library(name: "MessagingPushFCM", targets: ["CioMessagingPushFCM"]),
.library(name: "MessagingInApp", targets: ["CioMessagingInApp"])
]

// When we execute the automated test suite, we use tools to determine the code coverage of our tests.
// Xcode generates this code coverage report for us, for all of the products in this Package.swift file.
// It's important that we track the test code coverage of our internal modules, but we don't want to expose internal modules to customers when they install our SDK.
// Therefore, we dynamically modify the products array to include the internal modules only when executing the test suite and generating code coverage reports.
if (ProcessInfo.processInfo.environment["CI"] != nil) { // true if running on a CI machine. Important this is false for a customer trying to install our SDK on their machine.
// append all internal modules to the products array.
products.append(.library(name: "InternalCommon", targets: ["CioInternalCommon"]))
}

let package = Package(
name: "Customer.io",
platforms: [
.iOS(.v13)
],
products: [ // externally visible products for clients to install.
// library name is the name given when installing the SDK.
// target name is the name used for `import X`
.library(name: "Tracking", targets: ["CioTracking"]),
.library(name: "MessagingPushAPN", targets: ["CioMessagingPushAPN"]),
.library(name: "MessagingPushFCM", targets: ["CioMessagingPushFCM"]),
.library(name: "MessagingInApp", targets: ["CioMessagingInApp"])
],
products: products,
dependencies: [
// Help for the format of declaring SPM dependencies:
// https://web.archive.org/web/20220525200227/https://www.timc.dev/posts/understanding-swift-packages/
Expand Down Expand Up @@ -49,7 +64,7 @@ let package = Package(
dependencies: ["CioTracking"],
path: "Tests/Shared",
resources: [
.copy("SampleDataFiles") // static files that are used in test funnctions.
.copy("SampleDataFiles") // static files that are used in test functions.
]),

// Messaging Push
Expand Down
9 changes: 8 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ coverage:
informational: true
project:
default:
informational: true
informational: true

# The file that contains code coverage information may contain coverage for files that we do not want to keep track of.
# Example: We do not want to know the coverage for the Tests/ directory because that does not contain source code of our SDK.
# https://docs.codecov.com/docs/ignoring-paths
ignore:
- "Tests" # ignore code coverage of Test/ files
- "**/*.generated.swift" # Ignore code coverage of generated files.
56 changes: 0 additions & 56 deletions scripts/generate-code-coverage-report.sh

This file was deleted.

0 comments on commit 0ab6e44

Please sign in to comment.