Skip to content

Commit

Permalink
[chore] Rebuild .tools as they can be outdated (#5603)
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared authored May 20, 2024
1 parent d2e3069 commit bf9b41d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0 ## Needed for "Set tools/go.mod timestamp" step.
- name: Install Go
uses: actions/setup-go@v5
with:
Expand All @@ -34,6 +36,14 @@ jobs:
with:
path: .tools
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./tools/**') }}
# The step below is needed to not rebuild all the build tools.
- name: Set tools/go.mod timestamp
run: |
filename="tools/go.mod"
unixtime=$(git log -1 --format="%at" -- "${filename}")
touchtime=$(date -d @$unixtime +'%Y%m%d%H%M.%S')
touch -t ${touchtime} "${filename}"
ls -la --time-style=full-iso "${filename}"
- name: Generate
run: make generate
- name: Run linters
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TOOLS = $(CURDIR)/.tools

$(TOOLS):
@mkdir -p $@
$(TOOLS)/%: | $(TOOLS)
$(TOOLS)/%: $(TOOLS_MOD_DIR)/go.mod | $(TOOLS)
cd $(TOOLS_MOD_DIR) && \
$(GO) build -o $@ $(PACKAGE)

Expand Down Expand Up @@ -76,18 +76,18 @@ generate: go-generate vanity-import-fix
.PHONY: go-generate
go-generate: $(OTEL_GO_MOD_DIRS:%=go-generate/%)
go-generate/%: DIR=$*
go-generate/%: | $(STRINGER) $(GOTMPL)
go-generate/%: $(STRINGER) $(GOTMPL)
@echo "$(GO) generate $(DIR)/..." \
&& cd $(DIR) \
&& PATH="$(TOOLS):$${PATH}" $(GO) generate ./...

.PHONY: vanity-import-fix
vanity-import-fix: | $(PORTO)
vanity-import-fix: $(PORTO)
@$(PORTO) --include-internal -w .

# Generate go.work file for local development.
.PHONY: go-work
go-work: | $(CROSSLINK)
go-work: $(CROSSLINK)
$(CROSSLINK) work --root=$(shell pwd)

# Build
Expand Down Expand Up @@ -116,13 +116,13 @@ golangci-lint-fix: ARGS=--fix
golangci-lint-fix: golangci-lint
golangci-lint: $(OTEL_GO_MOD_DIRS:%=golangci-lint/%)
golangci-lint/%: DIR=$*
golangci-lint/%: | $(GOLANGCI_LINT)
golangci-lint/%: $(GOLANGCI_LINT)
@echo 'golangci-lint $(if $(ARGS),$(ARGS) ,)$(DIR)' \
&& cd $(DIR) \
&& $(GOLANGCI_LINT) run --allow-serial-runners $(ARGS)

.PHONY: crosslink
crosslink: | $(CROSSLINK)
crosslink: $(CROSSLINK)
@echo "Updating intra-repository dependencies in all go modules" \
&& $(CROSSLINK) --root=$(shell pwd) --prune

Expand All @@ -135,13 +135,13 @@ go-mod-tidy/%:
&& $(GO) mod tidy -compat=1.21

.PHONY: misspell
misspell: | $(MISSPELL)
misspell: $(MISSPELL)
@$(MISSPELL) -w $(ALL_DOCS)

.PHONY: govulncheck
govulncheck: $(ALL_GO_MOD_DIRS:%=govulncheck/%)
govulncheck/%: DIR=$*
govulncheck/%: | $(GOVULNCHECK)
govulncheck/%: $(GOVULNCHECK)
@echo "govulncheck in $(DIR)" \
&& cd $(DIR) \
&& $(GOVULNCHECK) ./...
Expand Down Expand Up @@ -252,26 +252,26 @@ test-mongo-driver:
.PHONY: gorelease
gorelease: $(OTEL_GO_MOD_DIRS:%=gorelease/%)
gorelease/%: DIR=$*
gorelease/%:| $(GORELEASE)
gorelease/%: $(GORELEASE)
@echo "gorelease in $(DIR):" \
&& cd $(DIR) \
&& $(GORELEASE) \
|| echo ""

COREPATH ?= "../opentelemetry-go"
.PHONY: sync-core
sync-core: | $(MULTIMOD)
sync-core: $(MULTIMOD)
@[ ! -d $COREPATH ] || ( echo ">> Path to core repository must be set in COREPATH and must exist"; exit 1 )
$(MULTIMOD) verify && $(MULTIMOD) sync -a -o ${COREPATH}

.PHONY: prerelease
prerelease: | $(MULTIMOD)
prerelease: $(MULTIMOD)
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
$(MULTIMOD) verify && $(MULTIMOD) prerelease -m ${MODSET}

COMMIT ?= "HEAD"
.PHONY: add-tags
add-tags: | $(MULTIMOD)
add-tags: $(MULTIMOD)
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
$(MULTIMOD) verify && $(MULTIMOD) tag -m ${MODSET} -c ${COMMIT}

Expand Down

0 comments on commit bf9b41d

Please sign in to comment.