diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59a3a6fc..b74394bc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: destination: "platform=iOS Simulator,name=iPhone 15 Pro" - platform: macos scheme: "PactSwift-macOS" - destination: "arch=aarm64" + destination: "arch=arm64" - host: macos-13 xcode: 14.3.1 - host: macos-14 diff --git a/.swiftlint.yml b/.swiftlint.yml index 5da79b12..2c013d30 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -47,13 +47,15 @@ opt_in_rules: - static_operator - toggle_bool - unneeded_parentheses_in_closure_argument - - unused_declaration - - unused_import - yoda_condition - xct_specific_matcher +analyzer_rules: + - unused_declaration + - unused_import + attributes: - always_on_same_line: ["@IBAction", "@objc"] + always_on_same_line: [] line_length: warning: 180 diff --git a/PactSwift.xcfilelist b/PactSwift.xcfilelist index 08ed84d2..7c335172 100644 --- a/PactSwift.xcfilelist +++ b/PactSwift.xcfilelist @@ -1,6 +1,8 @@ $(SRCROOT)/Sources/Extensions/Bundle+PactSwift.swift +$(SRCROOT)/Sources/Extensions/Task+Timeout.swift $(SRCROOT)/Sources/Extensions/Date+PactSwift.swift $(SRCROOT)/Sources/Extensions/UUID+PactSwift.swift +$(SRCROOT)/Sources/Extensions/MockServer+Async.swift $(SRCROOT)/Sources/Extensions/String+PactSwift.swift $(SRCROOT)/Sources/Extensions/Dictionary+PactSwift.swift $(SRCROOT)/Sources/Extensions/Sequence+PactSwift.swift diff --git a/Scripts/BuildPhases/lint-target b/Scripts/BuildPhases/lint-target index 6dbe98f3..4fa62b53 100755 --- a/Scripts/BuildPhases/lint-target +++ b/Scripts/BuildPhases/lint-target @@ -30,8 +30,8 @@ errors=() #### Script steps -if [[ ! -z "${INFOPLIST_FILE}" && ! -f "${INFOPLIST_FILE}" ]]; then - errors+=("error: Could not find Info.plist file "${INFOPLIST_FILE}" for target '${TARGET_NAME}'.") +if [[ -n "${INFOPLIST_FILE}" && ! -f "${INFOPLIST_FILE}" ]]; then + errors+=("error: Could not find Info.plist file ${INFOPLIST_FILE}\ for target '${TARGET_NAME}'.") fi if [[ ! -d "${TARGET_SRCROOT}" ]]; then @@ -40,7 +40,7 @@ fi if [ ${#errors[@]} -ne 0 ]; then for i in "${errors[@]}"; do - echo $i + echo "$i" done exit 1 fi diff --git a/Scripts/BuildPhases/validate-build-settings b/Scripts/BuildPhases/validate-build-settings index 5a5819f6..c929d52f 100755 --- a/Scripts/BuildPhases/validate-build-settings +++ b/Scripts/BuildPhases/validate-build-settings @@ -22,11 +22,11 @@ set -eu echo "--- 🤖 Ensuring there are no build settings in Xcode project file." PBXPROJ_FILE_PATH="${PROJECT_FILE_PATH}/project.pbxproj" -NUMBER_OF_BUILD_SETTINGS=`grep "buildSettings" "$PBXPROJ_FILE_PATH" | wc -l` -NUMBER_OF_EMPTY_BUILD_SETTINGS=`grep -B 0 -A 1 "buildSettings" "$PBXPROJ_FILE_PATH" | grep "};" | wc -l` +NUMBER_OF_BUILD_SETTINGS="$(grep -c "buildSettings" "$PBXPROJ_FILE_PATH")" +NUMBER_OF_EMPTY_BUILD_SETTINGS="$(grep -B 0 -A 1 "buildSettings" "$PBXPROJ_FILE_PATH" | grep "};" | wc -l)" -if [ $NUMBER_OF_BUILD_SETTINGS != $NUMBER_OF_EMPTY_BUILD_SETTINGS ]; then - NUMBER_WITH_SETTINGS=`expr $NUMBER_OF_BUILD_SETTINGS - $NUMBER_OF_EMPTY_BUILD_SETTINGS` +if [ "$NUMBER_OF_BUILD_SETTINGS" != "$NUMBER_OF_EMPTY_BUILD_SETTINGS" ]; then + NUMBER_WITH_SETTINGS=$(("$NUMBER_OF_BUILD_SETTINGS" - "$NUMBER_OF_EMPTY_BUILD_SETTINGS")) echo "error: Found ${NUMBER_WITH_SETTINGS} build settings in Xcode project file! Build settings should only be defined in ./Configurations/*.xcconfig files." exit 1 diff --git a/Scripts/build_file_list_and_swiftlint b/Scripts/build_file_list_and_swiftlint index b3587c40..d624529f 100755 --- a/Scripts/build_file_list_and_swiftlint +++ b/Scripts/build_file_list_and_swiftlint @@ -19,36 +19,22 @@ set -eu -# Adds support for Apple Silicon brew directory -export PATH="$PATH:/opt/homebrew/bin" - SRCROOT=${SRCROOT:-"."} -DERIVED_FILE_DIR=${DERIVED_FILE_DIR:-"."} if [ $# -ne 2 ]; then - echo "usage: build_file_list_and_swiftlint project_name swiftlint_yml" - exit 1 + echo "usage: build_file_list_and_swiftlint project_name swiftlint_yml" + exit 1 fi echo "--- 🤖 Linting $SRCROOT/Sources/*.swift" if which swiftlint >/dev/null; then - # Build a list of Swift files in the Sources directory - find Sources -name \*.swift -exec echo "\$(SRCROOT)/"{} \; > $DERIVED_FILE_DIR/$1.xcfilelist - - # Update the xcfilelist if the list of Swift files has changed - cmp --silent $SRCROOT/$1.xcfilelist $DERIVED_FILE_DIR/$1.xcfilelist || cp -f $DERIVED_FILE_DIR/$1.xcfilelist $SRCROOT/$1.xcfilelist - - # Run swiftlint (TODO: - swiftlint by iterating through the $1.xcfilelist) - # swiftlint --config $2 -- #filename0 #filename1 #filename2 ... - swiftlint --path Sources --config $2 - - # Output an empty derived file - touch $DERIVED_FILE_DIR/swiftlint.txt + # Run swiftlint (TODO: - swiftlint by iterating through the $1.xcfilelist) + swiftlint lint "$SRCROOT/Sources" - # All hunky dory - echo "--- 👍 .swift files linted" + # All hunky dory + echo "--- 👍 .swift files in ./Sources linted" else - echo "--- ⚠ī¸ Swiftlint" - echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" + echo "--- ⚠ī¸ Swiftlint" + echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi diff --git a/Scripts/build_rust_dependencies b/Scripts/build_rust_dependencies index f208cc32..0ea2184a 100755 --- a/Scripts/build_rust_dependencies +++ b/Scripts/build_rust_dependencies @@ -15,9 +15,9 @@ PACT_FOUNDATION_REPO="https://github.com/pact-foundation/pact-reference.git" if [ ! -d "$PWD/$PRODUCT_NAME.xcodeproj" ] then - echo "🚨 Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." - echo "⚠ī¸ You are runing it in $PWD" - exit 1 + echo "🚨 Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." + echo "⚠ī¸ You are runing it in $PWD" + exit 1 fi ####################### @@ -27,20 +27,20 @@ fi echo "👮‍♀ī¸ Verifying project and dependencies' folder setup..." if [[ "$CI" == true ]]; then - echo "ℹī¸ Adding submodule ${PACT_FOUNDATION_REPO}" - if [ ! -d "$PWD/pact-reference"]; then - git submodule add $PACT_FOUNDATION_REPO - fi - git submodule update --init - cd pact-reference/rust/pact_ffi + echo "ℹī¸ Adding submodule ${PACT_FOUNDATION_REPO}" + if [ ! -d "$PWD/pact-reference" ]; then + git submodule add $PACT_FOUNDATION_REPO + fi + git submodule update --init + cd pact-reference/rust/pact_ffi elif [ ! -d "$PWD/../pact-reference" ]; then - echo "🚨 Missing pact-foundation/pact-reference repo." - echo "⚠ī¸ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." - exit 1 + echo "🚨 Missing pact-foundation/pact-reference repo." + echo "⚠ī¸ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." + exit 1 else - echo "👍 Project setup seems to be in order." - echo "ℹī¸ Changing location to ${LIBPACT_FFI_DIR}" - cd $LIBPACT_FFI_DIR + echo "👍 Project setup seems to be in order." + echo "ℹī¸ Changing location to ${LIBPACT_FFI_DIR}" + cd "$LIBPACT_FFI_DIR" fi ####################### @@ -51,13 +51,13 @@ fi echo "👮‍♀ī¸ Checking if Rust is installed..." if which cargo >/dev/null; then - echo "👍 cargo installed" + echo "👍 cargo installed" elif command -v ~/.cargo/bin/cargo &> /dev/null; then - echo "👍 cargo installed in ~/.cargo/bin/" + echo "👍 cargo installed in ~/.cargo/bin/" else - echo "🚨 Rust/Cargo not installed" - echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" - exit 1 + echo "🚨 Rust/Cargo not installed" + echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" + exit 1 fi ############################################## @@ -71,9 +71,9 @@ echo "✅ libpact_ffi built" echo "ℹī¸ Setting LD_LIBRARY_PATH to include $LIBPACT_PRODUCT_DIR" if [[ "$CI" == true ]]; then - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${WORKSPACE}/pact-reference/rust/target/debug" + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${WORKSPACE}/pact-reference/rust/target/debug" else - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LIBPACT_PRODUCT_DIR}" + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LIBPACT_PRODUCT_DIR}" fi ####################### @@ -81,7 +81,7 @@ fi ####################### echo "ℹī¸ Changing directory back to ${WORKSPACE}" -cd ${WORKSPACE} +cd "${WORKSPACE}" ############################################################################################################## # Run Swift buld and test # @@ -89,13 +89,13 @@ cd ${WORKSPACE} ############################################################################################################## echo "ℹī¸ Running swift build:" -swift build -Xlinker -L$LIBPACT_PRODUCT_DIR +swift build -Xlinker -L"$LIBPACT_PRODUCT_DIR" echo "ℹī¸ Running swift test with -Xlinker -L$LIBPACT_PRODUCT_DIR" if [[ "$CI" == true ]]; then - BIN_PATH="${WORKSPACE}/pact-reference/rust/target/debug" - swift test -Xlinker -L$BIN_PATH + BIN_PATH="${WORKSPACE}/pact-reference/rust/target/debug" + swift test -Xlinker -L"$BIN_PATH" else - swift test -Xlinker -L$LIBPACT_PRODUCT_DIR + swift test -Xlinker -L"$LIBPACT_PRODUCT_DIR" fi diff --git a/Scripts/build_test_linux b/Scripts/build_test_linux index 97560652..04155dcc 100755 --- a/Scripts/build_test_linux +++ b/Scripts/build_test_linux @@ -34,9 +34,9 @@ PACT_FOUNDATION_REPO="https://github.com/pact-foundation/pact-reference.git" if [ ! -d "$PWD/$PRODUCT_NAME.xcodeproj" ] then - echo "🚨 Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." - echo "⚠ī¸ You are runing it in $PWD" - exit 1 + echo "🚨 Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." + echo "⚠ī¸ You are runing it in $PWD" + exit 1 fi ####################### @@ -46,30 +46,30 @@ fi echo "👮‍♀ī¸ Verifying project and dependencies' folder setup..." if [[ "$CI" == true ]]; then - echo "ℹī¸ Adding submodule ${PACT_FOUNDATION_REPO}" - if [ ! -d "$PWD/pact-reference" ]; then - git submodule add $PACT_FOUNDATION_REPO - git submodule update --init + echo "ℹī¸ Adding submodule ${PACT_FOUNDATION_REPO}" + if [ ! -d "$PWD/pact-reference" ]; then + git submodule add $PACT_FOUNDATION_REPO + git submodule update --init - echo "ℹī¸ Changing location to ${LIBPACT_FFI_DIR}" - cd $LIBPACT_FFI_DIR - git fetch --all --tags - git checkout tags/libpact_ffi-v0.3.11 - fi + echo "ℹī¸ Changing location to ${LIBPACT_FFI_DIR}" + cd "$LIBPACT_FFI_DIR" + git fetch --all --tags + git checkout tags/libpact_ffi-v0.3.11 + fi - export LD_LIBRARY_PATH="/usr/local/lib" + export LD_LIBRARY_PATH="/usr/local/lib" elif [ ! -d "$PWD/../pact-reference" ]; then - # TODO: fix this for running locally - echo "🚨 Missing pact-foundation/pact-reference repo." - echo "⚠ī¸ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." - exit 1 + # TODO: fix this for running locally + echo "🚨 Missing pact-foundation/pact-reference repo." + echo "⚠ī¸ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." + exit 1 else - echo "👍 Project setup seems to be in order." + echo "👍 Project setup seems to be in order." fi echo "ℹī¸ Changing location to ${LIBPACT_FFI_DIR}" -cd $LIBPACT_FFI_DIR +cd "$LIBPACT_FFI_DIR" ####################### # Setup # @@ -79,13 +79,13 @@ cd $LIBPACT_FFI_DIR echo "👮‍♀ī¸ Checking if Rust is installed..." if which cargo >/dev/null; then - echo "👍 cargo installed" + echo "👍 cargo installed" elif command -v ~/.cargo/bin/cargo &> /dev/null; then - echo "👍 cargo installed in ~/.cargo/bin/" + echo "👍 cargo installed in ~/.cargo/bin/" else - echo "🚨 Rust/Cargo not installed" - echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" - exit 1 + echo "🚨 Rust/Cargo not installed" + echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" + exit 1 fi ############################################## @@ -105,7 +105,7 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBPACT_PRODUCT_DIR ####################### echo "ℹī¸ Changing directory back to ${WORKSPACE}" -cd ${WORKSPACE} +cd "${WORKSPACE}" ############################################################################################################## # Run Swift buld and test # @@ -113,7 +113,7 @@ cd ${WORKSPACE} ############################################################################################################## echo "ℹī¸ Running swift build:" -swift build -Xlinker -L$LIBPACT_PRODUCT_DIR +swift build -Xlinker -L"$LIBPACT_PRODUCT_DIR" echo "ℹī¸ Running swift test with -Xlinker -L$LIBPACT_PRODUCT_DIR" -swift test -Xlinker -L$LIBPACT_PRODUCT_DIR \ No newline at end of file +swift test -Xlinker -L"$LIBPACT_PRODUCT_DIR" diff --git a/Scripts/carthage b/Scripts/carthage index f5ac5d14..02e41357 100755 --- a/Scripts/carthage +++ b/Scripts/carthage @@ -16,32 +16,31 @@ ACTIVE_ARCH=$(uname -m) if [[ $ACTIVE_ARCH == "x86_64" ]]; then - # If running on Intel machine, do the excluded architectures dance 💃đŸ•ē + # If running on Intel machine, do the excluded architectures dance 💃đŸ•ē - xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX) - trap 'rm -f "$xcconfig"' INT TERM HUP EXIT + xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX) + trap 'rm -f "$xcconfig"' INT TERM HUP EXIT - echo "⚠ī¸ NOTE: Using Carthage workaround script..." + echo "⚠ī¸ NOTE: Using Carthage workaround script..." - # For Xcode 12 and 13 make sure EXCLUDED_ARCHS is set to arm architectures otherwise - # the build will fail on lipo due to duplicate architectures. + # For Xcode 12 and 13 make sure EXCLUDED_ARCHS is set to arm architectures otherwise + # the build will fail on lipo due to duplicate architectures. - CURRENT_XCODE_VERSION="$(xcodebuild -version | grep "Xcode" | cut -d' ' -f2 | cut -d'.' -f1)00" - CURRENT_XCODE_BUILD=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3) + CURRENT_XCODE_VERSION="$(xcodebuild -version | grep "Xcode" | cut -d' ' -f2 | cut -d'.' -f1)00" + CURRENT_XCODE_BUILD=$(xcodebuild -version | grep "Build version" | cut -d' ' -f3) - echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_${CURRENT_XCODE_VERSION}__BUILD_${CURRENT_XCODE_BUILD} = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig + echo "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_${CURRENT_XCODE_VERSION}__BUILD_${CURRENT_XCODE_BUILD} = arm64 arm64e armv7 armv7s armv6 armv8" >> $xcconfig - echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_'${CURRENT_XCODE_VERSION}' = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_$(XCODE_VERSION_MAJOR)__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $xcconfig - echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig + echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_'${CURRENT_XCODE_VERSION}' = $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_$(XCODE_VERSION_MAJOR)__BUILD_$(XCODE_PRODUCT_BUILD_VERSION))' >> $xcconfig + echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig - export XCODE_XCCONFIG_FILE="$xcconfig" - carthage "$@" + export XCODE_XCCONFIG_FILE="$xcconfig" + carthage "$@" else - # Running on arm64 machine so just use the plain carthage - echo "⚠ī¸ NOTE: Using plain vanilla Carthage..." - carthage "$@" + # Running on arm64 machine so just use the plain carthage + echo "⚠ī¸ NOTE: Using plain vanilla Carthage..." + carthage "$@" fi - diff --git a/Scripts/check_build_tools b/Scripts/check_build_tools index 1c605c49..4a0445a5 100755 --- a/Scripts/check_build_tools +++ b/Scripts/check_build_tools @@ -5,23 +5,23 @@ set -o pipefail # Checking for SwiftLint if which swiftlint >/dev/null; then - echo "👍 swiftLint installed" + echo "👍 swiftLint installed" else - echo "⚠ī¸ Swiftlint" - echo "warning: SwiftLint not installed, use 'brew install swiftlint' to install it." + echo "⚠ī¸ Swiftlint" + echo "warning: SwiftLint not installed, use 'brew install swiftlint' to install it." fi if which carthage >/dev/null; then - echo "👍 carthage installed" + echo "👍 carthage installed" else - echo "⚠ī¸ carthage" - echo "warning: carthage not installed, use 'brew install carthage' to install it." + echo "⚠ī¸ carthage" + echo "warning: carthage not installed, use 'brew install carthage' to install it." fi # Checking for xcbeautify if which xcbeautify >/dev/null; then - echo "👍 xcbeautify installed" + echo "👍 xcbeautify installed" else - echo "⚠ī¸ xcbeautify" - echo "warning: xcbeautify not installed, use 'brew install xcbeautify' to install it." -fi \ No newline at end of file + echo "⚠ī¸ xcbeautify" + echo "warning: xcbeautify not installed, use 'brew install xcbeautify' to install it." +fi diff --git a/Scripts/prepare_build_tools b/Scripts/prepare_build_tools index 68ab1ea2..a5ae6dd6 100755 --- a/Scripts/prepare_build_tools +++ b/Scripts/prepare_build_tools @@ -5,5 +5,5 @@ brew tap thii/xcbeautify https://github.com/thii/xcbeautify.git brew install xcbeautify if [[ "$CI" == false ]]; then - brew install swiftlint -fi \ No newline at end of file + brew install swiftlint +fi diff --git a/Scripts/release b/Scripts/release index 46aa2ab9..f752d284 100755 --- a/Scripts/release +++ b/Scripts/release @@ -26,30 +26,30 @@ set -o pipefail #################### function help { - echo "Usage: release VERSION RELEASE_NAME [DRY_RUN]" - echo - echo "VERSION should be the version to release and should not include the 'v' prefix" - echo "RELEASE_NAME should be the type of release 'Bugfix Release / Maintenance Release'" - echo - echo "FLAGS" - echo " -d Dry run, won't push anything" - echo - echo " Example: ./Scripts/release 1.0.0 'Bugfix Release' -d" - echo - exit 2 + echo "Usage: release VERSION RELEASE_NAME [DRY_RUN]" + echo + echo "VERSION should be the version to release and should not include the 'v' prefix" + echo "RELEASE_NAME should be the type of release 'Bugfix Release / Maintenance Release'" + echo + echo "FLAGS" + echo " -d Dry run, won't push anything" + echo + echo " Example: ./Scripts/release 1.0.0 'Bugfix Release' -d" + echo + exit 2 } function die { - echo "🚨 [ERROR] $@" - echo - exit 1 + echo "🚨 [ERROR] $@" + echo + exit 1 } function handleInput { - if [[ ! $1 =~ ^[Yy]$ ]]; then - echo "⚠ī¸ Release aborted!" - exit 1 - fi + if [[ ! $1 =~ ^[Yy]$ ]]; then + echo "⚠ī¸ Release aborted!" + exit 1 + fi } ##################### @@ -65,10 +65,10 @@ fi ############################## if [[ "$CI" == true ]] ; then - die "🚨 Running on CI is not supported! Requires user input while running the release script." + die "🚨 Running on CI is not supported! Requires user input while running the release script." else - echo "👮‍♀ī¸ Running on local machine: 👍" - SCRIPTS_DIR="${BASH_SOURCE[0]%/*}" + echo "👮‍♀ī¸ Running on local machine: 👍" + SCRIPTS_DIR="${BASH_SOURCE[0]%/*}" fi ############################## @@ -76,31 +76,31 @@ fi ############################## # Get the latest release tag -LATEST_TAG=`git describe --match "v[0-9].*" --abbrev=0 HEAD` +LATEST_TAG="$(git describe --match "v[0-9].*" --abbrev=0 HEAD)" echo "ℹī¸ The last release tag number is: ${LATEST_TAG}" read -r -p "Did you provide the correctly incremented number for the new release tag? [Y/n] " -n 1 USER_INPUT echo -handleInput $USER_INPUT +handleInput "$USER_INPUT" echo read -r -p "Have you updated all the documentation files? [Y/n] " -n 1 USER_INPUT echo -handleInput $USER_INPUT +handleInput "$USER_INPUT" echo echo "ℹī¸ The following commits will be recorded with the tag:" -git log --pretty='* %h - %s (%an)' ${LATEST_TAG}..HEAD +git log --pretty='* %h - %s (%an)' "${LATEST_TAG}"..HEAD echo read -r -p "Have you prepared a draft release on GitHub.com? [Y/n] " -n 1 USER_INPUT echo -handleInput $USER_INPUT +handleInput "$USER_INPUT" read -r -p "You named the release name with something meaningful like \"Bugfix\" or \"Feature \". Right? [Y/n] " -n 1 USER_INPUT echo -handleInput $USER_INPUT +handleInput "$USER_INPUT" #################### # Variables # @@ -120,29 +120,29 @@ VERSION_TAG="v$VERSION" #################### function updateVersionFile { - sed -i '' "2s/.*/let pactSwiftVersion = \"$@\"/" $VERSION_FILE + sed -i '' "2s/.*/let pactSwiftVersion = \"$@\"/" "$VERSION_FILE" - MARKETING_VERSION="MARKETING_VERSION = $@" - sed -i '' "2s/.*/$MARKETING_VERSION/" $CONFIGURATION_FILE + MARKETING_VERSION="MARKETING_VERSION = $@" + sed -i '' "2s/.*/$MARKETING_VERSION/" "$CONFIGURATION_FILE" } function pushNewVersion { - updateVersionFile "$VERSION" + updateVersionFile "$VERSION" - echo ${RELEASE_NAME} > TAG_MESSAGE_FILE.md - git log --pretty='* %h - %s (%an)' ${LATEST_TAG}..HEAD >> TAG_MESSAGE_FILE.md + echo "${RELEASE_NAME}" > TAG_MESSAGE_FILE.md + git log --pretty='* %h - %s (%an)' "${LATEST_TAG}"..HEAD >> TAG_MESSAGE_FILE.md - git add $VERSION_FILE - git add $CONFIGURATION_FILE - git add $RELEASE_NOTES + git add "$VERSION_FILE" + git add "$CONFIGURATION_FILE" + git add "$RELEASE_NOTES" - git commit -m "${RELEASE_NAME}" + git commit -m "${RELEASE_NAME}" - echo "🏷 Tagging the current commit" - git tag "$VERSION_TAG" -F TAG_MESSAGE_FILE.md || die "Failed to tag version" + echo "🏷 Tagging the current commit" + git tag "$VERSION_TAG" -F TAG_MESSAGE_FILE.md || die "Failed to tag version" - echo "🚀 Tagging the current commit" - git push --atomic origin main $VERSION_TAG || die "Failed to push the release commit with tag '$VERSION_TAG' to origin" + echo "🚀 Tagging the current commit" + git push --atomic origin main "$VERSION_TAG" || die "Failed to push the release commit with tag '$VERSION_TAG' to origin" } @@ -152,12 +152,12 @@ function pushNewVersion { echo "👮‍♀ī¸ Verifying if version tag is reasonable..." -echo $VERSION_TAG | grep -q "^vv" +echo "$VERSION_TAG" | grep -q "^vv" if [ $? -eq 0 ]; then die "This tag ($VERSION) is in an incorrect format. You should remove the 'v' prefix." fi -echo $VERSION_TAG | grep -q -E "^v[0-9]+\.[0-9]+\.[0-9]+(-\w+(\.\d)?)?$" +echo "$VERSION_TAG" | grep -q -E "^v[0-9]+\.[0-9]+\.[0-9]+(-\w+(\.\d)?)?$" if [ $? -ne 0 ]; then die "This tag $VERSION is in an incorrect format. It should be in 'v{MAJOR}.{MINOR}.{PATCH}(-{PRERELEASE_NAME}.{PRERELEASE_VERSION})' form." fi @@ -172,19 +172,19 @@ fi echo "🏗 Generating release notes into $RELEASE_NOTES" # backup the existing CHANGELOG.md to CHANGELOG.backup -cp $RELEASE_NOTES ${RELEASE_NOTES}.backup +cp "$RELEASE_NOTES" "${RELEASE_NOTES}.backup" # Prepare the title for this release -echo "# ${VERSION} - ${RELEASE_NAME}" > ${RELEASE_NOTES}.next +echo "# ${VERSION} - ${RELEASE_NAME}" > "${RELEASE_NOTES}.next" # Get the commits from last change -git log --pretty='* %h - %s (%an)' ${LATEST_TAG}..HEAD >> ${RELEASE_NOTES}.next +git log --pretty='* %h - %s (%an)' "${LATEST_TAG}"..HEAD >> "${RELEASE_NOTES}.next" # Stage the updated CHANGELOG.md -git add $RELEASE_NOTES || { die "Failed to add ${RELEASE_NOTES} to INDEX"; } +git add "$RELEASE_NOTES" || { die "Failed to add ${RELEASE_NOTES} to INDEX"; } # Read the notes for this release and append them to the old CHANGELOG.md -cat $RELEASE_NOTES.next | cat - ${RELEASE_NOTES}.backup > ${RELEASE_NOTES} +cat "$RELEASE_NOTES.next" | cat - "${RELEASE_NOTES}.backup" > "${RELEASE_NOTES}" echo "đŸšĸ Releasing version $VERSION (tag: $VERSION_TAG)..." @@ -195,27 +195,27 @@ git diff --quiet HEAD "origin/$REMOTE_BRANCH" || die "HEAD is not aligned to ori echo "🏷 Tagging release version..." if [ -z "$DRY_RUN" ]; then - echo "🚅 Pushing release version tag to origin..." + echo "🚅 Pushing release version tag to origin..." - pushNewVersion + pushNewVersion - echo - echo "-------- 🎉 Created a new PactSwift version tag 🎉 --------------------------------" - echo "-------- 🏷 Version: $VERSION_TAG" - echo "-------- ✏ī¸ Name: $RELEASE_NAME" - echo "--------" - echo "-------- 🚀 Go and link you draft release for '$VERSION_TAG' with this tagged commit." - echo "-------- 🔗 https://github.com/surpher/PactSwift/releases" - echo + echo + echo "-------- 🎉 Created a new PactSwift version tag 🎉 --------------------------------" + echo "-------- 🏷 Version: $VERSION_TAG" + echo "-------- ✏ī¸ Name: $RELEASE_NAME" + echo "--------" + echo "-------- 🚀 Go and link you draft release for '$VERSION_TAG' with this tagged commit." + echo "-------- 🔗 https://github.com/surpher/PactSwift/releases" + echo else - echo "-> Dry run completed." + echo "-> Dry run completed." fi #################### # Cleanup # #################### -rm ${RELEASE_NOTES}.next -rm ${RELEASE_NOTES}.backup +rm "${RELEASE_NOTES}.next" +rm "${RELEASE_NOTES}.backup" rm TAG_MESSAGE_FILE.md diff --git a/Scripts/run_tests b/Scripts/run_tests index bdbc8ca7..2d1c2ec9 100755 --- a/Scripts/run_tests +++ b/Scripts/run_tests @@ -11,14 +11,14 @@ SCRIPTS_DIR="${BASH_SOURCE[0]%/*}" ACTIVE_ARCH=$(uname -m) # Check for dependencies -$SCRIPTS_DIR/check_build_tools +"${SCRIPTS_DIR}"/check_build_tools # Carthage build echo "đŸ“Ļ Building as a Carthage dependency" if [[ $ACTIVE_ARCH == "x86_64" ]]; then - ${SCRIPTS_DIR}/carthage build --no-skip-current --use-xcframeworks + "${SCRIPTS_DIR}"/carthage build --no-skip-current --use-xcframeworks else - carthage build --no-skip-current --use-xcframeworks + carthage build --no-skip-current --use-xcframeworks fi # Build and test for SPM diff --git a/Sources/ExampleGenerators/DateTime.swift b/Sources/ExampleGenerators/DateTime.swift index 3ee2e641..25502a59 100644 --- a/Sources/ExampleGenerators/DateTime.swift +++ b/Sources/ExampleGenerators/DateTime.swift @@ -35,7 +35,8 @@ public extension ExampleGenerator { // MARK: - Objective-C #if !os(Linux) -@objc(PFGeneratorDateTime) +@objc +(PFGeneratorDateTime) public class ObjcDateTime: NSObject, ObjcGenerator { let type: ExampleGeneratorExpressible diff --git a/Sources/ExampleGenerators/RandomBool.swift b/Sources/ExampleGenerators/RandomBool.swift index 241917bd..2edd750a 100644 --- a/Sources/ExampleGenerators/RandomBool.swift +++ b/Sources/ExampleGenerators/RandomBool.swift @@ -40,7 +40,8 @@ public class ObjcRandomBool: NSObject, ObjcGenerator { let type: ExampleGeneratorExpressible = ExampleGenerator.RandomBool() /// Generates a random boolean value - @objc public override init() { + @objc + public override init() { super.init() } diff --git a/Sources/ExampleGenerators/RandomUUID.swift b/Sources/ExampleGenerators/RandomUUID.swift index 04919adc..cb209892 100644 --- a/Sources/ExampleGenerators/RandomUUID.swift +++ b/Sources/ExampleGenerators/RandomUUID.swift @@ -104,7 +104,8 @@ public class ObjcRandomUUID: NSObject, ObjcGenerator { } /// The format of the UUID value - @objc public enum ObjcUUIDFormat: Int { + @objc + public enum ObjcUUIDFormat: Int { case simple = 0 case lowercaseHyphenated = 1 case uppercaseHyphenated = 2 diff --git a/Sources/Extensions/MockServer+Async.swift b/Sources/Extensions/MockServer+Async.swift index 83c1ec45..321200cb 100644 --- a/Sources/Extensions/MockServer+Async.swift +++ b/Sources/Extensions/MockServer+Async.swift @@ -31,7 +31,7 @@ extension MockServer { #if os(Linux) typealias TransferProtocolScheme = PactSwiftMockServerLinux.TransferProtocol #else - private var TransferProtocolScheme = PactSwiftMockServer.TransferProtocol + typealias TransferProtocolScheme = PactSwiftMockServer.TransferProtocol #endif /// Spins up a mock server with expected interactions defined in the provided Pact diff --git a/Sources/Matchers/MatchNull.swift b/Sources/Matchers/MatchNull.swift index 97f8527f..32587962 100644 --- a/Sources/Matchers/MatchNull.swift +++ b/Sources/Matchers/MatchNull.swift @@ -44,7 +44,8 @@ public class ObjcMatchNull: NSObject, ObjcMatcher { let type: MatchingRuleExpressible = Matcher.MatchNull() /// The value returned by API provider matches `null`. - @objc public override init() { + @objc + public override init() { super.init() } diff --git a/Sources/MockService.swift b/Sources/MockService.swift index 75380833..47a66594 100644 --- a/Sources/MockService.swift +++ b/Sources/MockService.swift @@ -408,5 +408,4 @@ private extension MockService { } } } - -} +} // swiftlint:disable:this file_length diff --git a/Sources/Model/Interaction.swift b/Sources/Model/Interaction.swift index cac95ff2..62d502cd 100644 --- a/Sources/Model/Interaction.swift +++ b/Sources/Model/Interaction.swift @@ -30,7 +30,8 @@ public class Interaction: NSObject { } #else /// Defines the interaction between a consumer and a provider -@objc public class Interaction: NSObject { +@objc +public class Interaction: NSObject { var interactionDescription: String? var providerState: String? var providerStates: [ProviderState]? @@ -63,7 +64,8 @@ extension Interaction { self.interactionDescription = description } #else - @objc convenience init(description: String) { + @objc + convenience init(description: String) { self.init() self.interactionDescription = description } diff --git a/Sources/Model/PactHTTPMethod.swift b/Sources/Model/PactHTTPMethod.swift index 4dc96b92..1851ffa1 100644 --- a/Sources/Model/PactHTTPMethod.swift +++ b/Sources/Model/PactHTTPMethod.swift @@ -32,7 +32,8 @@ public enum PactHTTPMethod { } #else /// The HTTP method expected in the interaction -@objc public enum PactHTTPMethod: Int { +@objc +public enum PactHTTPMethod: Int { case GET case HEAD case POST diff --git a/Sources/Model/TransferProtocol.swift b/Sources/Model/TransferProtocol.swift index 78fdcb86..45aeedd4 100644 --- a/Sources/Model/TransferProtocol.swift +++ b/Sources/Model/TransferProtocol.swift @@ -40,7 +40,8 @@ public enum TransferProtocol { @_implementationOnly import PactSwiftMockServer /// Defines the transfer protocol on which `MockService` runs. -@objc public enum TransferProtocol: Int { +@objc +public enum TransferProtocol: Int { case standard case secure @@ -58,7 +59,8 @@ public enum TransferProtocol { import PactSwiftMockServer /// Defines the transfer protocol on which `MockService` runs. -@objc public enum TransferProtocol: Int { +@objc +public enum TransferProtocol: Int { case standard case secure diff --git a/Sources/PFMockService.swift b/Sources/PFMockService.swift index 7bfed243..f27e29aa 100644 --- a/Sources/PFMockService.swift +++ b/Sources/PFMockService.swift @@ -16,24 +16,18 @@ // #if !os(Linux) - import Foundation import XCTest -#if os(Linux) -import PactSwiftMockServerLinux -#elseif compiler(>=5.5) @_implementationOnly import PactSwiftMockServer -#else -import PactSwiftMockServer -#endif /// Initializes a `PFMockService` object that handles Pact interaction testing for projects written in Objective-C. For Swift projects use `MockService`. /// /// When initializing with `.secure` scheme, the SSL certificate on Mock Server /// is a self-signed certificate. /// -@objc open class PFMockService: NSObject { +@objc +open class PFMockService: NSObject { // MARK: - Properties @@ -82,7 +76,8 @@ import PactSwiftMockServer /// - parameter description: A description of the API interaction /// @discardableResult - @objc public func uponReceiving(_ description: String) -> Interaction { + @objc + public func uponReceiving(_ description: String) -> Interaction { mockService.uponReceiving(description) } @@ -115,5 +110,4 @@ import PactSwiftMockServer } } - #endif