Skip to content

Commit

Permalink
misc(ci): detect breaking change to any .proto files or config fields…
Browse files Browse the repository at this point in the history
… in nodebuilder/**/config.go and add kind:break! (#3568)

(cherry picked from commit 73235c6)
  • Loading branch information
ramin authored and walldiss committed Aug 15, 2024
1 parent 94cda2d commit 8486a3e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
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

0 comments on commit 8486a3e

Please sign in to comment.