diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..851cfde18 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,64 @@ +--- +name: Test + +on: + pull_request: + +env: + DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer + MINT_LINK_PATH: .mint/bin + MINT_PATH: .mint/lib + SIMULATOR_DESTINATION: platform=iOS Simulator,name=iPhone 14 Pro,OS=16.4 + +jobs: + test: + name: Test + runs-on: macos-13 + steps: + - name: Checkout + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - name: Setup Ruby + uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0 + with: + bundler-cache: true + ruby-version: 3.2.2 + + - name: Cache Mint Packages + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + with: + path: .mint + key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }} + restore-keys: | + ${{ runner.os }}-mint- + + - name: Cache SPM Packages + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 + with: + path: build/DerivedData/SourcePackages + key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm- + + - name: Setup + run: | + brew install mint xcbeautify + ./Scripts/bootstrap.sh + + - name: Build and Test + run: | + set -o pipefail && \ + xcodebuild test \ + -project Bitwarden.xcodeproj \ + -scheme Bitwarden \ + -configuration Debug \ + -sdk iphonesimulator \ + -destination "${{ env.SIMULATOR_DESTINATION }}" \ + -resultBundlePath build/BitwardenTests.xcresult \ + -derivedDataPath build/DerivedData \ + | xcbeautify --renderer github-actions + + - name: Danger + env: + DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: bundle exec danger diff --git a/.swiftformat b/.swiftformat index 5db6f104a..53303cbe6 100644 --- a/.swiftformat +++ b/.swiftformat @@ -8,7 +8,7 @@ --varattributes same-line # file options ---exclude **/Generated +--exclude **/Generated,build,vendor/bundle # rules --disable elseOnSameLine,semicolons,unusedArguments,opaqueGenericParameters diff --git a/.swiftlint.yml b/.swiftlint.yml index 4dc9b206b..84a6c426c 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -38,6 +38,8 @@ opt_in_rules: excluded: - BitwardenShared/UI/Platform/Application/Support/Generated + - build + - vendor/bundle cyclomatic_complexity: ignores_case_statements: true diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 000000000..e2c5b5eb2 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,22 @@ +xcode_summary.ignored_files = '**/SourcePackages/*' +xcode_summary.report 'build/BitwardenTests.xcresult' + +slather.configure( + 'Bitwarden.xcodeproj', 'Bitwarden', + options: { + binary_basename: [ + 'Bitwarden', + #'BitwardenActionExtension', -- Can't add this until the target has some lines of code or slather throws an error. + 'BitwardenAutoFillExtension', + 'BitwardenShareExtension', + 'BitwardenShared', + ], + build_directory: 'build/DerivedData', + # Ignore Swift Packages + ignore_list: ['build/DerivedData/SourcePackages/*'] + }, +) + +slather.notify_if_coverage_is_less_than(minimum_coverage: 80, notify_level: :warning) +slather.notify_if_modified_file_is_less_than(minimum_coverage: 80, notify_level: :warning) +slather.show_coverage diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..cf26505be --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem 'danger' +gem 'danger-slather' +gem 'danger-xcode_summary' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..a4c0efdca --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,110 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.6) + rexml + activesupport (7.0.7.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + addressable (2.8.5) + public_suffix (>= 2.0.2, < 6.0) + atomos (0.1.3) + claide (1.1.0) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) + clamp (1.3.2) + colored2 (3.1.2) + concurrent-ruby (1.2.2) + cork (0.3.0) + colored2 (~> 3.1) + danger (9.3.1) + claide (~> 1.0) + claide-plugins (>= 0.9.2) + colored2 (~> 3.1) + cork (~> 0.1) + faraday (>= 0.9.0, < 3.0) + faraday-http-cache (~> 2.0) + git (~> 1.13) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.0) + no_proxy_fix + octokit (~> 6.0) + terminal-table (>= 1, < 4) + danger-plugin-api (1.0.0) + danger (> 2.0) + danger-slather (0.0.6) + danger-plugin-api (~> 1.0) + slather (~> 2.3) + danger-xcode_summary (1.2.0) + danger-plugin-api (~> 1.0) + xcresult (~> 0.2) + faraday (2.7.10) + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) + faraday-http-cache (2.5.0) + faraday (>= 0.8) + faraday-net_http (3.0.2) + git (1.18.0) + addressable (~> 2.8) + rchardet (~> 1.8) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + minitest (5.19.0) + nanaimo (0.3.0) + nap (1.1.0) + no_proxy_fix (0.1.2) + nokogiri (1.15.4-arm64-darwin) + racc (~> 1.4) + nokogiri (1.15.4-x86_64-darwin) + racc (~> 1.4) + octokit (6.1.1) + faraday (>= 1, < 3) + sawyer (~> 0.9) + open4 (1.3.4) + public_suffix (5.0.3) + racc (1.7.1) + rchardet (1.8.0) + rexml (3.2.6) + ruby2_keywords (0.0.5) + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) + slather (2.7.4) + CFPropertyList (>= 2.2, < 4) + activesupport + clamp (~> 1.3) + nokogiri (>= 1.13.9) + xcodeproj (~> 1.21) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) + xcodeproj (1.22.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + xcresult (0.2.1) + +PLATFORMS + arm64-darwin-21 + x86_64-darwin-20 + +DEPENDENCIES + danger + danger-slather + danger-xcode_summary + +BUNDLED WITH + 2.3.22 diff --git a/project.yml b/project.yml index 93117673b..2f594be12 100644 --- a/project.yml +++ b/project.yml @@ -289,6 +289,7 @@ targets: - "**/TestHelpers/*" - path: GlobalTestHelpers dependencies: + - target: Bitwarden - target: BitwardenShared - package: SnapshotTesting - package: ViewInspector