Skip to content

Commit

Permalink
BIT-58: Add Github Actions workflow for building and testing (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-livefront authored Aug 31, 2023
1 parent 6e3dda2 commit e0e05b2
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--varattributes same-line

# file options
--exclude **/Generated
--exclude **/Generated,build,vendor/bundle

# rules
--disable elseOnSameLine,semicolons,unusedArguments,opaqueGenericParameters
Expand Down
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ opt_in_rules:

excluded:
- BitwardenShared/UI/Platform/Application/Support/Generated
- build
- vendor/bundle

cyclomatic_complexity:
ignores_case_statements: true
Expand Down
22 changes: 22 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem 'danger'
gem 'danger-slather'
gem 'danger-xcode_summary'
110 changes: 110 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ targets:
- "**/TestHelpers/*"
- path: GlobalTestHelpers
dependencies:
- target: Bitwarden
- target: BitwardenShared
- package: SnapshotTesting
- package: ViewInspector
Expand Down

0 comments on commit e0e05b2

Please sign in to comment.