LSW_WEBDIR ?= $(top_srcdir)/RESULTS WEB_SUMMARYDIR ?= $(LSW_WEBDIR) ifneq ($(wildcard $(WEB_SUMMARYDIR)),) WEB_ENABLED ?= true endif
WEB_UTILSDIR ?= testing/utils WEB_SOURCEDIR ?= testing/web WEB_REPODIR ?= .
WEB_SUBDIR ?= $(shell $(WEB_SOURCEDIR)/gime-git-description.sh $(WEB_REPODIR))
ifdef WEB_ENABLED ifndef WEB_HASH WEB_HASH := $(shell cd $(WEB_REPODIR) ; git show --no-patch --format=%H HEAD) endif ifndef WEB_RESULTSDIR WEB_RESULTSDIR := $(WEB_SUMMARYDIR)/$(WEB_SUBDIR) endif ifndef WEB_SOURCES WEB_SOURCES := $(wildcard $(addprefix $(WEB_SOURCEDIR)/, .css .js *.html)) endif ifndef WEB_TIME WEB_TIME := $(shell $(WEB_SOURCEDIR)/now.sh) endif ifndef WEB_TESTSDIR WEB_TESTSDIR := $(WEB_SUMMARYDIR)/tests endif endif
web web-page: | $(WEB_SUMMARYDIR) $(MAKE) web-resultsdir web-summarydir
$(WEB_SUMMARYDIR): mkdir $(WEB_SUMMARYDIR)
.PHONY: web-test-prep web-test-post web-page web web-test-prep: web-test-post: ifdef WEB_ENABLED web-test-prep: web-results-html web-summarydir web-testsdir web-test-post: web-tests-json endif
.PHONY: web-site web-site:
.PHONY: web-summarydir web-summarydir:
.PHONY: web-resultsdir web-resultsdir:
ifdef WEB_ENABLED
web-testsdir: | $(WEB_TESTSDIR) $(WEB_TESTSDIR): mkdir $@
.PHONY: web-tests-json: $(WEB_SOURCEDIR)/json-tests.sh $(WEB_REPODIR) $(WEB_TESTSDIR) $(WEB_RESULTSDIR)
endif
ifdef WEB_ENABLED
.PHONY: web-summary-html web-site web-summarydir: web-summary-html web-summary-html: $(WEB_SUMMARYDIR)/index.html $(WEB_SUMMARYDIR)/index.html: $(WEB_SOURCES) $(WEB_SUMMARYDIR)/tsconfig.json | $(WEB_SUMMARYDIR) tsc --project $(WEB_SUMMARYDIR)/tsconfig.json cp $(filter-out %.js, $(WEB_SOURCES)) $(WEB_SUMMARYDIR) cp $(WEB_SOURCEDIR)/summary.html $(WEB_SUMMARYDIR)/index.html
endif
ifdef WEB_ENABLED
.PHONY: web-summaries-json web-site web-summarydir web-summaries-json: $(WEB_SUMMARYDIR)/summaries.json $(WEB_SUMMARYDIR)/summaries.json: $(wildcard $(WEB_SUMMARYDIR)//summary.json) $(WEB_SOURCEDIR)/json-summaries.sh : -H - follow any $(WEB_SUMMARYDIR) link : -maxdepth 2 - stop before $(WEB_SUMMARYDIR)//*/ find -H $(WEB_SUMMARYDIR) \ -maxdepth 2 \ ( -type f -name summary.json -print ) \ | $(WEB_SOURCEDIR)/json-summaries.sh $(WEB_REPODIR) - > $@.tmp mv $@.tmp $@
endif
ifdef WEB_ENABLED
.PHONY: web-status-json web-site web-summarydir web-status-json: $(WEB_SUMMARYDIR)/status.json $(WEB_SUMMARYDIR)/status.json: $(WEB_SOURCEDIR)/json-status.sh "initialized" > $@.tmp mv $@.tmp $@
endif
ifdef WEB_ENABLED
WEB_COMMITSDIR = $(WEB_SUMMARYDIR)/commits FIRST_COMMIT = $(shell $(WEB_SOURCEDIR)/earliest-commit.sh $(WEB_SUMMARYDIR) $(WEB_REPODIR))
.PHONY: web-commits-json $(WEB_SUMMARYDIR)/commits.json web-site web-summarydir web-commits-json: $(WEB_SUMMARYDIR)/commits.json $(WEB_SUMMARYDIR)/commits.json: web-commitsdir : pick up all commits unconditionally and unsorted. find $(WEB_COMMITSDIR) -name '*.json' \ | xargs --no-run-if-empty cat \ | jq -s 'unique_by(.hash)' > $@.tmp mv $@.tmp $@
.PHONY: web-commitsdir web-commitsdir: | $(WEB_COMMITSDIR) : -s suppresses the sub-make message ... is up to date : watch out for the sub-make re-valuating make variables ( cd $(WEB_REPODIR) && git rev-list $(FIRST_COMMIT)^.. ) \ | awk '{print "$(WEB_COMMITSDIR)/" $$1 ".json"}' \ | xargs --no-run-if-empty \ $(MAKE) --no-print-directory -s
$(WEB_COMMITSDIR)/%.json: $(WEB_SOURCEDIR)/json-commit.sh | $(WEB_COMMITSDIR) echo $@ $(WEB_SOURCEDIR)/json-commit.sh $* $(WEB_REPODIR) > $@.tmp mv $@.tmp $@
$(WEB_COMMITSDIR): mkdir $(WEB_COMMITSDIR)
endif
ifdef WEB_ENABLED
WEB_RESULTS_HTML = $(wildcard $(WEB_SUMMARYDIR)/-g/results.html) web-site: $(WEB_RESULTS_HTML)
$(WEB_SUMMARYDIR)/%/results.html: $(WEB_SOURCES) $(MAKE) web-resultsdir \ WEB_SUMMARYDIR=$(WEB_SUMMARYDIR) WEB_RESULTSDIR=$(dir $@)
endif
ifdef WEB_ENABLED
.PHONY: web-resultsdir web-results-html web-results-json web-resultsdir: web-results-html web-results-json web-results-html: $(WEB_RESULTSDIR)/index.html web-results-json: $(WEB_RESULTSDIR)/summary.json
$(WEB_RESULTSDIR)/index.html: $(WEB_SOURCES) $(WEB_RESULTSDIR)/tsconfig.json | $(WEB_RESULTSDIR) tsc --project $(WEB_RESULTSDIR)/tsconfig.json cp $(filter-out %.js, $(WEB_SOURCES)) $(WEB_RESULTSDIR) cp $(WEB_SOURCEDIR)/results.html $(WEB_RESULTSDIR)/index.html
$(WEB_RESULTSDIR)/summary.json: | $(WEB_RESULTSDIR) $(WEB_UTILSDIR)/kvmresults.py \ --exit-ok \ --quick \ --test-kind '' \ --test-status '' \ --publish-summary $@.tmp \ --publish-status $(WEB_SUMMARYDIR)/status.json \ --publish-results $(WEB_RESULTSDIR) \ --publish-hash $(WEB_HASH) \ testing/pluto mv $@.tmp $@
%/tsconfig.json: $(WEB_SOURCEDIR)/tsconfig.json.in mk/web-targets.mk | % sed -e 's;@@DEST_DIR@@;$(realpath $(dir $@));' \ -e 's;@@SOURCE_DIR@@;$(realpath $(WEB_SOURCEDIR));' \ $(WEB_SOURCEDIR)/tsconfig.json.in \ > $@.tmp mv $@.tmp $@
$(WEB_RESULTSDIR): | $(WEB_SUMMARYDIR) mkdir $(WEB_RESULTSDIR)
endif
ifdef WEB_ENABLED ifdef WEB_SCRATCH_REPODIR ifneq ($(abspath $(WEB_SCRATCH_REPODIR)),$(abspath .))
.PHONY: web-results-json web-site web-results-json: $(sort $(wildcard $(WEB_SUMMARYDIR)/-g/results.json))
$(WEB_SUMMARYDIR)/%/results.json: $(WEB_UTILSDIR)/kvmresults.py $(WEB_UTILSDIR)/fab/*.py $(WEB_SOURCEDIR)/json-results.sh $(WEB_SCRATCH_REPODIR) $(dir $@)
endif endif endif
define web-config
Web Configuration:
The test results can be published as a web page using either of the make variables: $(call kvm-var-value,LSW_WEBDIR) $(call kvm-var-value,WEB_SUMMARYDIR) The top-level html directory containing a summary of all test runs. The results from individual test runs are stored under this directory. $(call kvm-var-value,WEB_SUBDIR) $(call kvm-var-value,WEB_RESULTSDIR) Sub-directory to store the current test run's results. By default, the test run's results are stored as the sub-directory $$(WEB_SUBDIR) under $$(WEB_SUMMARYDIR), and $$(WEB_SUBDIR) is formatted as TAG-OFFSET-gREV-BRANCH using information from $$(WEB_REPODIR)'s current commit (see also `git describe --long`). $(call kvm-var-value,WEB_REPODIR) The git repository to use when constructing the web pages (for instance the list of commits). By default, the current directory is used.
Internal targets:
web-site: update the web site web-results-html: update the HTML files in all the test run sub-directories under $$(WEB_SUMMARYDIR) web-commits-json: update the commits.json file in $$(WEB_SUMMARYDIR) web-results-json: update the results.json in all the test run sub-directories under $$(WEB_SUMMARYDIR) very slow requires $$(WEB_SCRATCH_REPODIR) set and pointing at a dedicated git repository
Web targets:
web-summarydir: build or update the top-level summary web page under $$(WEB_SUMMARYDIR) (the test run sub-directories are not updated, see above). web-resultsdir: build or update $$(WEB_RESULTSDIR) web-page: build or update the web page in $(LSW_WEBDIR) including the results from the most recent test run
endef
.PHONY: web-config web-help web-config web-help: $(info $(web-config))