Skip to content

Add support for running Bazel on Linux #907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
- uses: actions/checkout@master
- uses: jdx/mise-action@v2
- run: mise run lint-ci
bazel:
bazel_macos:
runs-on: macos-15
name: Bazel
name: Bazel (macOS)
steps:
- uses: actions/checkout@master
- uses: jdx/mise-action@v2
Expand All @@ -34,7 +34,20 @@ jobs:
run: mise r gen-bazel-rules && git diff --quiet --exit-code
- name: Scan
run: bazel run //:periphery -- scan --bazel --quiet --strict --baseline baselines/bazel.json
macOS:
bazel_linux:
runs-on: ubuntu-latest
container: swift:latest
name: Bazel (Linux)
steps:
- uses: actions/checkout@master
- uses: bazel-contrib/[email protected]
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Scan
run: CC=clang bazel run --spawn_strategy=standalone //:periphery -- scan --bazel --quiet --strict --baseline baselines/bazel.json
macos:
name: macOS
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .mise/tasks/scan-linux
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -e

export DOCKER_CLI_HINTS=false
docker build -t periphery -f docker/Dockerfile.linux .
docker build -t periphery -f docker/Dockerfile-Linux .
docker run --rm -t periphery scan "$@" --baseline baselines/linux.json
7 changes: 7 additions & 0 deletions .mise/tasks/scan-linux-bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

export DOCKER_CLI_HINTS=false
docker build -t periphery -f docker/Dockerfile-Bazel .
docker run --rm -t periphery scan "$@" --bazel --verbose --baseline baselines/linux.json
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bazel_dep(name = "rules_swift", version = "2.3.0")
bazel_dep(name = "rules_apple", version = "3.16.0")
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.11")

# Swift dependencies
bazel_dep(name = "aexml", version = "4.7.0")
Expand Down
35 changes: 18 additions & 17 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions Sources/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ swift_library(
],
)

_PROJECT_DRIVERS_DEPS = [
"//Sources:Indexer",
"//Sources:Shared",
"//Sources:SourceGraph",
]

swift_library(
name = "ProjectDrivers",
srcs = [
Expand All @@ -133,12 +139,10 @@ swift_library(
"ProjectDrivers/XcodeProjectDriver.swift",
],
module_name = "ProjectDrivers",
deps = [
"//Sources:Indexer",
"//Sources:Shared",
"//Sources:SourceGraph",
"//Sources:XcodeSupport",
],
deps = select({
"@platforms//os:macos": _PROJECT_DRIVERS_DEPS + ["//Sources:XcodeSupport"],
"//conditions:default": _PROJECT_DRIVERS_DEPS,
}),
)

swift_library(
Expand Down
17 changes: 17 additions & 0 deletions docker/Dockerfile-Bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM swift:latest

RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*

RUN curl -Lo /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-arm64 \
&& chmod +x /usr/local/bin/bazelisk \
&& ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel

WORKDIR /workspace
COPY . /workspace

ENV CC=clang
RUN bazel build //:periphery

ENTRYPOINT ["bazel-bin/Sources/Frontend_opt"]
File renamed without changes.
Loading