Skip to content

Commit

Permalink
Improve Bazel integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch committed Nov 3, 2024
1 parent 52d6e73 commit 5afed96
Show file tree
Hide file tree
Showing 24 changed files with 913 additions and 112 deletions.
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.build
.git
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3.0
7.4.0
24 changes: 15 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,29 @@ env:
cache_version: 1
jobs:
lint:
runs-on: macos-14
runs-on: macos-15
name: Lint
steps:
- uses: actions/checkout@master
- uses: jdx/mise-action@v2
- run: mise run lint-ci
bazel:
runs-on: macos-15
name: Bazel
steps:
- uses: actions/checkout@master
- name: Scan
run: bazel run //:periphery -- scan --bazel --quiet --strict
macOS:
strategy:
fail-fast: false
matrix:
xcode: ["16.0", "15.4", "15.2"]
xcode: ["16.1", "16.0", "15.4", "15.2"]
include:
- xcode: "16.1"
macos: macos-15
- xcode: "16.0"
macos: macos-14
macos: macos-15
- xcode: "15.4"
macos: macos-14
- xcode: "15.2"
Expand Down Expand Up @@ -69,33 +78,30 @@ jobs:
include:
- swift: "6.0"
container: "swift:6.0"
cache-version: 1
- swift: "5.10"
container: "swift:5.10"
cache-version: 1
- swift: "5.9"
container: "swift:5.9"
cache-version: 1
runs-on: ubuntu-20.04
container: ${{ matrix.container }}
name: Linux
steps:
- uses: actions/checkout@master
- name: Get Swift Version
id: get-swift-version
run: |
echo "::set-output name=version::$(swift -version | head -n 1 | sed s/,// )"
shell: bash
- uses: actions/checkout@master
- name: Cache resolved dependencies
id: cache-resolved-dependencies
uses: actions/cache@v2
with:
path: |
.build
Package.resolved
key: ${{ matrix.cache-version }}-${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps-${{ hashFiles('Package.swift', 'Package.resolved') }}
key: ${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps-${{ hashFiles('Package.swift', 'Package.resolved') }}
restore-keys: |
${{ matrix.cache-version }}-${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps-
${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps-
- name: Resolve dependencies
if: steps.cache-resolved-dependencies.outputs.cache-hit != 'true'
run: ${{ env.swift_package_resolve }}
Expand Down
1 change: 1 addition & 0 deletions .mise/tasks/lint
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set -euo pipefail

cd $MISE_PROJECT_ROOT

bazel run //bazel/internal:buildifier.fix
swiftformat .
swiftlint lint --quiet
1 change: 1 addition & 0 deletions .mise/tasks/lint-ci
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set -euo pipefail

cd $MISE_PROJECT_ROOT

bazel run //bazel/internal:buildifier.check
swiftformat --quiet --strict .
swiftlint lint --quiet --strict
10 changes: 8 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package_group(
name = "generated",
includes = [
"@periphery_generated//:package_group"
"@periphery_generated//:package_group",
],
)

Expand All @@ -10,4 +10,10 @@ package_group(
packages = ["//..."],
)

alias(actual = "@periphery_generated//rule:scan", name = "scan")
sh_binary(
name = "periphery",
srcs = ["//bazel/internal:run.sh"],
data = [
"//Sources:Frontend",
],
)
27 changes: 25 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,32 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "rules_swift", version = "2.1.1")
bazel_dep(name = "rules_apple", version = "3.8.0")
# Bazel dependencies
bazel_dep(name = "rules_swift", version = "2.2.2")
bazel_dep(name = "rules_apple", version = "3.11.1")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "apple_support", version = "1.17.1")
bazel_dep(name = "platforms", version = "0.0.10")

# Bazel dev dependencies
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)

# Swift dependencies
bazel_dep(name = "swift-syntax", version = "600.0.0") # TODO: Update to 600.0.1
bazel_dep(name = "yams", version = "5.1.3")
bazel_dep(name = "aexml", version = "4.7.0")
bazel_dep(name = "swift_argument_parser", version = "1.3.1.1") # TODO: Update to 1.5.0
bazel_dep(name = "swift-indexstore", version = "0.3.0")
bazel_dep(name = "swift-filename-matcher", version = "0.1.2")

# Extensions
generated = use_extension("//bazel:extensions.bzl", "generated")
use_repo(generated, "periphery_generated")

non_module_deps = use_extension("//bazel/internal:extensions.bzl", "non_module_deps")
use_repo(
non_module_deps,
"com_github_apple_swift-system",
"com_github_kylef_pathkit",
"com_github_tuist_xcodeproj",
)
Loading

0 comments on commit 5afed96

Please sign in to comment.