diff --git a/.circleci/config.yml b/.circleci/config.yml index 95631e6b..fde0a2fd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,9 +2,9 @@ version: 2.1 jobs: danger: - executor: xcode-12 + executor: xcode-14 steps: - - setup + - setup-apple-silicon - run: name: Install xchtmlreport command: | @@ -48,26 +48,32 @@ jobs: name: Danger when: always command: | - if [ -n "$DANGER_GITHUB_API_TOKEN" ]; then bundle exec danger; else echo "Skipping Danger for forked pull request."; fi + if [ -n "$DANGER_GITHUB_API_TOKEN" ]; then bundle exec danger --verbose; else echo "Skipping Danger for forked pull request."; fi - run: name: Upload to Codecov when: always command: bash <(curl -s https://codecov.io/bash) -f build/BonMot-iOS/slather/cobertura.xml -X coveragepy -X gcov -X xcode swift-package: - executor: xcode-12 + executor: xcode-14 steps: - - setup + - setup-apple-silicon - run: swift build - - run: swift test + - run: swift test --verbose lint-pod: - executor: xcode-12 + executor: xcode-14 steps: - - setup + - setup-apple-silicon - lint-pod fastlane-tests: + executor: xcode-14 + steps: + - setup-apple-silicon + - run: bundle exec fastlane test_all --verbose + + fastlane-tests-xcode-12: executor: xcode-12 steps: - setup @@ -80,7 +86,7 @@ jobs: - run: bundle exec fastlane test_all carthage-build: - executor: xcode-12 + executor: xcode-14 steps: - checkout - run: @@ -93,7 +99,7 @@ jobs: # - run: carthage build --no-skip-current && for platform in Mac iOS tvOS watchOS; do test -d Carthage/Build/${platform}/BonMot.framework || exit 1; done deploy-to-cocoapods: - executor: xcode-12 + executor: xcode-14 steps: - setup - run: bundle exec pod trunk push @@ -109,7 +115,16 @@ executors: shell: /bin/bash --login -eo pipefail xcode-13: macos: - xcode: "13.0.0" + xcode: "13.4.1" + environment: + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + HOMEBREW_NO_AUTO_UPDATE: 1 + shell: /bin/bash --login -eo pipefail + xcode-14: + macos: + xcode: "14.3.1" + resource_class: macos.m1.large.gen1 environment: LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 @@ -117,6 +132,30 @@ executors: shell: /bin/bash --login -eo pipefail commands: + + setup-apple-silicon: + description: "Shared Apple Silicon setup" + steps: + - checkout + - restore-gems-apple-silicon + + restore-gems-apple-silicon: + description: "Restore Ruby Gems: Apple Silicon" + steps: + - run: + name: Ruby Setup + command: bash ./.circleci/ruby_setup.sh + - run: + name: Set Ruby Version + command: bash ./.circleci/ruby_version.sh + - restore_cache: + key: 1-gems-{{ checksum "Gemfile.lock" }} + - run: bundle check || bundle install --path vendor/bundle + - save_cache: + key: 1-gems-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + setup: description: "Shared setup" steps: @@ -127,8 +166,8 @@ commands: description: "Restore Ruby Gems" steps: - run: - name: Set Ruby Version - command: echo "ruby-2.5" > ~/.ruby-version + name: Set Ruby Version + command: echo "ruby-2.5" > ~/.ruby-version - restore_cache: key: 1-gems-{{ checksum "Gemfile.lock" }} - run: bundle check || bundle install --path vendor/bundle @@ -166,6 +205,10 @@ workflows: filters: tags: only: /.*/ + - fastlane-tests-xcode-12: + filters: + tags: + only: /.*/ - lint-pod: filters: tags: @@ -181,6 +224,7 @@ workflows: - swift-package - fastlane-tests - fastlane-tests-xcode-13 + - fastlane-tests-xcode-12 - lint-pod - carthage-build filters: diff --git a/.circleci/ruby_setup.sh b/.circleci/ruby_setup.sh new file mode 100644 index 00000000..7544f0f9 --- /dev/null +++ b/.circleci/ruby_setup.sh @@ -0,0 +1,47 @@ +#!/bin/bash -eo pipefail + +# Ensure any error stops the script +set -e + +# Check if Homebrew is installed +if ! command -v brew &> /dev/null; then + echo "Homebrew not found. Please install it first." + exit 1 +fi + +# Check if rbenv is installed; if not, install it +if ! command -v rbenv &> /dev/null; then + echo "Installing rbenv..." + brew install rbenv + # Check if rbenv init line is already present in .bash_profile, if not, add it + if ! grep -q 'eval "$(rbenv init -)"' ~/.bash_profile; then + echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile + fi + + source ~/.bash_profile +else + echo "rbenv is already installed." +fi + +# Check if ruby-build is installed; if not, install it +if ! brew list ruby-build &> /dev/null; then + echo "Installing ruby-build..." + brew install ruby-build +else + echo "ruby-build is already installed." +fi + +# Ensure ruby-build is up-to-date +brew update && brew upgrade ruby-build + +# Check if Ruby 3.0.6 is already installed; if not, install it +if ! rbenv versions | grep -q 3.0.6; then + echo "Installing Ruby 3.0.6..." + rbenv install 3.0.6 +else + echo "Ruby 3.0.6 is already installed." +fi + +# Set the global Ruby version to 3.0.6 +echo "Setting global Ruby version to 3.0.6..." +rbenv global 3.0.6 diff --git a/.circleci/ruby_version.sh b/.circleci/ruby_version.sh new file mode 100644 index 00000000..cdb4e428 --- /dev/null +++ b/.circleci/ruby_version.sh @@ -0,0 +1,17 @@ +#!/bin/bash -eo pipefail + +# Ensure any error stops the script +set -e + +# Ensure rbenv is properly initialized +if ! command -v rbenv &> /dev/null; then + echo "rbenv not found. Please install it first." + exit 1 +fi + +echo "Initializing rbenv..." +source ~/.bash_profile + +# Set the global Ruby version to 3.0.6 +echo "Setting global Ruby version to 3.0.6..." +rbenv global 3.0.6 diff --git a/Gemfile.lock b/Gemfile.lock index 978dfa6b..796612ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,12 +3,12 @@ GEM specs: CFPropertyList (3.0.6) rexml - activesupport (7.0.5) + activesupport (7.0.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.4) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) @@ -16,20 +16,20 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.777.0) - aws-sdk-core (3.174.0) + aws-partitions (1.805.0) + aws-sdk-core (3.180.3) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.66.0) - aws-sdk-core (~> 3, >= 3.174.0) + aws-sdk-kms (1.71.0) + aws-sdk-core (~> 3, >= 3.177.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.123.1) - aws-sdk-core (~> 3, >= 3.174.0) + aws-sdk-s3 (1.132.1) + aws-sdk-core (~> 3, >= 3.179.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.4) - aws-sigv4 (1.5.2) + aws-sigv4 (~> 1.6) + aws-sigv4 (1.6.0) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) circleci (2.1.0) @@ -109,7 +109,7 @@ GEM danger (>= 2.1) xcov (>= 1.7.3) declarative (0.0.20) - digest-crc (0.6.4) + digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) @@ -150,7 +150,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.7) - fastlane (2.213.0) + fastlane (2.214.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -196,9 +196,9 @@ GEM git (1.18.0) addressable (~> 2.8) rchardet (~> 1.8) - google-apis-androidpublisher_v3 (0.43.0) + google-apis-androidpublisher_v3 (0.48.0) google-apis-core (>= 0.11.0, < 2.a) - google-apis-core (0.11.0) + google-apis-core (0.11.1) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -227,7 +227,7 @@ GEM google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - googleauth (1.5.2) + googleauth (1.7.0) faraday (>= 0.17.3, < 3.a) jwt (>= 1.4, < 3.0) memoist (~> 0.16) @@ -249,9 +249,9 @@ GEM kramdown (~> 2.0) memoist (0.16.2) mini_magick (4.12.0) - mini_mime (1.1.2) - mini_portile2 (2.8.2) - minitest (5.18.0) + mini_mime (1.1.5) + mini_portile2 (2.8.4) + minitest (5.19.0) molinillo (0.8.0) multi_json (1.15.0) multipart-post (2.3.0) @@ -260,7 +260,7 @@ GEM naturally (2.2.1) netrc (0.11.0) no_proxy_fix (0.1.2) - nokogiri (1.15.2) + nokogiri (1.15.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) octokit (6.1.1) @@ -269,10 +269,10 @@ GEM open4 (1.3.4) optparse (0.1.1) os (1.1.4) - ox (2.14.16) + ox (2.14.17) plist (3.7.0) public_suffix (4.0.7) - racc (1.7.0) + racc (1.7.1) rake (13.0.6) rchardet (1.8.0) representable (3.2.0) @@ -280,7 +280,7 @@ GEM trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.2.5) + rexml (3.2.6) rouge (2.0.7) ruby-macho (2.5.1) ruby2_keywords (0.0.5) diff --git a/Sources/XMLBuilder.swift b/Sources/XMLBuilder.swift index 5d33de46..aad9637b 100644 --- a/Sources/XMLBuilder.swift +++ b/Sources/XMLBuilder.swift @@ -267,9 +267,7 @@ class XMLBuilder: NSObject, XMLParserDelegate { string : "<\(XMLBuilder.internalTopLevelElement)>\(string)") - guard let data = xml.data(using: String.Encoding.utf8) else { - fatalError("Unable to convert to UTF8") - } + let data = Data(xml.utf8) self.attributedString = NSMutableAttributedString() self.parser = XMLParser(data: data) self.options = options