[chore] Improve the Makefile to make it more robust to other environments. (#1063)
This commit is contained in:
parent
e299079696
commit
dadb51b7c3
35
Makefile
35
Makefile
|
|
@ -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 \
|
||||
|
|
@ -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 \
|
||||
|
|
@ -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 \
|
||||
|
|
@ -118,7 +129,7 @@ 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 \
|
||||
|
|
@ -126,11 +137,25 @@ table-check:
|
|||
--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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue