Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from cgrindel/ios_app
Browse files Browse the repository at this point in the history
feat: add Swift modules and an iOS application
  • Loading branch information
alexeagle committed Oct 4, 2023
2 parents 048355e + f8ed18d commit d9583eb
Show file tree
Hide file tree
Showing 49 changed files with 1,397 additions and 125 deletions.
11 changes: 10 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
common --enable_bzlmod
# Test output information
test --test_output=errors --test_summary=detailed

common --enable_bzlmod

# The CNIOBoringSSL library uses C++14 features like 'enable_if_t' macro support.
# For more details on how to enable this in Bazel:
# https://stackoverflow.com/questions/40260242/how-to-set-c-standard-version-when-build-with-bazel/43388168#43388168
build --cxxopt='-std=c++14'

2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.0
6.3.2
57 changes: 54 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ on:
workflow_dispatch:

jobs:
test:
ubuntu_test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

env:
# Required for rules_swift
# https://github.com/bazelbuild/rules_swift#3-additional-configuration-linux-only
CC: clang

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Install the Swift toolchain
- uses: cgrindel/gha_install_swift_on_ubuntu@v1
with:
swift_release_tag: "swift-5.8.1-RELEASE"
ubuntu_version: "22.04"

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

Expand All @@ -27,9 +38,49 @@ jobs:
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'MODULE.bazel') }}
restore-keys: bazel-cache-

# Make the PATH available to build actions so that the Swift toolchain is discoverable.
- name: Update local.bazelrc with Linux Flags
shell: bash
run: |
cat >> "local.bazelrc" <<EOF
# Need to expose the PATH so that the Swift toolchain can be found
build --action_env=PATH
EOF
- name: bazel test //...
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
working-directory: ${{ matrix.folder }}
run: bazel test //...
run: |
bazel test //...
bazel test //:manual_tests
macos_test:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.3.1"
- uses: cgrindel/gha_set_up_bazel@v1
with:
repo_name: codelabs
- name: Execute Bazel Tests
shell: bash
run: |
bazel test //...
bazel test //:manual_tests
test:
runs-on: ubuntu-latest
needs:
- macos_test
- ubuntu_test
if: ${{ always() }}
steps:
- uses: cgrindel/gha_join_jobs@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}


6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
/bazel-*
node_modules/

# Swift package manager build directory
.build/

# Generated Xcode project
*.xcodeproj/
57 changes: 55 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("@rules_swift_package_manager//swiftpkg:defs.bzl", "swift_update_packages")

npm_link_all_packages(name = "node_modules")

Expand All @@ -10,7 +11,59 @@ compile_pip_requirements(
requirements_txt = "requirements_lock.txt",
)

# Ignore the `.build` folder that is created by running Swift package manager
# commands. The Swift Gazelle plugin executes some Swift package manager
# commands to resolve external dependencies. This results in a `.build` file
# being created.
# NOTE: Swift package manager is not used to build any of the external packages.
# The `.build` directory should be ignored. Be sure to configure your source
# control to ignore it (i.e., add it to your `.gitignore`).
# gazelle:exclude .build

# This declaration builds a Gazelle binary that incorporates all of the Gazelle
# plugins for the languages that you use in your workspace. In this example, we
# are enabling Gazelle's default languages (Go, protobuf) and the plugin from
# rules_swift_package_manager.
gazelle_binary(
name = "gazelle_bin",
languages = DEFAULT_LANGUAGES + [
"@rules_swift_package_manager//gazelle",
],
)

# This macro defines two targets: `swift_update_pkgs` and
# `swift_update_pkgs_to_latest`.
#
# The `swift_update_pkgs` target should be run whenever the list of external
# dependencies is updated in the `Package.swift`. Running this target will
# populate the `swift_deps.bzl` with `swift_package` declarations for all of
# the direct and transitive Swift packages that your project uses.
#
# The `swift_update_pkgs_to_latest` target should be run when you want to
# update your Swift dependencies to their latest eligible version.
swift_update_packages(
name = "swift_update_pkgs",
gazelle = ":gazelle_bin",
generate_swift_deps_for_workspace = False,
update_bzlmod_stanzas = True,
)

# gazelle:prefix github.com/aspect-build/codelabs

# This target updates the Bazel build files for your project. Run this target
# whenever you add or remove source files from your project.
gazelle(
name = "gazelle",
gazelle = ":gazelle_bin",
)

# Any tests that are too expensive to run when using `bazel test //...` should
# be marked manual and listed in this test_suite.
test_suite(
name = "manual_tests",
tags = ["manual"],
tests = [
"//ios/LoggingClient/UITests",
],
visibility = ["//:__subpackages__"],
)
80 changes: 49 additions & 31 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
"Declare dependencies for bzlmod, see https://bazel.build/build/bzlmod"
bazel_dep(name = "aspect_bazel_lib", version = "1.19.0")
bazel_dep(name = "aspect_rules_js", version = "1.13.1")
bazel_dep(name = "aspect_rules_ts", version = "1.0.5")
bazel_dep(name = "gazelle", version = "0.28.0", repo_name = "bazel_gazelle")
bazel_dep(name = "protobuf", version = "3.19.6")
bazel_dep(name = "rules_go", version = "0.37.0", repo_name = "io_bazel_rules_go")

bazel_dep(name = "aspect_bazel_lib", version = "1.19.0")
bazel_dep(name = "aspect_rules_js", version = "1.13.1")
bazel_dep(name = "aspect_rules_ts", version = "1.0.5")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "gazelle", version = "0.32.0", repo_name = "bazel_gazelle")
bazel_dep(name = "protobuf", version = "21.7")
bazel_dep(name = "rules_apple", version = "3.0.0")
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_jvm_external", version = "4.5")
bazel_dep(name = "rules_python", version = "0.16.1")
bazel_dep(name = "rules_python", version = "0.16.1")
bazel_dep(name = "rules_swift", version = "1.12.0")
bazel_dep(name = "rules_swift_package_manager", version = "0.12.0")

bazel_dep(name = "rules_xcodeproj", version = "1.11.0", dev_dependency = True)

# Python
# https://github.com/bazelbuild/rules_python/tree/main/examples/bzlmod
pip = use_extension("@rules_python//python:extensions.bzl", "pip")
python = use_extension("@rules_python//python:extensions.bzl", "python")

python = use_extension("@rules_python//python:extensions.bzl", "python")
python.toolchain(
name = "python3_9",
python_version = "3.9",
)

use_repo(python, "python3_9_toolchains")

register_toolchains(
Expand All @@ -28,19 +34,16 @@ pip.parse(
name = "pip",
requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")

# Java and other JVM languages:
# https://github.com/bazelbuild/rules_jvm_external/blob/master/examples/bzlmod/MODULE.bazel
# https://github.com/bazelbuild/rules_jvm_external#pinning-artifacts-and-integration-with-bazels-downloader
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")

maven.install(
artifacts = ["io.grpc:grpc-all:1.51.1"],
lock_file = "//:maven_install.json",
)

use_repo(
maven,
"maven",
Expand All @@ -51,44 +54,59 @@ use_repo(
# https://github.com/aspect-build/rules_js/tree/main/e2e/bzlmod
# https://github.com/aspect-build/rules_ts/tree/main/e2e/bzlmod
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")

npm.npm_translate_lock(
name = "npm",

pnpm_lock = "//:pnpm-lock.yaml",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
)

use_repo(npm, "npm")

rules_ts_ext = use_extension(
"@aspect_rules_ts//ts:extensions.bzl",
"ext",
dev_dependency = True,
)

rules_ts_ext.deps()

use_repo(rules_ts_ext, "npm_typescript")

# Go
# https://github.com/bazelbuild/rules_go/tree/master/tests/bcr
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")

go_sdk.download(name = "go_sdk", version = "1.19.3")
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(
name = "go_sdk",
version = "1.21.1",
)
use_repo(go_sdk, "go_sdk")

go_deps.module(
path = "google.golang.org/grpc",
version = "v1.50.1",
sum = "h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY=",
build_file_proto_mode = "disable"
go_deps.from_file(go_mod = "//:go.mod")
use_repo(go_deps, "org_golang_google_grpc", "org_golang_google_protobuf")

non_module_deps = use_extension("@rules_swift//swift:extensions.bzl", "non_module_deps")
use_repo(
non_module_deps,
"build_bazel_rules_swift_index_import",
"build_bazel_rules_swift_local_config",
"com_github_apple_swift_log",
"com_github_apple_swift_nio",
"com_github_apple_swift_nio_extras",
"com_github_apple_swift_nio_http2",
"com_github_apple_swift_nio_transport_services",
"com_github_apple_swift_protobuf",
"com_github_grpc_grpc_swift",
)
go_deps.module(
path = "google.golang.org/protobuf",
sum = "h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=",
version = "v1.28.1",
build_file_proto_mode = "disable"

# swift_deps START
swift_deps = use_extension(
"@rules_swift_package_manager//:extensions.bzl",
"swift_deps",
)
use_repo(go_deps, "org_golang_google_grpc", "org_golang_google_protobuf")
swift_deps.from_file(
deps_index = "//:swift_deps_index.json",
)
use_repo(
swift_deps,
"swiftpkg_swifterswift",
)
# swift_deps END
14 changes: 14 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "swifterswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SwifterSwift/SwifterSwift.git",
"state" : {
"revision" : "933f27d8e7fa0bf8200a5d6235e0de383b801126",
"version" : "5.3.0"
}
}
],
"version" : 2
}
10 changes: 10 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// swift-tools-version: 5.7

import PackageDescription

let package = Package(
name: "codelabs",
dependencies: [
.package(url: "https://github.com/SwifterSwift/SwifterSwift.git", from: "5.3.0"),
]
)
4 changes: 2 additions & 2 deletions backend/cmd/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_library(
deps = [
"//schema/logger",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_google_grpc//reflection:go_default_library",
"@org_golang_google_protobuf//encoding/protojson:go_default_library",
"@org_golang_google_grpc//reflection",
"@org_golang_google_protobuf//encoding/protojson",
],
)
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/aspect-build/codelabs
go 1.19

require (
google.golang.org/grpc v1.50.1
google.golang.org/protobuf v1.28.1
google.golang.org/grpc v1.58.2
google.golang.org/protobuf v1.31.0
)

require (
github.com/golang/protobuf v1.5.2 // indirect
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.3.3 // indirect
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
)
Loading

0 comments on commit d9583eb

Please sign in to comment.