Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc(ci): detect breaking change to any .proto files or config fields in nodebuilder/**/config.go and add kind:break! #3568

Merged
merged 11 commits into from
Aug 9, 2024
30 changes: 30 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,33 @@ jobs:
mode: minimum
count: 1
labels: "kind:fix, kind:misc, kind:break!, kind:refactor, kind:feat, kind:deps, kind:docs, kind:ci, kind:chore, kind:testing" # yamllint disable-line rule:line-length

# will attempt to apply a breaking label
# on opening the PR but not enforce it on repeated changes
# so we don't get trapped by false positives (for now)
# we can expand to all cases after
apply-breaking:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'opened' && github.actor != 'dependabot[bot]' }}
permissions:
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run check for breaking
id: breaking_change
run: |
git fetch origin main
make detect-breaking

- name: Add label if breaking changes detected
if: failure()
run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
LABELS: kind:break!
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,32 @@ goreleaser-release:
goreleaser release --clean --fail-fast --skip-publish
.PHONY: goreleaser-release

# detect changed files and parse output
# to inspect changes to nodebuilder/**/config.go fields
CHANGED_FILES = $(shell git diff --name-only origin/main...HEAD)
detect-breaking:
@BREAK=false
@for file in ${CHANGED_FILES}; do \
if echo $$file | grep -qE '\.proto$$'; then \
BREAK=true; \
fi; \
if echo $$file | grep -qE 'nodebuilder/.*/config\.go'; then \
DIFF_OUTPUT=$$(git diff origin/main...HEAD $$file); \
if echo "$$DIFF_OUTPUT" | grep -qE 'type Config struct|^\s+\w+\s+Config'; then \
BREAK=true; \
fi; \
fi; \
done; \
if [ "$$BREAK" = true ]; then \
echo "break detected"; \
exit 1; \
else \
echo "no break detected"; \
exit 0; \
fi
.PHONY: detect-breaking


# Copied from https://github.com/dgraph-io/badger/blob/main/Makefile
USER_ID = $(shell id -u)
HAS_JEMALLOC = $(shell test -f /usr/local/lib/libjemalloc.a && echo "jemalloc")
Expand Down
Loading