diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..76b6841 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,25 @@ +codecov: + branch: main + require_ci_to_pass: yes + notify: + wait_for_ci: yes + +coverage: + range: 80...100 + precision: 3 + round: down + +ignore: + - "EmpowerPlantTests/*" + +comment: + layout: "reach,diff,flags,files,footer" + # Update, if comment exists. Otherwise post new. + behavior: default + # Comments will only post when coverage changes. Furthermore, if a comment + # already exists, and a newer commit results in no coverage change for the + # entire pull, the comment will be deleted. + require_changes: true + require_base: yes # must have a base report to post + require_head: yes # must have a head report to post + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b74cdc8..f90386b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,30 +1,21 @@ name: test.yml on: - push: - branches: - - integrate_codecov - workflow_dispatch: + pull_request: jobs: build: - runs-on: macos-latest + runs-on: macos-14 steps: - name: Checkout code uses: actions/checkout@v3 - - name: Install Bundler - run: gem install bundler - - - name: Install dependencies - run: bundle install + - name: Install Slather + run: gem install slather - name: Build and Test - run: | - swift build - swift test - - - name: Generate Coverage Report - run: | - xcrun xccov view --report /Logs/Test/*.xccovreport > coverage.txt + run: make test + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 diff --git a/.github/workflows/upload-codecov-report.yml b/.github/workflows/upload-codecov-report.yml deleted file mode 100644 index c9b9edb..0000000 --- a/.github/workflows/upload-codecov-report.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: upload-codecov-report.yml -on: [push] -jobs: - main: - runs-on: ubuntu-latest - steps: - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index a53a8ed..611f2ac 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .env build/ release-build.log -EmpowerPlant_release.zip \ No newline at end of file +EmpowerPlant_release.zip +slather/ \ No newline at end of file diff --git a/.slather.yml b/.slather.yml new file mode 100644 index 0000000..9999fea --- /dev/null +++ b/.slather.yml @@ -0,0 +1,6 @@ +coverage_service: cobertura_xml +xcodeproj: EmpowerPlant.xcodeproj +scheme: EmpowerPlant +source_directory: EmpowerPlant +output_directory: slather +build_directory: build diff --git a/EmpowerPlant.xcodeproj/project.pbxproj b/EmpowerPlant.xcodeproj/project.pbxproj index 1b96a20..22c682f 100644 --- a/EmpowerPlant.xcodeproj/project.pbxproj +++ b/EmpowerPlant.xcodeproj/project.pbxproj @@ -39,12 +39,14 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 840B7EF12BBF3C70008B8120 /* .slather.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .slather.yml; sourceTree = ""; }; 843BD60E2AD08CE900B0098F /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; 843BD6262AD7798C00B0098F /* jwt-deep-field.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "jwt-deep-field.png"; sourceTree = ""; }; 846BEA1A2ABE46880032F77F /* upload-symbols.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "upload-symbols.sh"; sourceTree = ""; }; 846BEA1B2ABE611A0032F77F /* mobydick.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = mobydick.txt; sourceTree = ""; }; 8474F0482ACCE2D800F21E06 /* deploy_project.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = deploy_project.sh; sourceTree = ""; }; 8474F04D2ACE54F300F21E06 /* .github */ = {isa = PBXFileReference; lastKnownFileType = folder; path = .github; sourceTree = ""; }; + 848A45262BBFC79E006AAAEC /* .codecov.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .codecov.yml; sourceTree = ""; }; 84A264182AA9155800A62A88 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = ""; }; 84A264192AA915B100A62A88 /* Brewfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Brewfile; sourceTree = ""; }; 84A2641B2AA915D800A62A88 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; @@ -103,8 +105,10 @@ 8474F0482ACCE2D800F21E06 /* deploy_project.sh */, 84A2641E2AA926A300A62A88 /* .env */, 846BEA1A2ABE46880032F77F /* upload-symbols.sh */, + 840B7EF12BBF3C70008B8120 /* .slather.yml */, 84A264192AA915B100A62A88 /* Brewfile */, 84A264182AA9155800A62A88 /* Makefile */, + 848A45262BBFC79E006AAAEC /* .codecov.yml */, 84A2641B2AA915D800A62A88 /* README.md */, D17C73B127D8291D006650AF /* EmpowerPlant */, 8BA3AB2D2A201FE900BE1EA8 /* EmpowerPlantTests */, @@ -323,6 +327,107 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 848A45232BBFC6FE006AAAEC /* Test */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = 97JCY7859U; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_GENERATE_TEST_COVERAGE_FILES = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_SWIFT_FLAGS = "-D DEBUG"; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Test; + }; + 848A45242BBFC6FE006AAAEC /* Test */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 97JCY7859U; + INFOPLIST_FILE = EmpowerPlant/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = sentrydemos.ios.EmpowerPlant; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Test; + }; + 848A45252BBFC6FE006AAAEC /* Test */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = sentrydemos.ios.EmpowerPlantTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EmpowerPlant.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/EmpowerPlant"; + }; + name = Test; + }; 8BA3AB322A201FE900BE1EA8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -332,7 +437,6 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.4; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = sentrydemos.ios.EmpowerPlantTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -351,7 +455,6 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.4; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = sentrydemos.ios.EmpowerPlantTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -402,6 +505,7 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; + GCC_GENERATE_TEST_COVERAGE_FILES = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -414,7 +518,6 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -463,6 +566,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_GENERATE_TEST_COVERAGE_FILES = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; @@ -470,7 +574,6 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -527,6 +630,7 @@ isa = XCConfigurationList; buildConfigurations = ( 8BA3AB322A201FE900BE1EA8 /* Debug */, + 848A45252BBFC6FE006AAAEC /* Test */, 8BA3AB332A201FE900BE1EA8 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -536,6 +640,7 @@ isa = XCConfigurationList; buildConfigurations = ( D17C73C127D8291D006650AF /* Debug */, + 848A45232BBFC6FE006AAAEC /* Test */, D17C73C227D8291D006650AF /* Release */, ); defaultConfigurationIsVisible = 0; @@ -545,6 +650,7 @@ isa = XCConfigurationList; buildConfigurations = ( D17C73C427D8291D006650AF /* Debug */, + 848A45242BBFC6FE006AAAEC /* Test */, D17C73C527D8291D006650AF /* Release */, ); defaultConfigurationIsVisible = 0; diff --git a/Makefile b/Makefile index 50e8029..dd3e0e6 100644 --- a/Makefile +++ b/Makefile @@ -17,3 +17,8 @@ init: # download iOS platform image # (happens on fresh xcode installation or MAS-managed major version update) xcodebuild -downloadPlatform iOS + +.PHONY: test +test: + xcodebuild -project EmpowerPlant.xcodeproj -scheme EmpowerPlant -configuration Test -derivedDataPath build -destination "platform=iOS Simulator,OS=latest,name=iPhone 15" -quiet test + slather coverage --configuration Test --verbose diff --git a/deploy_project.sh b/deploy_project.sh index 42c5176..f67a989 100755 --- a/deploy_project.sh +++ b/deploy_project.sh @@ -15,7 +15,7 @@ SENTRY_AUTH_TOKEN_INPUT=${4} # Build the release bundle echo "Building the release bundle..." -SENTRY_ORG=$SENTRY_ORG_INPUT SENTRY_PROJECT=$SENTRY_PROJECT_INPUT SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN_INPUT xcodebuild -project EmpowerPlant.xcodeproj -scheme EmpowerPlant -configuration Release -derivedDataPath build -destination "platform=iOS Simulator,OS=latest,name=iPhone 14" -quiet clean build +SENTRY_ORG=$SENTRY_ORG_INPUT SENTRY_PROJECT=$SENTRY_PROJECT_INPUT SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN_INPUT xcodebuild -project EmpowerPlant.xcodeproj -scheme EmpowerPlant -configuration Release -derivedDataPath build -destination "platform=iOS Simulator,OS=latest,name=iPhone 15" -quiet clean build zip -r EmpowerPlant_release.zip ./build/Build/Products/Release-iphonesimulator/EmpowerPlant.app ZIP_PATH="./EmpowerPlant_release.zip" diff --git a/upload-symbols.sh b/upload-symbols.sh index 7db2fe4..3cacf4a 100755 --- a/upload-symbols.sh +++ b/upload-symbols.sh @@ -2,6 +2,11 @@ export PATH="$PATH:/opt/homebrew/bin:/usr/local/bin" +if [ $CONFIGURATION == 'Test' ]; then + echo "Will not upload debug symbols for test build." + exit 0 +fi + if which sentry-cli >/dev/null; then # get SENTRY_ORG and SENTRY_PROJECT values