From 4ab7468e89d139f547ee5f0a77c90cf991451cd8 Mon Sep 17 00:00:00 2001 From: Paul Salaberria Date: Tue, 14 Nov 2023 12:03:39 +0100 Subject: [PATCH] Add Gazelle tests (#185) --- .github/workflows/ci.yaml | 11 +++++++++++ BUILD.bazel | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 00ca98ea..6bb72887 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,6 +15,17 @@ jobs: path: "/home/runner/.cache/bazel" key: bazel + - name: Gazelle + run: | + bazel run //:gazelle-update-repos + bazel run //:gazelle_check + if git diff --exit-code snapshots/dependencies.bzl ; then + echo "Gazelle repos are up to date." + else + echo "Gazelle repos aren't up to date. Run 'bazel run //:gazelle-update-repos' locally, and commit the changes." + exit 1 + fi + - name: Build run: | bazel build //... diff --git a/BUILD.bazel b/BUILD.bazel index 0e06f769..1bf79997 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,6 +4,16 @@ load("@bazel_gazelle//:def.bzl", "gazelle") # gazelle:proto disable_global gazelle(name = "gazelle") +# Gazelle check: exits with 1 if gazelle wants to make changes. +# +# Usage: +# bazel run gazelle_check +gazelle( + name = "gazelle_check", + command = "update", + extra_args = ["-mode=diff"], +) + gazelle( name = "gazelle-update-repos", args = [