<commit_before># generate version number from the latest git tag; if the topmost commit is
# tagged (at release time), just use that; if there are commits after that,
# append a ".x" suffix to indicate that's a development snapshot
# if there is no tag (yet), use 0 as version
RELEASEVER=$(shell (git describe --exclude '*jenkins*' || echo 0) | sed 's/-[0-9]\+-g.*/.x/')

all: npm-install
	NODE_ENV=$(NODE_ENV) npm run build

npm-install:
	npm install

install: all
	mkdir -p /usr/share/cockpit/welder
	cp -r public/* /usr/share/cockpit/welder

dist-gzip: NODE_ENV=production
dist-gzip: all
	mkdir -p _install/usr/share/cockpit
	cp -r public/ _install/usr/share/cockpit/welder
	# remove evil file name that breaks rpmbuild (https://github.com/patternfly/patternfly/issues/917)
	find _install -name 'Logo_Horizontal_Reversed.svg alias' -delete
	cp welder-web.spec _install/
	tar -C _install/ -czf welder-web-$(RELEASEVER).tar.gz .
	rm -rf _install

srpm: dist-gzip
	rpmbuild -bs \
	  --define "_sourcedir `pwd`" \
	  --define "_srcrpmdir `pwd`" \
	  --define "releasever $(RELEASEVER)" \
	  welder-web.spec

rpm: dist-gzip
	mkdir -p "`pwd`/output"
	mkdir -p "`pwd`/rpmbuild"
	rpmbuild -bb \
	  --define "_sourcedir `pwd`" \
	  --define "_specdir `pwd`" \
	  --define "_builddir `pwd`/rpmbuild" \
	  --define "_srcrpmdir `pwd`" \
	  --define "_rpmdir `pwd`/output" \
	  --define "_buildrootdir `pwd`/build" \
	  --define "releasever $(RELEASEVER)" \
	  welder-web.spec
	find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
	rm -r "`pwd`/rpmbuild"

eslint:
	npm run eslint

stylelint:
	npm run stylelint

unit-test:
	npm run test:cov

metadata.db:
	sudo docker build -f Dockerfile.metadata -t welder/import-metadata .
	sudo docker run --name import-metadata welder/import-metadata:latest
	sudo docker cp import-metadata:/metadata.db .
	sudo docker rm import-metadata

shared: metadata.db
	if [ -n "$$TRAVIS" ]; then \
	    sudo docker build -f Dockerfile.nodejs --cache-from welder/web-nodejs:latest -t welder/web-nodejs:latest . ; \
	    sudo docker build -f ./test/end-to-end/Dockerfile --cache-from welder/web-e2e-tests:latest -t welder/web-e2e-tests:latest ./test/end-to-end/; \
	else \
	    sudo docker build -f Dockerfile.nodejs -t welder/web-nodejs:latest . ; \
	    sudo docker build -f ./test/end-to-end/Dockerfile -t welder/web-e2e-tests:latest ./test/end-to-end/ ; \
	fi;

	sudo mkdir failed-image
	sudo docker network inspect welder >/dev/null 2>&1 || sudo docker network create welder
	sudo docker ps --quiet --all --filter 'ancestor=welder/bdcs-api-rs' | sudo xargs --no-run-if-empty docker rm -f
	sudo docker run -d --name api --restart=always -p 4000:4000 -v bdcs-recipes-volume:/bdcs-recipes -v `pwd`:/mddb --network welder --security-opt label=disable welder/bdcs-api-rs:latest

end-to-end-test: shared
	if [ -n "$$TRAVIS" ]; then \
	    sudo docker build --cache-from welder/web:latest -t welder/web:latest . ; \
	else \
	    sudo docker build -t welder/web:latest . ; \
	fi;<commit_msg>Make tests reentrant<commit_after># generate version number from the latest git tag; if the topmost commit is
# tagged (at release time), just use that; if there are commits after that,
# append a ".x" suffix to indicate that's a development snapshot
# if there is no tag (yet), use 0 as version
RELEASEVER=$(shell (git describe --exclude '*jenkins*' || echo 0) | sed 's/-[0-9]\+-g.*/.x/')

all: npm-install
	NODE_ENV=$(NODE_ENV) npm run build

npm-install:
	npm install

install: all
	mkdir -p /usr/share/cockpit/welder
	cp -r public/* /usr/share/cockpit/welder

dist-gzip: NODE_ENV=production
dist-gzip: all
	mkdir -p _install/usr/share/cockpit
	cp -r public/ _install/usr/share/cockpit/welder
	# remove evil file name that breaks rpmbuild (https://github.com/patternfly/patternfly/issues/917)
	find _install -name 'Logo_Horizontal_Reversed.svg alias' -delete
	cp welder-web.spec _install/
	tar -C _install/ -czf welder-web-$(RELEASEVER).tar.gz .
	rm -rf _install

srpm: dist-gzip
	rpmbuild -bs \
	  --define "_sourcedir `pwd`" \
	  --define "_srcrpmdir `pwd`" \
	  --define "releasever $(RELEASEVER)" \
	  welder-web.spec

rpm: dist-gzip
	mkdir -p "`pwd`/output"
	mkdir -p "`pwd`/rpmbuild"
	rpmbuild -bb \
	  --define "_sourcedir `pwd`" \
	  --define "_specdir `pwd`" \
	  --define "_builddir `pwd`/rpmbuild" \
	  --define "_srcrpmdir `pwd`" \
	  --define "_rpmdir `pwd`/output" \
	  --define "_buildrootdir `pwd`/build" \
	  --define "releasever $(RELEASEVER)" \
	  welder-web.spec
	find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
	rm -r "`pwd`/rpmbuild"

eslint:
	npm run eslint

stylelint:
	npm run stylelint

unit-test:
	npm run test:cov

metadata.db:
	sudo docker build -f Dockerfile.metadata -t welder/import-metadata .
	sudo docker run --name import-metadata welder/import-metadata:latest
	sudo docker cp import-metadata:/metadata.db .
	sudo docker rm import-metadata

shared: metadata.db
	if [ -n "$$TRAVIS" ]; then \
	    sudo docker build -f Dockerfile.nodejs --cache-from welder/web-nodejs:latest -t welder/web-nodejs:latest . ; \
	    sudo docker build -f ./test/end-to-end/Dockerfile --cache-from welder/web-e2e-tests:latest -t welder/web-e2e-tests:latest ./test/end-to-end/; \
	else \
	    sudo docker build -f Dockerfile.nodejs -t welder/web-nodejs:latest . ; \
	    sudo docker build -f ./test/end-to-end/Dockerfile -t welder/web-e2e-tests:latest ./test/end-to-end/ ; \
	fi;

	sudo mkdir -p failed-image
	sudo docker network inspect welder >/dev/null 2>&1 || sudo docker network create welder
	sudo docker ps --quiet --all --filter 'ancestor=welder/bdcs-api-rs' | sudo xargs --no-run-if-empty docker rm -f
	sudo docker run -d --name api --restart=always -p 4000:4000 -v bdcs-recipes-volume:/bdcs-recipes -v `pwd`:/mddb --network welder --security-opt label=disable welder/bdcs-api-rs:latest

end-to-end-test: shared
	if [ -n "$$TRAVIS" ]; then \
	    sudo docker build --cache-from welder/web:latest -t welder/web:latest . ; \
	else \
	    sudo docker build -t welder/web:latest . ; \
	fi;
{'fraction_non_alphanumeric': 0.14524677045379264, 'fraction_numerical': 0.006624710168930109, 'mean_word_length': 3.144818119423473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2901084', 'n_tokens_mistral': 2417, 'n_tokens_neox': 2227, 'n_words': 620}