Skip to content

Commit

Permalink
Adds Bazel Build Support (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinder-maxwellelliott authored May 3, 2021
1 parent 39a83bb commit 3b2783e
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0.0
21 changes: 21 additions & 0 deletions .github/workflows/bazelbuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Bazel Build

on: [pull_request]

env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer

jobs:
macos:
name: Bazel
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Test iOS
run: bazelisk test //Tests:KronosTestsiOS --test_output=errors
- name: Test MacOS
run: bazelisk test //Tests:KronosTestsMacOS --test_output=errors
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ build/
Carthage/Build
coverage.txt
DerivedData
Icon
Icon

run-tests
xcuserdata
Packages/

bazel-*
8 changes: 8 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

swift_library(
name = "Kronos",
module_name = "Kronos",
srcs = glob(["Sources/*.swift"]),
visibility = ["//visibility:public"]
)
66 changes: 66 additions & 0 deletions Tests/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

load(
"@build_bazel_rules_apple//apple:ios.bzl",
"ios_unit_test",
"ios_application"
)

load(
"@build_bazel_rules_apple//apple:macos.bzl",
"macos_unit_test"
)

load(
"@build_bazel_rules_apple//apple:tvos.bzl",
"tvos_unit_test",
"tvos_application"
)

MINIMUM_IOS_VERSION = "9.0"

MINIMUM_MACOS_VERSION = "10.9"

MINIMUM_TVOS_VERSION = "14.5"

swift_library(
name = "KronosTests",
srcs = glob(["KronosTests/*.swift"]),
deps = ["//:Kronos"]
)

genrule(
name = "AppDelegate",
outs = ["AppDelegate.swift"],
cmd = """
echo "import UIKit\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\nvar window: UIWindow?\n}" > $@
"""
)

swift_library(
name = "lib",
srcs = ["AppDelegate.swift"],
)

ios_application(
name = "iOSTestApp",
bundle_id = "com.Lyft.Kronos",
families = ["iphone"],
infoplists = ["Info.plist"],
minimum_os_version = MINIMUM_IOS_VERSION,
launch_storyboard = "Main.storyboard",
deps = [":lib"],
)

ios_unit_test(
name = "KronosTestsiOS",
deps = [":KronosTests"],
minimum_os_version = MINIMUM_IOS_VERSION,
test_host = ":iOSTestApp"
)

macos_unit_test(
name = "KronosTestsMacOS",
deps = [":KronosTests"],
minimum_os_version = MINIMUM_MACOS_VERSION
)
36 changes: 36 additions & 0 deletions Tests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
42 changes: 42 additions & 0 deletions Tests/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hello World" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Z9g-BR-NKm">
<rect key="frame" x="143" y="323" width="89" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Z9g-BR-NKm" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="b9H-lm-x4b"/>
<constraint firstItem="Z9g-BR-NKm" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="uTp-aY-7lJ"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
35 changes: 35 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "build_bazel_rules_apple",
sha256 = "84f34c95e68f65618b54c545f75e2df73559af47fb42ae28b17189fcebb7ed17",
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.31.1/rules_apple.0.31.1.tar.gz",
)

load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)

apple_rules_dependencies()

load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)

swift_rules_dependencies()

load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)

apple_support_dependencies()

0 comments on commit 3b2783e

Please sign in to comment.