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

[chore] Improve the Makefile to make it more robust to other environments. #1063

Merged
merged 2 commits into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ CHLOGGEN_CONFIG := .chloggen/config.yaml
SEMCONVGEN_VERSION=0.24.0
WEAVER_VERSION=0.2.0

# From where to resolve the containers (e.g. "otel/weaver").
CONTAINER_REPOSITORY=docker.io

# Per container overrides for the repository resolution.
WEAVER_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)
SEMCONVGEN_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)

# Fully qualified references to containers used in this Makefile.
WEAVER_CONTAINER=$(WEAVER_CONTAINER_REPOSITORY)/otel/weaver:$(WEAVER_VERSION)
SEMCONVGEN_CONTAINER=$(SEMCONVGEN_CONTAINER_REPOSITORY)/otel/semconvgen:$(SEMCONVGEN_VERSION)

# TODO: add `yamllint` step to `all` after making sure it works on Mac.
.PHONY: all
all: install-tools markdownlint markdown-link-check misspell table-check compatibility-check schema-check \
Expand Down Expand Up @@ -96,7 +107,7 @@ yamllint:
.PHONY: table-generation
table-generation:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec -v $(PWD)/templates:/weaver/templates \
otel/weaver:${WEAVER_VERSION} registry update-markdown \
$(WEAVER_CONTAINER) registry update-markdown \
--registry=/source \
--attribute-registry-base-url=/docs/attributes-registry \
--templates=/weaver/templates \
Expand All @@ -107,7 +118,7 @@ table-generation:
.PHONY: attribute-registry-generation
attribute-registry-generation:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec -v $(PWD)/templates:/weaver/templates \
otel/weaver:${WEAVER_VERSION} registry generate \
$(WEAVER_CONTAINER) registry generate \
--registry=/source \
--templates=/weaver/templates \
markdown \
Expand All @@ -118,19 +129,33 @@ attribute-registry-generation:
.PHONY: table-check
table-check:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec -v $(PWD)/templates:/weaver/templates \
otel/weaver:${WEAVER_VERSION} registry update-markdown \
$(WEAVER_CONTAINER) registry update-markdown \
--registry=/source \
--attribute-registry-base-url=/docs/attributes-registry \
--templates=/weaver/templates \
--target=markdown \
--dry-run \
/spec

LATEST_RELEASED_SEMCONV_VERSION := $(shell git describe --tags --abbrev=0 | sed 's/v//g')

# A previous iteration of calculating "LATEST_RELEASED_SEMCONV_VERSION"
# relied on "git describe". However, that approach does not work with
# light-weight developer forks/branches that haven't synced tags. Hence the
# more complex implementation of this using "git ls-remote".
#
# The output of "git ls-remote" looks something like this:
#
# e531541025992b68177a68b87628c5dc75c4f7d9 refs/tags/v1.21.0
# cadfe53949266d33476b15ca52c92f682600a29c refs/tags/v1.22.0
# ...
#
# .. which is why some additional processing is required to extract the
# latest version number and strip off the "v" prefix.
LATEST_RELEASED_SEMCONV_VERSION := $(shell git ls-remote --tags https://github.com/open-telemetry/semantic-conventions.git | cut -f 2 | sort --reverse | head -n 1 | tr '/' ' ' | cut -d ' ' -f 3 | sed 's/v//g')
.PHONY: compatibility-check
compatibility-check:
docker run --rm -v $(PWD)/model:/source -v $(PWD)/docs:/spec --pull=always \
otel/semconvgen:$(SEMCONVGEN_VERSION) -f /source compatibility --previous-version $(LATEST_RELEASED_SEMCONV_VERSION)
$(SEMCONVGEN_CONTAINER) -f /source compatibility --previous-version $(LATEST_RELEASED_SEMCONV_VERSION)

.PHONY: schema-check
schema-check:
Expand Down
Loading