Skip to content

Commit

Permalink
[CIVIS-8070] added required_git option handling (#103)
Browse files Browse the repository at this point in the history
* added requiredGit option handling
* better logs for ITR configuration
* better skippable test request and response types
* updated makefile and github actions
* enabled debug for integration tests
  • Loading branch information
ypopovych authored May 17, 2024
1 parent 277c371 commit e37df34
Show file tree
Hide file tree
Showing 12 changed files with 329 additions and 230 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/createRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ jobs:
- name: Select Xcode 14
run: sudo xcode-select --switch /Applications/Xcode_14.1.app
- name: Test
run: make tests/pretty
run: make XC_LOG=tests tests
- name: Attach Xcode logs
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: xcode-tests-logs
path: "*-tests.log"

release:
needs: [test]
Expand All @@ -27,4 +33,10 @@ jobs:
- name: Build and upload XCFrameworks, recreate tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make version=${{ github.event.release.tag_name }} github
run: make XC_LOG=archive version=${{ github.event.release.tag_name }} github
- name: Attach Xcode logs
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: xcode-archive-logs
path: "*-archive.log"
52 changes: 26 additions & 26 deletions .github/workflows/integrationTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
workflow_dispatch:

jobs:
test-13-Integration-Unit:
name: Run Tests macOS 13.0
test-13-Unit:
name: Run Unit Tests macOS 13.0
runs-on: macos-13
strategy:
fail-fast: false
Expand All @@ -19,34 +19,34 @@ jobs:
- name: Select ${{ matrix.xcode }}
run: sudo xcode-select --switch /Applications/${{ matrix.xcode }}.app
- name: Unit tests
run: make tests/unit/pretty
run: make XC_LOG=unit tests/unit
- name: Attach Xcode logs
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.xcode }}-unit-logs
path: "*-unit.log"

test-Integration-macOS:
runs-on: macos-latest
env:
DD_API_KEY: '${{ secrets.DD_API_KEY }}'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: tests macOS
run: make tests/integration/macOS/pretty

test-Integration-iOS:
runs-on: macos-latest
test-13-Integration:
name: Run Integration Tests macOS 13.0 Xcode 14.3.1
runs-on: macos-13
strategy:
fail-fast: false
matrix:
platform: ["macOS", "iOSsim", "tvOSsim"]
env:
DD_API_KEY: '${{ secrets.DD_API_KEY }}'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: tests iOS
run: make tests/integration/iOS/pretty
- name: Select Xcode
run: sudo xcode-select --switch /Applications/Xcode_14.3.1.app
- name: Run tests for ${{ matrix.platform }}
run: make XC_LOG=integration tests/integration/${{ matrix.platform }}
- name: Attach Xcode logs
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: Xcode_14.3.1-${{ matrix.platform }}-integration-log
path: "*-integration.log"

test-Integration-tvOS:
runs-on: macos-latest
env:
DD_API_KEY: '${{ secrets.DD_API_KEY }}'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: tests tvOS
run: make tests/integration/tvOS/pretty
4 changes: 4 additions & 0 deletions IntegrationTests/UITests/IntegrationTestsUITests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
{
"key" : "GITHUB_WORKFLOW",
"value" : "$(GITHUB_WORKFLOW)"
},
{
"key" : "DD_TRACE_DEBUG",
"value" : "1"
}
],
"targetForVariableExpansion" : {
Expand Down
160 changes: 74 additions & 86 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,65 @@
check_defined = $(strip $(foreach 1,$1, $(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = $(if $(value $1),, $(error Undefined $1$(if $2, ($2))$(if $(value @), required by target '$@')))

build/DatadogSDKTesting/ios:
xcodebuild archive -scheme DatadogSDKTesting -destination "generic/platform=iOS" -archivePath build/DatadogSDKTesting/iphoneos.xcarchive -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive -scheme DatadogSDKTesting -destination "generic/platform=iOS Simulator" -archivePath build/DatadogSDKTesting/iphonesimulator.xcarchive -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

build/DatadogSDKTesting/mac:
xcodebuild archive -scheme DatadogSDKTesting -destination "generic/platform=macOS" -archivePath build/DatadogSDKTesting/macos.xcarchive -sdk macosx SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive -scheme DatadogSDKTesting -destination "generic/platform=macOS,variant=Mac Catalyst" -archivePath build/DatadogSDKTesting/maccatalyst.xcarchive -sdk macosx SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES


build/DatadogSDKTesting/tvos:
xcodebuild archive -scheme DatadogSDKTesting -destination "generic/platform=tvOS" -archivePath build/DatadogSDKTesting/appletvos.xcarchive -sdk appletvos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive -scheme DatadogSDKTesting -destination "generic/platform=tvOS Simulator" -archivePath build/DatadogSDKTesting/appletvsimulator.xcarchive -sdk appletvsimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES

build/DatadogSDKTesting.xcframework: build/DatadogSDKTesting/ios build/DatadogSDKTesting/mac build/DatadogSDKTesting/tvos
mkdir -p $(PWD)/build/xcframework
xcodebuild -create-xcframework -framework build/DatadogSDKTesting/macos.xcarchive/Products/Library/Frameworks/DatadogSDKTesting.framework -framework build/DatadogSDKTesting/iphoneos.xcarchive/Products/Library/Frameworks/DatadogSDKTesting.framework -framework build/DatadogSDKTesting/iphonesimulator.xcarchive/Products/Library/Frameworks/DatadogSDKTesting.framework -framework build/DatadogSDKTesting/appletvos.xcarchive/Products/Library/Frameworks/DatadogSDKTesting.framework -framework build/DatadogSDKTesting/appletvsimulator.xcarchive/Products/Library/Frameworks/DatadogSDKTesting.framework -output build/xcframework/DatadogSDKTesting.xcframework

build/xcframework/DatadogSDKTesting.zip: build/DatadogSDKTesting.xcframework
cd ./build/xcframework/; zip -ry ./DatadogSDKTesting.zip ./DatadogSDKTesting.xcframework

build/xcframework: build/xcframework/DatadogSDKTesting.zip

collect_symbols:
mkdir -p $(PWD)/build/symbols
mkdir -p $(PWD)/build/symbols/macos
cp -R build/DatadogSDKTesting/macos.xcarchive/dSYMs/DatadogSDKTesting.framework.dSYM $(PWD)/build/symbols/macos/DatadogSDKTesting.framework.dSYM
mkdir -p $(PWD)/build/symbols/iphoneos
cp -R build/DatadogSDKTesting/iphoneos.xcarchive/dSYMs/DatadogSDKTesting.framework.dSYM $(PWD)/build/symbols/iphoneos/DatadogSDKTesting.framework.dSYM
mkdir -p $(PWD)/build/symbols/iphonesimulator
cp -R build/DatadogSDKTesting/iphonesimulator.xcarchive/dSYMs/DatadogSDKTesting.framework.dSYM $(PWD)/build/symbols/iphonesimulator/DatadogSDKTesting.framework.dSYM
mkdir -p $(PWD)/build/symbols/appletvos
cp -R build/DatadogSDKTesting/appletvos.xcarchive/dSYMs/DatadogSDKTesting.framework.dSYM $(PWD)/build/symbols/appletvos/DatadogSDKTesting.framework.dSYM
mkdir -p $(PWD)/build/symbols/appletvsimulator
cp -R build/DatadogSDKTesting/appletvsimulator.xcarchive/dSYMs/DatadogSDKTesting.framework.dSYM $(PWD)/build/symbols/appletvsimulator/DatadogSDKTesting.framework.dSYM
mkdir -p $(PWD)/build/symbols/maccatalyst
cp -R build/DatadogSDKTesting/maccatalyst.xcarchive/dSYMs/DatadogSDKTesting.framework.dSYM $(PWD)/build/symbols/maccatalyst/DatadogSDKTesting.framework.dSYM
cd ./build/; zip -ry ./symbols.zip ./symbols

build: build/xcframework collect_symbols
# params: scheme, platform, logfile
define xctest
$(if $(filter $2,macOS),$(eval SDK=macosx)$(eval DEST='platform=macOS,arch=x86_64'),)
$(if $(filter $2,iOSsim),$(eval SDK=iphonesimulator)$(eval DEST='platform=iOS Simulator,name=iPhone 14'),)
$(if $(filter $2,tvOSsim),$(eval SDK=appletvsimulator)$(eval DEST='platform=tvOS Simulator,name=Apple TV'),)
$(if $3,\
set -o pipefail; xcodebuild -scheme $1 -sdk $(SDK) -destination $(DEST) test | tee $1-$2-$3.log | xcbeautify,\
xcodebuild -scheme $1 -sdk $(SDK) -destination $(DEST) test)
endef

## params: scheme, sdk, destination, name, logfile
define xcarchive
$(if $5,\
set -o pipefail; xcodebuild archive -scheme $1 -sdk $2 -destination $3 -archivePath \
build/$1/$4.xcarchive SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES | tee $1-$4-$5.log | xcbeautify,\
xcodebuild archive -scheme $1 -sdk $2 -destination $3 -archivePath build/$1/$4.xcarchive SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES)
endef

build/%/iphoneos.xcarchive:
$(call xcarchive,$*,iphoneos,'generic/platform=iOS',iphoneos,$(XC_LOG))

build/%/iphonesimulator.xcarchive:
$(call xcarchive,$*,iphonesimulator,'generic/platform=iOS Simulator',iphonesimulator,$(XC_LOG))

build/%/macos.xcarchive:
$(call xcarchive,$*,macosx,'generic/platform=macOS',macos,$(XC_LOG))

build/%/maccatalyst.xcarchive:
$(eval platform = 'generic/platform=macOS,variant=Mac Catalyst')
$(call xcarchive,$*,macosx,$(platform),maccatalyst,$(XC_LOG))

build/%/appletvos.xcarchive:
$(call xcarchive,$*,appletvos,'generic/platform=tvOS',appletvos,$(XC_LOG))

build/%/appletvsimulator.xcarchive:
$(call xcarchive,$*,appletvsimulator,'generic/platform=tvOS Simulator',appletvsimulator,$(XC_LOG))

build/xcframework/%.xcframework: \
build/%/iphoneos.xcarchive build/%/iphonesimulator.xcarchive \
build/%/macos.xcarchive build/%/maccatalyst.xcarchive \
build/%/appletvos.xcarchive build/%/appletvsimulator.xcarchive
@mkdir -p $(PWD)/build/xcframework
@xargs xcodebuild -create-xcframework -output $@ <<<"$(foreach archive,$^,-framework $(archive)/Products/Library/Frameworks/$*.framework)"

build/xcframework/%.zip: build/xcframework/%.xcframework
cd ./build/xcframework/; zip -ry ./$*.zip ./$*.xcframework

build/symbols/%.zip: \
build/%/iphoneos.xcarchive build/%/iphonesimulator.xcarchive \
build/%/macos.xcarchive build/%/maccatalyst.xcarchive \
build/%/appletvos.xcarchive build/%/appletvsimulator.xcarchive
@for archive in $^ ; do \
name=$$(basename $$archive | cut -d'.' -f1) ;\
mkdir -p $(PWD)/build/symbols/$*/$$name ;\
cp -R $$archive/dSYMs/*.dSYM $(PWD)/build/symbols/$*/$$name/ ;\
done
@cd $(PWD)/build/symbols/$*; zip -ry ../$*.symbols.zip ./*

build: build/xcframework/DatadogSDKTesting.zip build/symbols/DatadogSDKTesting.zip

set_version:
@:$(call check_defined, version, release version)
Expand All @@ -54,7 +74,7 @@ set_hash:
$(eval HASH := $(shell swift package compute-checksum ./build/xcframework/DatadogSDKTesting.zip))
sed -i "" "s|:sha256 =>.*|:sha256 => '$(HASH)'|g" DatadogSDKTesting.podspec
sed -i "" "s|let[[:blank:]]*relaseChecksum.*|let relaseChecksum = \"$(HASH)\"|g" Package.swift

release: set_version build set_hash

github: release
Expand All @@ -63,64 +83,32 @@ github: release
# Upload binary file to GitHub release
brew list gh &>/dev/null || brew install gh
@echo $(GITHUB_TOKEN) | gh auth login --with-token
# upload xcframework
gh release upload $(version) ./build/xcframework/DatadogSDKTesting.zip --clobber
gh release upload $(version) ./build/symbols.zip --clobber
# upload symbols
rm -f build/symbols/DatadogSDKTesting.symbols.zip
mv build/symbols/DatadogSDKTesting.zip build/symbols/DatadogSDKTesting.symbols.zip
gh release upload $(version) ./build/symbols/DatadogSDKTesting.symbols.zip --clobber
# Commit updated xcodeproj, Package.swift and DatadogSDKTesting.podspec
git add Package.swift DatadogSDKTesting.podspec DatadogSDKTesting.xcodeproj/project.pbxproj
git checkout -b update-binary
git commit -m "Updated binary package version to $(version)"
git tag -f $(version)
git push -f --tags origin update-binary

clean:
rm -rf ./build

tests/unit/exporter:
xcodebuild -scheme EventsExporter -sdk macosx -destination 'platform=macOS,arch=x86_64' test
xcodebuild -scheme EventsExporter -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' test
xcodebuild -scheme EventsExporter -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' test

tests/unit/exporter/pretty:
set -o pipefail; xcodebuild -scheme EventsExporter -sdk macosx -destination 'platform=macOS,arch=x86_64' test | xcbeautify
set -o pipefail; xcodebuild -scheme EventsExporter -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' test | xcbeautify
set -o pipefail; xcodebuild -scheme EventsExporter -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' test | xcbeautify

tests/unit/sdk:
xcodebuild -scheme DatadogSDKTesting -sdk macosx -destination 'platform=macOS,arch=x86_64' test
xcodebuild -scheme DatadogSDKTesting -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' test
xcodebuild -scheme DatadogSDKTesting -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' test

tests/unit/sdk/pretty:
set -o pipefail; xcodebuild -scheme DatadogSDKTesting -sdk macosx -destination 'platform=macOS,arch=x86_64' test | xcbeautify
set -o pipefail; xcodebuild -scheme DatadogSDKTesting -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' test | xcbeautify
set -o pipefail; xcodebuild -scheme DatadogSDKTesting -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' test | xcbeautify

tests/integration/macOS:
xcodebuild -scheme IntegrationTests -sdk macosx -destination 'platform=macOS,arch=x86_64' test

tests/integration/macOS/pretty:
set -o pipefail; xcodebuild -scheme IntegrationTests -sdk macosx -destination 'platform=macOS,arch=x86_64' test | xcbeautify

tests/integration/iOS:
xcodebuild -scheme IntegrationTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' test
tests/unit/%:
$(call xctest,$*,macOS,$(XC_LOG))
$(call xctest,$*,iOSsim,$(XC_LOG))
$(call xctest,$*,tvOSsim,$(XC_LOG))

tests/integration/iOS/pretty:
set -o pipefail; xcodebuild -scheme IntegrationTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' test | xcbeautify

tests/integration/tvOS:
xcodebuild -scheme IntegrationTests -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' test

tests/integration/tvOS/pretty:
set -o pipefail; xcodebuild -scheme IntegrationTests -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' test | xcbeautify

tests/unit: tests/unit/exporter tests/unit/sdk

tests/unit/pretty: tests/unit/exporter/pretty tests/unit/sdk/pretty

tests/integration: tests/integration/macOS tests/integration/iOS tests/integration/tvOS
tests/integration/%:
$(call xctest,IntegrationTests,$*,$(XC_LOG))

tests/integration/pretty: tests/integration/macOS/pretty tests/integration/iOS/pretty tests/integration/tvOS/pretty
tests/unit: tests/unit/EventsExporter tests/unit/DatadogSDKTesting

tests/pretty: tests/unit/pretty
tests/integration: tests/integration/macOS tests/integration/iOSsim tests/integration/tvOSsim

tests: tests/unit
Loading

0 comments on commit e37df34

Please sign in to comment.