Skip to content
Merged
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
68 changes: 68 additions & 0 deletions .github/workflows/BuildAndTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Test

on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:

jobs:
FormattingLint:
runs-on: macos-15
steps:
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1.2.0
- name: SwiftFormat
run: |
base_branch="${{ github.base_ref }}"
echo "swiftformat --lint $(git diff --name-only origin/$base_branch...HEAD) --reporter github-actions-log"

SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@50fbc622fc4ef5163becd7fab6573eac35f8462e # v1.2.0
- name: GitHub Action for SwiftLint (Only files changed in the PR)
uses: norio-nomura/action-swiftlint@9f4dcd7fd46b4e75d7935cf2f4df406d5cae3684 # 3.2.1
env:
args: --strict
DIFF_BASE: ${{ github.base_ref }}
macOS:
runs-on: macos-15
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
- name: Build and Test for macOS
run: swift test --enable-code-coverage
- name: Upload Code coverage
run: |
curl -Os https://uploader.codecov.io/latest/macos/codecov
chmod +x codecov
xcrun llvm-cov export -ignore-filename-regex="pb\.swift|grpc\.swift" -format="lcov" .build/debug/aws-otel-swiftPackageTests.xctest/Contents/MacOS/aws-otel-swiftPackageTests -instr-profile .build/debug/codecov/default.profdata > .build/debug/codecov/coverage_report.lcov
./codecov -f .build/debug/codecov/coverage_report.lcov
iOS:
runs-on: macos-15
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
- name: Install Homebrew kegs
run: make setup-brew
- name: Build for iOS
run: make build-for-testing-ios
- name: Test for iOS
run: make test-without-building-ios
tvOS:
runs-on: macos-15
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
- name: Install Homebrew kegs
run: make setup-brew
- name: Build for tvOS
run: make build-for-testing-tvos
- name: Test for tvOS
run: make test-without-building-tvos
watchOS:
runs-on: macos-15
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
- name: Install Homebrew kegs
run: make setup-brew
- name: Build for watchOS
run: make build-for-testing-watchos
- name: Test for watchOS
run: make test-without-building-watchos
77 changes: 77 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
PROJECT_NAME="aws-otel-swift-Package"

XCODEBUILD_OPTIONS_IOS=\
-configuration Debug \
-destination platform='iOS Simulator,name=iPhone 16,OS=18.0' \
-scheme $(PROJECT_NAME) \
-test-iterations 5 \
-retry-tests-on-failure \
-workspace .

XCODEBUILD_OPTIONS_TVOS=\
-configuration Debug \
-destination platform='tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0' \
-scheme $(PROJECT_NAME) \
-test-iterations 5 \
-retry-tests-on-failure \
-workspace .

XCODEBUILD_OPTIONS_WATCHOS=\
-configuration Debug \
-destination platform='watchOS Simulator,name=Apple Watch Series 10 (46mm),OS=11.0' \
-scheme $(PROJECT_NAME) \
-test-iterations 5 \
-retry-tests-on-failure \
-workspace .

.PHONY: setup-brew
setup-brew:
brew update && brew install xcbeautify

.PHONY: build-ios
build-ios:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) build | xcbeautify

.PHONY: build-tvos
build-tvos:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_TVOS) build | xcbeautify

.PHONY: build-watchos
build-watchos:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) build | xcbeautify

.PHONY: build-for-testing-ios
build-for-testing-ios:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) build-for-testing | xcbeautify

.PHONY: build-for-testing-tvos
build-for-testing-tvos:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_TVOS) build-for-testing | xcbeautify

.PHONY: build-for-testing-watchos
build-for-testing-watchos:
set -o pipefail && xcodebuild OTHER_LDFLAGS="$(OTHER_LDFLAGS) -fprofile-instr-generate" $(XCODEBUILD_OPTIONS_WATCHOS) build-for-testing | xcbeautify

.PHONY: test-ios
test-ios:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) test | xcbeautify

.PHONY: test-tvos
test-tvos:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_TVOS) test | xcbeautify

.PHONY: test-watchos
test-watchos:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_WATCHOS) test | xcbeautify

.PHONY: test-without-building-ios
test-without-building-ios:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_IOS) test-without-building | xcbeautify

.PHONY: test-without-building-tvos
test-without-building-tvos:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_TVOS) test-without-building | xcbeautify

.PHONY: test-without-building-watchos
test-without-building-watchos:
set -o pipefail && xcodebuild $(XCODEBUILD_OPTIONS_WATCHOS) test-without-building | xcbeautify
14 changes: 11 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ let package = Package(
.product(name: "OpenTelemetryApi", package: "opentelemetry-swift"),
.product(name: "OpenTelemetrySdk", package: "opentelemetry-swift"),
.product(name: "StdoutExporter", package: "opentelemetry-swift"),
.product(name: "ResourceExtension", package: "opentelemetry-swift"),
.product(name: "URLSessionInstrumentation", package: "opentelemetry-swift"),
.product(name: "OpenTelemetryProtocolExporterHTTP", package: "opentelemetry-swift")
]
),
Expand All @@ -49,4 +47,14 @@ let package = Package(
dependencies: ["AwsOpenTelemetryCore"]
)
]
)
).addPlatformSpecific()

extension Package {
func addPlatformSpecific() -> Self {
#if canImport(Darwin)
targets[0].dependencies
.append(.product(name: "ResourceExtension", package: "opentelemetry-swift"))
#endif
return self
}
}
7 changes: 0 additions & 7 deletions Sources/AwsOpenTelemetryCore/AwsOpenTelemetryAgent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@

import Foundation

import OpenTelemetryApi
import OpenTelemetrySdk
import StdoutExporter
import ResourceExtension
import URLSessionInstrumentation
import OpenTelemetryProtocolExporterHttp

/**
* This class provides a singleton instance and methods to initialize
* the OpenTelemetry SDK with AWS-specific configurations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import OpenTelemetryProtocolExporterHttp
import OpenTelemetrySdk
import ResourceExtension
import StdoutExporter
import URLSessionInstrumentation

/**
* Main entry point for the AWS OpenTelemetry SDK.
Expand Down
Loading