Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .ci/changed-file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ ciFilters:
# decide which macOS jobs run, so a change to one has to rerun them all, while a Maestro
# flow edit under e2e/ must not.
iosCiConfig:
- '.ci/coverage-thresholds.json'
- 'scripts/check_coverage'
- 'scripts/lib/coverage_thresholds.rb'
- 'scripts/report_coverage'
- 'scripts/lib/coverage_report.rb'
- 'e2e/bitrise.yml'
Expand Down
8 changes: 7 additions & 1 deletion .ci/coverage-thresholds.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"android": {"Lines": 85}
"android": {
"Lines": 85
},
"swift": {
"ShopifyCheckoutKit": 85,
"ShopifyAcceleratedCheckouts": 85
}
}
5 changes: 4 additions & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,10 @@ commands:
subcommands:
coverage:
desc: Run Swift package tests and export Xcode coverage reports
run: cd platforms/swift && ./Scripts/test_coverage
run: |
set -e
platforms/swift/Scripts/test_coverage
ruby scripts/check_coverage swift .xcresults/coverage/coverage.json
sample:
desc: Run the sample app test target
syntax: "[test_class_name]"
Expand Down
16 changes: 9 additions & 7 deletions e2e/bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,9 @@ workflows:
set -euo pipefail
cd platforms/swift
./Scripts/test_coverage
ruby ../../scripts/check_coverage swift ../../.xcresults/coverage/coverage.json
- deploy-to-bitrise-io@2:
is_always_run: false
is_always_run: true
inputs:
- deploy_path: "$BITRISE_SOURCE_DIR/.xcresults/coverage"
- script@1:
Expand All @@ -373,12 +374,16 @@ workflows:

- script@1:
title: Run Embedded Checkout Protocol Swift coverage
is_always_run: true
inputs:
- content: |-
set -euo pipefail
./protocol/scripts/test_swift_coverage
outcome=success
./protocol/scripts/test_swift_coverage || outcome=failure
envman add --key PROTOCOL_SWIFT_TEST_OUTCOME --value "$outcome"
test "$outcome" = success
- deploy-to-bitrise-io@2:
is_always_run: false
is_always_run: true
inputs:
- deploy_path: "$BITRISE_SOURCE_DIR/protocol/languages/swift/.build/coverage"
- script@1:
Expand All @@ -392,10 +397,7 @@ workflows:
export COVERAGE_SHA="${BITRISE_GIT_COMMIT:-}"
export COVERAGE_REPORT_URL="${BITRISE_BUILD_URL:-}"
export COVERAGE_TOKEN="${OVERRIDE_GITHUB_TOKEN:-${GIT_HTTP_PASSWORD:-}}"
export COVERAGE_TEST_OUTCOME=success
if [ "${BITRISE_BUILD_STATUS:-0}" != "0" ]; then
export COVERAGE_TEST_OUTCOME=failure
fi
export COVERAGE_TEST_OUTCOME="${PROTOCOL_SWIFT_TEST_OUTCOME:-failure}"
ruby scripts/report_coverage protocol-swift protocol/languages/swift/.build/coverage/coverage.json

ci-ios-swift-samples:
Expand Down
9 changes: 9 additions & 0 deletions scripts/test/coverage_thresholds_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def test_every_configured_target_must_pass_independently
assert_equal ["Second: 70.00% (70/100) is below 85%"], result
end

def test_swift_targets_use_individual_thresholds_from_the_committed_configuration
configuration = JSON.parse(File.read(File.expand_path("../../.ci/coverage-thresholds.json", __dir__)))
checker = CoverageThresholds.new(configuration)
report = Report.new("swift", [["ShopifyCheckoutKit", 99, 100], ["ShopifyAcceleratedCheckouts", 84, 100]])
assert_equal ["ShopifyAcceleratedCheckouts: 84.00% (84/100) is below 85%"], checker.failures(report)
report.rows[1][1] = 85
assert_empty checker.failures(report)
end

def test_invalid_configuration_fails_closed
assert_raises(KeyError) { threshold_failures([], {}) }
[-1, 101, "85", Float::NAN].each do |minimum|
Expand Down
Loading