Skip to content
Open
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
8 changes: 8 additions & 0 deletions .ci/changed-file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ android:
- &exclude-docs-directory '!**/docs/**'
swift:
- 'platforms/swift/**'
- 'telemetry/languages/swift/**'
- *exclude-markdown
- *exclude-docs-directory
reactNative:
Expand All @@ -14,8 +15,15 @@ reactNative:
- *exclude-docs-directory
web:
- 'platforms/web/**'
- 'telemetry/languages/typescript/**'
- 'telemetry/contract/**'
- *exclude-markdown
- *exclude-docs-directory
# Markdown stays included here: the metrics contract is a markdown document
# and contract changes must run the telemetry checks.
telemetry:
- 'telemetry/**'
- *exclude-docs-directory
protocol:
- 'protocol/**'
- *exclude-markdown
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/android-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ jobs:

- name: Publish Package
run: |
./gradlew \
:lib:publishReleasePublicationToOssrh-staging-apiRepository
./gradlew :lib:publishReleasePublicationToOssrh-staging-apiRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
reactNativeIos: ${{ steps.platform.outputs.reactNative == 'true' || steps.platform.outputs.protocolTypescript == 'true' || steps.platform.outputs.protocolShared == 'true' || steps.infra.outputs.reactNativeCommon == 'true' || steps.infra.outputs.reactNativeIos == 'true' }}
reactNativeAndroid: ${{ steps.platform.outputs.reactNative == 'true' || steps.platform.outputs.protocolTypescript == 'true' || steps.platform.outputs.protocolShared == 'true' || steps.infra.outputs.reactNativeCommon == 'true' || steps.infra.outputs.reactNativeAndroid == 'true' }}
web: ${{ steps.platform.outputs.web == 'true' || steps.platform.outputs.protocolTypescript == 'true' || steps.platform.outputs.protocolShared == 'true' || steps.infra.outputs.web == 'true' }}
telemetry: ${{ steps.platform.outputs.telemetry == 'true' || steps.infra.outputs.telemetry == 'true' }}
protocol: ${{ steps.platform.outputs.protocolTypescript == 'true' || steps.platform.outputs.protocolShared == 'true' || steps.infra.outputs.protocol == 'true' }}
scripts: ${{ steps.infra.outputs.scripts == 'true' }}
steps:
Expand Down Expand Up @@ -101,6 +102,11 @@ jobs:
- '.github/actions/setup/**'
- '.ci/changed-file-filters.yml'
- '.github/workflows/ci.yml'
telemetry:
- '.github/workflows/telemetry-test.yml'
- '.github/actions/setup/**'
- '.ci/changed-file-filters.yml'
- '.github/workflows/ci.yml'
protocol:
- '.github/workflows/protocol-test.yml'
- '.github/actions/setup/**'
Expand Down Expand Up @@ -208,6 +214,14 @@ jobs:
pull-requests: write
uses: ./.github/workflows/web.yml

telemetry-test:
name: Telemetry
needs: changes
if: needs.changes.outputs.telemetry == 'true'
permissions:
contents: read
uses: ./.github/workflows/telemetry-test.yml

protocol-test:
name: Protocol
needs: changes
Expand Down Expand Up @@ -265,6 +279,7 @@ jobs:
- rn-check-packed-files
- rn-lint
- web
- telemetry-test
- protocol-test
- scripts-test
- breaking-changes
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/telemetry-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Telemetry

on:
workflow_call:
workflow_dispatch:

jobs:
test:
name: Typecheck, lint, test
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
defaults:
run:
# The TypeScript telemetry package is a member of the web pnpm
# workspace, so dependency install and filtered runs happen there.
Comment on lines +16 to +17

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke my brain for a second - not introduced by your PR but that workspace file shouldn't sit in the web package

working-directory: platforms/web
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js, pnpm, and install dependencies
uses: ./.github/actions/setup
with:
node-version-file: platforms/web/package.json
cache-dependency-path: platforms/web/pnpm-lock.yaml
package-json-file: platforms/web/package.json
working-directory: platforms/web

- name: Typecheck
run: pnpm --filter @shopify/checkout-kit-telemetry run typecheck

- name: Lint
run: pnpm --filter @shopify/checkout-kit-telemetry run lint

- name: Test
run: pnpm --filter @shopify/checkout-kit-telemetry run test
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ disabled_rules:
included:
- platforms/swift/Sources
- platforms/swift/Tests
- telemetry/languages/swift/Sources
- telemetry/languages/swift/Tests

excluded:
- platforms/swift/Samples
Expand Down
16 changes: 13 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
.library(
name: "EmbeddedCheckoutProtocol",
targets: ["EmbeddedCheckoutProtocol"]
)
),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -36,8 +36,13 @@ let package = Package(
path: "protocol/languages/swift/Sources/UniversalCommerceProtocol/EmbeddedCheckoutProtocol"
),
.target(
name: "ShopifyCheckoutKit",
name: "CheckoutKitTelemetry",
dependencies: ["EmbeddedCheckoutProtocol"],
path: "telemetry/languages/swift/Sources/CheckoutKitTelemetry"
),
.target(
name: "ShopifyCheckoutKit",
dependencies: ["EmbeddedCheckoutProtocol", "CheckoutKitTelemetry"],
path: "platforms/swift/Sources/ShopifyCheckoutKit",
resources: [.process("Assets.xcassets")]
),
Expand All @@ -53,9 +58,14 @@ let package = Package(
path: "protocol/languages/swift/Tests/EmbeddedCheckoutProtocolTests",
resources: [.copy("Fixtures")]
),
.testTarget(
name: "CheckoutKitTelemetryTests",
dependencies: ["CheckoutKitTelemetry"],
path: "telemetry/languages/swift/Tests/CheckoutKitTelemetryTests"
),
.testTarget(
name: "ShopifyCheckoutKitTests",
dependencies: ["ShopifyCheckoutKit"],
dependencies: ["ShopifyCheckoutKit", "CheckoutKitTelemetry"],
path: "platforms/swift/Tests/ShopifyCheckoutKitTests"
),
.testTarget(
Expand Down
1 change: 1 addition & 0 deletions ShopifyCheckoutKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Pod::Spec.new do |s|
core.source_files = [
'platforms/swift/Sources/ShopifyCheckoutKit/**/*.swift',
'protocol/languages/swift/Sources/UniversalCommerceProtocol/EmbeddedCheckoutProtocol/**/*.swift',
'telemetry/languages/swift/Sources/CheckoutKitTelemetry/**/*.swift',
]
core.resource_bundles = {
'ShopifyCheckoutKit' => ['platforms/swift/Sources/ShopifyCheckoutKit/Assets.xcassets']
Expand Down
51 changes: 51 additions & 0 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ commands:
/opt/dev/bin/dev react-native lint
/opt/dev/bin/dev web lint
/opt/dev/bin/dev protocol lint
/opt/dev/bin/dev telemetry typecheck

test:
desc: Run tests across all supported workspaces
Expand All @@ -146,6 +147,7 @@ commands:
/opt/dev/bin/dev react-native test
/opt/dev/bin/dev web test
/opt/dev/bin/dev protocol test typescript
/opt/dev/bin/dev telemetry test typescript

apollo:
desc: "Apollo GraphQL schema and code generation commands"
Expand Down Expand Up @@ -237,6 +239,55 @@ commands:
desc: Verify protocol codegen tools match protocol/package.json
run: ./protocol/scripts/check_codegen_tools.sh "$@"

telemetry:
desc: "Checkout telemetry package commands"
subcommands:
test:
desc: "Run telemetry tests for every language, or a single one. Usage: dev telemetry test [typescript|swift|kotlin]"
syntax: "[typescript|swift|kotlin]"
run: |
set -e
run_typescript() { (cd telemetry/languages/typescript && pnpm test); }
run_swift() {
# xcode_run only auto-discovers test targets under
# platforms/swift/Tests, so pass the telemetry target/suite
# pair explicitly.
(cd platforms/swift && ./Scripts/xcode_run test ShopifyCheckoutKit-Package CheckoutKitTelemetryTests/CheckoutKitTelemetryTests)
}
run_kotlin() {
platforms/android/gradlew -p platforms/android :lib:testDebugUnitTest \
--tests "com.shopify.checkoutkit.telemetry.*" \
--tests "com.shopify.checkoutkit.Telemetry*" \
--console=plain
}
case "${1:-all}" in
typescript|ts) run_typescript ;;
swift|ios) run_swift ;;
kotlin|android) run_kotlin ;;
all) run_typescript; run_swift; run_kotlin ;;
*) echo "Usage: dev telemetry test [typescript|swift|kotlin]"; exit 1 ;;
esac
typecheck:
desc: "Type-check the TypeScript telemetry package"
run: cd telemetry/languages/typescript && pnpm typecheck
lint:
desc: "Lint the TypeScript and Swift telemetry sources (Kotlin lives in the Android lib and is covered by dev android lint)"
run: |
set -e
(cd telemetry/languages/typescript && pnpm lint)
# SwiftLint's scope comes from .swiftlint.yml's `included`, which
# covers the telemetry Swift sources. Use the Mintfile-pinned
# binary so results match CI.
swiftlint_bin="$(cd platforms/swift && mint which swiftlint)"
"$swiftlint_bin" lint --strict --no-cache --quiet
check:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should update all of the dev.yml changes to include kotlin/swift, test / check / lint etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — dev telemetry test now takes typescript/swift/kotlin and runs all three by default, and check aggregates typecheck + lint + tests. On lint: the Swift telemetry sources weren't in SwiftLint's scope at all, so I've added them; Kotlin was already covered by detekt inside the lib, and the TS package now has its own oxlint script.

desc: "Type-check, lint, and test the telemetry packages in every language"
run: |
set -e
/opt/dev/bin/dev telemetry typecheck
/opt/dev/bin/dev telemetry lint
/opt/dev/bin/dev telemetry test

# Android
android:
aliases: ["kotlin"]
Expand Down
1 change: 0 additions & 1 deletion platforms/android/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ dependencies {
mockitoAgent libs.mockito.core

api project(':embedded-checkout-protocol')

testImplementation libs.junit
testImplementation libs.robolectric
testImplementation libs.mockito.core
Expand Down
Loading
Loading