mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:21:50 +00:00
130 lines
3.2 KiB
Python
130 lines
3.2 KiB
Python
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
|
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
|
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push", "oci_tarball")
|
|
load("@rules_pkg//:pkg.bzl", "pkg_tar")
|
|
load("@container_structure_test//:defs.bzl", "container_structure_test")
|
|
load("//dev:oci_defs.bzl", "image_repository")
|
|
|
|
go_library(
|
|
name = "executor_lib",
|
|
srcs = ["main.go"],
|
|
importpath = "github.com/sourcegraph/sourcegraph/cmd/executor",
|
|
visibility = ["//visibility:private"],
|
|
deps = [
|
|
"//cmd/executor/internal/config",
|
|
"//cmd/executor/internal/run",
|
|
"//cmd/executor/internal/util",
|
|
"//internal/env",
|
|
"//internal/hostname",
|
|
"//internal/logging",
|
|
"//internal/sanitycheck",
|
|
"//internal/version",
|
|
"@com_github_sourcegraph_log//:log",
|
|
"@com_github_urfave_cli_v2//:cli",
|
|
],
|
|
)
|
|
|
|
go_binary(
|
|
name = "executor",
|
|
embed = [":executor_lib"],
|
|
visibility = ["//visibility:public"],
|
|
x_defs = {
|
|
"github.com/sourcegraph/sourcegraph/internal/version.version": "{STABLE_VERSION}",
|
|
"github.com/sourcegraph/sourcegraph/internal/version.timestamp": "{VERSION_TIMESTAMP}",
|
|
},
|
|
)
|
|
|
|
# Ensure this builds, so we don't fail at publish time later on in the pipeline.
|
|
build_test(
|
|
name = "executor_build_test",
|
|
targets = [":executor"],
|
|
)
|
|
|
|
go_binary(
|
|
name = "executor_sh",
|
|
basename = "executor",
|
|
embed = [":executor_lib"],
|
|
gotags = [
|
|
"shell",
|
|
],
|
|
visibility = ["//visibility:public"],
|
|
x_defs = {
|
|
"github.com/sourcegraph/sourcegraph/internal/version.version": "{STABLE_VERSION}",
|
|
"github.com/sourcegraph/sourcegraph/internal/version.timestamp": "{VERSION_TIMESTAMP}",
|
|
},
|
|
)
|
|
|
|
pkg_tar(
|
|
name = "tar_executor",
|
|
srcs = [":executor"],
|
|
visibility = ["//cmd/bundled-executor:__pkg__"],
|
|
)
|
|
|
|
pkg_tar(
|
|
name = "tar_batcheshelper",
|
|
srcs = ["//cmd/batcheshelper"],
|
|
package_dir = "/usr/local/bin",
|
|
)
|
|
|
|
pkg_tar(
|
|
name = "tar_src-cli",
|
|
srcs = ["@src-cli-linux-amd64//:src-cli-linux-amd64"],
|
|
package_dir = "/usr/local/bin",
|
|
)
|
|
|
|
oci_image(
|
|
name = "image",
|
|
base = "@wolfi_executor_base",
|
|
entrypoint = [
|
|
"/sbin/tini",
|
|
"--",
|
|
"/executor",
|
|
],
|
|
env = {
|
|
"EXECUTOR_USE_FIRECRACKER": "false", # Firecracker doesn't work in docker, so disable it by default
|
|
},
|
|
tars = [
|
|
":tar_executor",
|
|
":tar_src-cli",
|
|
":tar_batcheshelper",
|
|
],
|
|
user = "sourcegraph",
|
|
)
|
|
|
|
oci_tarball(
|
|
name = "image_tarball",
|
|
image = ":image",
|
|
repo_tags = ["executor:candidate"],
|
|
)
|
|
|
|
container_structure_test(
|
|
name = "image_test",
|
|
timeout = "short",
|
|
configs = ["image_test.yaml"],
|
|
driver = "docker",
|
|
image = ":image",
|
|
tags = [
|
|
"exclusive",
|
|
"requires-network",
|
|
],
|
|
)
|
|
|
|
oci_push(
|
|
name = "candidate_push",
|
|
image = ":image",
|
|
repository = image_repository("executor"),
|
|
)
|
|
|
|
sh_binary(
|
|
name = "binary.push",
|
|
srcs = ["_binary.push.sh"],
|
|
args = [
|
|
"$(location //dev/tools:gsutil)",
|
|
"$(location :executor)",
|
|
],
|
|
data = [
|
|
":executor",
|
|
"//dev/tools:gsutil",
|
|
],
|
|
)
|