mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 13:31:54 +00:00
build: add gazelle checks to Aspect Workflows (#58568)
Co-authored-by: William Bezuidenhout <william.bezuidenhout@sourcegraph.com>
This commit is contained in:
parent
5a70adce92
commit
9b8d25a5fb
@ -13,7 +13,9 @@ env:
|
||||
GIT_PAGER: ''
|
||||
tasks:
|
||||
# Checks that BUILD file content is up-to-date with sources
|
||||
# gazelle:
|
||||
gazelle:
|
||||
target: //:configure
|
||||
fix_target: //:configure
|
||||
# Checks that all tests are passing
|
||||
test:
|
||||
include_eternal_tests: true
|
||||
|
||||
@ -201,6 +201,13 @@ gazelle(
|
||||
gazelle = ":gazelle-buf",
|
||||
)
|
||||
|
||||
sh_binary(
|
||||
name = "configure",
|
||||
srcs = ["//dev/ci:bazel-configure.sh"],
|
||||
data = ["@go_sdk//:bin/go"],
|
||||
env = {"GO": "$(rootpath @go_sdk//:bin/go)"},
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "sourcegraph",
|
||||
srcs = [
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
|
||||
exports_files([
|
||||
"bazel-configure.sh",
|
||||
])
|
||||
|
||||
go_library(
|
||||
name = "ci_lib",
|
||||
srcs = ["gen-pipeline.go"],
|
||||
|
||||
32
dev/ci/bazel-configure.sh
Executable file
32
dev/ci/bazel-configure.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit -o nounset -o pipefail
|
||||
|
||||
# Add go to PATH
|
||||
readonly runfiles_dir="${PWD}"
|
||||
PATH="$(dirname "${runfiles_dir}/${GO}"):${PATH}"
|
||||
# Remove bazelisk from path
|
||||
PATH=$(echo "${PATH}" | awk -v RS=: -v ORS=: '/bazelisk/ {next} {print}')
|
||||
export PATH
|
||||
# Allow Aspect to re-enter again
|
||||
export ASPECT_REENTRANT=
|
||||
|
||||
cd "${BUILD_WORKSPACE_DIRECTORY}"
|
||||
|
||||
bazel configure
|
||||
|
||||
if [ "${CI:-}" ]; then
|
||||
git ls-files --exclude-standard --others | grep -v .aspect/bazelrc/ci.generated.bazelrc | xargs git add --intent-to-add || true
|
||||
|
||||
diff_file=$(mktemp)
|
||||
trap 'rm -f "${diff_file}"' EXIT
|
||||
|
||||
EXIT_CODE=0
|
||||
git diff --color=never --output="${diff_file}" --exit-code || EXIT_CODE=$?
|
||||
|
||||
# if we have a diff, BUILD files were updated so we notify people
|
||||
if [[ $EXIT_CODE -ne 0 ]]; then
|
||||
cat "${diff_file}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user