diff --git a/Makefile b/Makefile index cf8a84ff571a9..0e36e67d9e74a 100644 --- a/Makefile +++ b/Makefile @@ -1543,8 +1543,7 @@ derive: .PHONY: derive-up-to-date derive-up-to-date: must-start-clean/host derive @if ! git diff --quiet; then \ - echo 'Please run make derive.'; \ - git diff; \ + ./build.assets/tooling/cmd/please-run.sh "derived functions" "make derive"; \ exit 1; \ fi @@ -1579,16 +1578,14 @@ endif .PHONY: protos-up-to-date/host protos-up-to-date/host: must-start-clean/host grpc/host @if ! git diff --quiet; then \ - echo 'Please run make grpc.'; \ - git diff; \ + ./build.assets/tooling/cmd/please-run.sh "protos gRPC" "make grpc"; \ exit 1; \ fi .PHONY: must-start-clean/host must-start-clean/host: @if ! git diff --quiet; then \ - echo 'This must be run from a repo with no unstaged commits.'; \ - git diff; \ + ./build.assets/tooling/cmd/please-run.sh "protos gRPC" "make grpc"; \ exit 1; \ fi @@ -1597,14 +1594,12 @@ must-start-clean/host: crds-up-to-date: must-start-clean/host $(MAKE) -C integrations/operator manifests @if ! git diff --quiet; then \ - echo 'Please run make -C integrations/operator manifests.'; \ - git diff; \ + ./build.assets/tooling/cmd/please-run.sh "operator CRD manifests" "make -C integrations/operator crd"; \ exit 1; \ fi $(MAKE) -C integrations/operator crd-docs @if ! git diff --quiet; then \ - echo 'Please run make -C integrations/operator crd-docs.'; \ - git diff; \ + ./build.assets/tooling/cmd/please-run.sh "operator CRD docs" "make -C integrations/operator crd"; \ exit 1; \ fi @@ -1613,8 +1608,7 @@ crds-up-to-date: must-start-clean/host terraform-resources-up-to-date: must-start-clean/host $(MAKE) -C integrations/terraform docs @if ! git diff --quiet; then \ - echo 'Please run make -C integrations/terraform docs.'; \ - git diff; \ + ./build.assets/tooling/cmd/please-run.sh "TF provider docs" "make -C integrations/terraform docs"; \ exit 1; \ fi diff --git a/api/proto/teleport/accesslist/v1/accesslist.proto b/api/proto/teleport/accesslist/v1/accesslist.proto index 373c325027d39..0b8211b75f627 100644 --- a/api/proto/teleport/accesslist/v1/accesslist.proto +++ b/api/proto/teleport/accesslist/v1/accesslist.proto @@ -64,6 +64,8 @@ message AccessListSpec { AccessListRequires ownership_requires = 5; // grants describes the access granted by membership to this Access List. + // This is a totally new comment + // And I forgot to run the generation commands. AccessListGrants grants = 6; // title is a plaintext short description of the Access List. diff --git a/build.assets/tooling/cmd/please-run.sh b/build.assets/tooling/cmd/please-run.sh new file mode 100755 index 0000000000000..c58f29d836cff --- /dev/null +++ b/build.assets/tooling/cmd/please-run.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +# This script is a helper that tells developers what generated content is out of date +# and which command to run. +# When running on GitHub actions, the script will also create an error in the PR and +# collapse the diff to improve readability. + +set -eu + +KIND="$1" +GENERATE_COMMAND="$2" + +TITLE="$KIND are out-of-date" +MESSAGE="Please run the command \`$GENERATE_COMMAND\`" + +if [ -z ${GITHUB_ACTIONS+x} ]; +then + # We are not in GitHub Actions + echo "=============" + echo "$TITLE" + echo "$MESSAGE" + echo "=============" + + git diff || true +else + # We are in GitHub Actions + + # Create a GitHub error + echo "::error file=Makefile,title=$TITLE::$MESSAGE" + + # Also write to the job logs + echo "=============" + echo "$TITLE" + echo "$MESSAGE" + echo "=============" + + echo "::group::Diff output" + git diff || true + echo "::endgroup::" +fi \ No newline at end of file diff --git a/integrations/operator/Makefile b/integrations/operator/Makefile index 145a7c97dd9b1..4b8b07247e847 100644 --- a/integrations/operator/Makefile +++ b/integrations/operator/Makefile @@ -72,6 +72,9 @@ help: ## Display this help. ##@ Development +.PHONY: crd ## Single command to generate anything CRD-related (manifests and docs) +crd: crdgen crd-docs + .PHONY: crdgen crdgen: ## Generate CRDs make -C crdgen