diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48a8d06d1..d48b43ca8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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/setup-bazel@0.14.0 + 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 diff --git a/.mise/tasks/scan-linux b/.mise/tasks/scan-linux index d4fc1a54b..4fe4b350a 100755 --- a/.mise/tasks/scan-linux +++ b/.mise/tasks/scan-linux @@ -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 diff --git a/.mise/tasks/scan-linux-bazel b/.mise/tasks/scan-linux-bazel new file mode 100755 index 000000000..8bd558594 --- /dev/null +++ b/.mise/tasks/scan-linux-bazel @@ -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 diff --git a/MODULE.bazel b/MODULE.bazel index a8c47a79c..ba6dd9135 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 8c900180f..4a0431abb 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -59,7 +59,8 @@ "https://bcr.bazel.build/modules/pathkit/1.0.1/MODULE.bazel": "fae93989a10f8d90d5ac02453e6632ae7f71111687862c01f468858cef40bb5e", "https://bcr.bazel.build/modules/pathkit/1.0.1/source.json": "3215e6b4b08f96f34024eaf186d247744ca255925d7ee3f50cf94f7cf885696b", "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", - "https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5", + "https://bcr.bazel.build/modules/platforms/0.0.11/MODULE.bazel": "0daefc49732e227caa8bfa834d65dc52e8cc18a2faf80df25e8caea151a9413f", + "https://bcr.bazel.build/modules/platforms/0.0.11/source.json": "f7e188b79ebedebfe75e9e1d098b8845226c7992b307e28e1496f23112e8fc29", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", @@ -175,6 +176,22 @@ }, "selectedYankedVersions": {}, "moduleExtensions": { + "//bazel:generated.bzl%generated": { + "general": { + "bzlTransitiveDigest": "nMR2FBcoRPImVocN9DNOnm2NQWyTbJPu7SHJgAXsLFw=", + "usagesDigest": "4V0SQiDEBMW4aAeaNSRW2lPd5NPkALfgBsR7pBFNlPU=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "periphery_generated": { + "repoRuleId": "@@//bazel:generated.bzl%generated_repo", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [] + } + }, "@@apple_support+//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { "bzlTransitiveDigest": "Ync9nL0AbHC6ondeEY7fBjBjLxojTsiXcJh65ZDTRlA=", @@ -345,22 +362,6 @@ ] } }, - "@@platforms//host:extension.bzl%host_platform": { - "general": { - "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", - "usagesDigest": "SeQiIN/f8/Qt9vYQk7qcXp4I4wJeEC0RnQDiaaJ4tb8=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "host_platform": { - "repoRuleId": "@@platforms//host:extension.bzl%host_platform_repo", - "attributes": {} - } - }, - "recordedRepoMappingEntries": [] - } - }, "@@rules_java+//java:rules_java_deps.bzl%compatibility_proxy": { "general": { "bzlTransitiveDigest": "84xJEZ1jnXXwo8BXMprvBm++rRt4jsTu9liBxz0ivps=", diff --git a/Sources/BUILD.bazel b/Sources/BUILD.bazel index df238b8c9..aafd40439 100644 --- a/Sources/BUILD.bazel +++ b/Sources/BUILD.bazel @@ -122,6 +122,12 @@ swift_library( ], ) +_PROJECT_DRIVERS_DEPS = [ + "//Sources:Indexer", + "//Sources:Shared", + "//Sources:SourceGraph", +] + swift_library( name = "ProjectDrivers", srcs = [ @@ -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( diff --git a/docker/Dockerfile-Bazel b/docker/Dockerfile-Bazel new file mode 100644 index 000000000..e7927df7d --- /dev/null +++ b/docker/Dockerfile-Bazel @@ -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"] diff --git a/docker/Dockerfile.linux b/docker/Dockerfile-Linux similarity index 100% rename from docker/Dockerfile.linux rename to docker/Dockerfile-Linux