Skip to content

Commit

Permalink
[chore] Make check-contrib rebuild and reapply tools (open-telemetr…
Browse files Browse the repository at this point in the history
…y#11670)

#### Description

There have been issues where changes in `mdatagen` are not properly
tested in CI and end up breaking collector-contrib (cf. open-telemetry#11167). This is
because `make check-contrib` does not rebuild or rerun `mdatagen` before
running contrib tests. This PR fixes that.

I added a flag to disable this when running manually, as it adds
significant time (~3 min!) to the run and is only really useful when
`mdatagen` has been modified.

I had to change the `make gotidy` to `make for-all CMD="go mod tidy"`
because we don't have a way to run `generate` on a specific module group
(and doing so may cause false-positives/negatives if a module group
depends on the generated files of another).

#### Link to tracking issue
Fixes open-telemetry#11167
  • Loading branch information
jade-guiton-dd authored and HongChenTW committed Dec 19, 2024
1 parent 629faa1 commit c7ae432
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,30 @@ check-contrib:
@echo Setting contrib at $(CONTRIB_PATH) to use this core checkout
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
$(addprefix -replace ,$(join $(ALL_MOD_PATHS:%=go.opentelemetry.io/collector%=),$(ALL_MOD_PATHS:%=$(CURDIR)%)))"
@$(MAKE) -C $(CONTRIB_PATH) gotidy
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod tidy"

@$(MAKE) generate-contrib

@echo -e "\nRunning tests"
@$(MAKE) -C $(CONTRIB_PATH) gotest

@if [ -z "$(SKIP_RESTORE_CONTRIB)" ]; then \
$(MAKE) restore-contrib; \
fi

.PHONY: generate-contrib
generate-contrib:
@echo -e "\nGenerating files in contrib"
$(MAKE) -C $(CONTRIB_PATH) -B install-tools
$(MAKE) -C $(CONTRIB_PATH) generate GROUP=all

# Restores contrib to its original state after running check-contrib.
.PHONY: restore-contrib
restore-contrib:
@echo Restoring contrib at $(CONTRIB_PATH) to its original state
@echo -e "\nRestoring contrib at $(CONTRIB_PATH) to its original state"
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod edit \
$(addprefix -dropreplace ,$(ALL_MOD_PATHS:%=go.opentelemetry.io/collector%))"
@$(MAKE) -C $(CONTRIB_PATH) -j2 gotidy
@$(MAKE) -C $(CONTRIB_PATH) for-all CMD="$(GOCMD) mod tidy"

# List of directories where certificates are stored for unit tests.
CERT_DIRS := localhost|""|config/configgrpc/testdata \
Expand Down

0 comments on commit c7ae432

Please sign in to comment.