Updated dependencies to match latest starterkit

* removed unused dependencies
* updated dependencies to match starterkit
* updated build pipeline
This commit is contained in:
Benjamin Graham 2020-07-23 22:06:42 -04:00 committed by Justin Stephenson
parent 7eada9f82a
commit 46ad9834b3
7 changed files with 155 additions and 112 deletions

View file

@ -5,9 +5,11 @@ ifeq ($(TEST_OS),)
TEST_OS = rhel-x
endif
export TEST_OS
TARFILE=cockpit-$(PACKAGE_NAME)-$(VERSION).tar.gz
RPMFILE=$(shell rpmspec -D"VERSION $(VERSION)" -q cockpit-session-recording.spec.in).rpm
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
# one example directory from `npm install` to check if that already ran
NODE_MODULES_TEST=node_modules/po2json
# stamp file to check if/when npm install ran
NODE_MODULES_TEST=package-lock.json
# one example file in dist/ from webpack to check if that already ran
WEBPACK_TEST=dist/index.html
@ -21,7 +23,7 @@ LINGUAS=$(basename $(notdir $(wildcard po/*.po)))
po/POTFILES.js.in:
mkdir -p $(dir $@)
find src/ -name '*.js' -o -name '*.jsx' -o -name '*.es6' > $@
find src/ -name '*.js' -o -name '*.jsx' > $@
po/$(PACKAGE_NAME).js.pot: po/POTFILES.js.in
xgettext --default-domain=cockpit --output=$@ --language=C --keyword= \
@ -61,11 +63,14 @@ dist/po.%.js: po/%.po $(NODE_MODULES_TEST)
#
%.spec: %.spec.in
sed -e 's/@VERSION@/$(VERSION)/g' $< > $@
sed -e 's/%{VERSION}/$(VERSION)/g' $< > $@
$(WEBPACK_TEST): $(NODE_MODULES_TEST) $(shell find src/ -type f) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS))
NODE_ENV=$(NODE_ENV) npm run build
watch:
NODE_ENV=$(NODE_ENV) npm run watch
clean:
rm -rf dist/
[ ! -e cockpit-$(PACKAGE_NAME).spec.in ] || rm -f cockpit-$(PACKAGE_NAME).spec
@ -81,29 +86,32 @@ devel-install: $(WEBPACK_TEST)
mkdir -p ~/.local/share/cockpit
ln -s `pwd`/dist ~/.local/share/cockpit/$(PACKAGE_NAME)
dist-gzip: $(TARFILE)
# when building a distribution tarball, call webpack with a 'production' environment
# ship a stub node_modules/ so that `make` works without re-running `npm install`
dist-gzip: NODE_ENV=production
dist-gzip: all cockpit-$(PACKAGE_NAME).spec
# we don't ship node_modules for license and compactness reasons; we ship a
# pre-built dist/ (so it's not necessary) and ship packge-lock.json (so that
# node_modules/ can be reconstructed if necessary)
$(TARFILE): NODE_ENV=production
$(TARFILE): $(WEBPACK_TEST) cockpit-$(PACKAGE_NAME).spec
if type appstream-util >/dev/null 2>&1; then appstream-util validate-relax --nonet *.metainfo.xml; fi
mv node_modules node_modules.release
mkdir -p $(NODE_MODULES_TEST)
touch -r package.json $(NODE_MODULES_TEST)
touch dist/*
tar czf cockpit-$(PACKAGE_NAME)-$(VERSION).tar.gz --transform 's,^,cockpit-$(PACKAGE_NAME)/,' \
--exclude cockpit-$(PACKAGE_NAME).spec.in \
$$(git ls-files) cockpit-$(PACKAGE_NAME).spec dist/ node_modules
rm -rf node_modules
$$(git ls-files) package-lock.json cockpit-$(PACKAGE_NAME).spec dist/
mv node_modules.release node_modules
srpm: dist-gzip cockpit-$(PACKAGE_NAME).spec
appstream-util validate-relax --nonet *.metainfo.xml
srpm: $(TARFILE) cockpit-$(PACKAGE_NAME).spec
rpmbuild -bs \
--define "_sourcedir `pwd`" \
--define "_srcrpmdir `pwd`" \
cockpit-$(PACKAGE_NAME).spec
rpm: dist-gzip cockpit-$(PACKAGE_NAME).spec
appstream-util validate-relax --nonet ./*.metainfo.xml
rpm: $(RPMFILE)
$(RPMFILE): $(TARFILE) cockpit-$(PACKAGE_NAME).spec
mkdir -p "`pwd`/output"
mkdir -p "`pwd`/rpmbuild"
rpmbuild -bb \
@ -117,11 +125,13 @@ rpm: dist-gzip cockpit-$(PACKAGE_NAME).spec
find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
rm -r "`pwd`/rpmbuild"
rm -r "`pwd`/output" "`pwd`/build"
# sanity check
test -e "$(RPMFILE)"
# build a VM with locally built rpm installed
$(VM_IMAGE): rpm bots
$(VM_IMAGE): $(RPMFILE) bots
rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2
bots/image-customize -v -i cockpit-ws -i `pwd`/cockpit-$(PACKAGE_NAME)-*.noarch.rpm -s $(CURDIR)/test/vm.install $(TEST_OS)
bots/image-customize -v -i cockpit-ws -i `pwd`/$(RPMFILE) -s $(CURDIR)/test/vm.install $(TEST_OS)
bots/image-customize -v -r "usermod -u 981 tlog || true" $(TEST_OS)
bots/image-customize -v -u ./test/files/1.journal:/var/log/journal/1.journal $(TEST_OS)
@ -130,11 +140,13 @@ vm: $(VM_IMAGE)
echo $(VM_IMAGE)
# run the browser integration tests; skip check for SELinux denials
# this will run all tests/check-* and format them as TAP
check: $(NODE_MODULES_TEST) $(VM_IMAGE) test/common
TEST_AUDIT_NO_SELINUX=1 test/check-application -s
TEST_AUDIT_NO_SELINUX=1 test/common/run-tests
# checkout Cockpit's bots for standard test VM images and API to launch them
# must be from master, as only that has current and existing images; but testvm.py API is stable
# support CI testing against a bots change
bots:
sudo rm -rf bots
git clone --quiet --reference-if-able $${XDG_CACHE_HOME:-$$HOME/.cache}/cockpit-project/bots https://github.com/cockpit-project/bots.git
@ -142,13 +154,17 @@ bots:
@echo "checked out bots/ ref $$(git -C bots rev-parse HEAD)"
# checkout Cockpit's test API; this has no API stability guarantee, so check out a stable tag
# when you start a new project, use the latest relese, and update it from time to time
# when you start a new project, use the latest release, and update it from time to time
test/common:
git fetch --depth=1 https://github.com/cockpit-project/cockpit.git 219
git fetch --depth=1 https://github.com/cockpit-project/cockpit.git 220
git checkout --force FETCH_HEAD -- test/common
git reset test/common
$(NODE_MODULES_TEST): package.json
npm install
# if it exists already, npm install won't update it; force that so that we always get up-to-date packages
rm -f package-lock.json
# unset NODE_ENV, skips devDependencies otherwise
env -u NODE_ENV npm install
env -u NODE_ENV npm prune
.PHONY: all bots clean install devel-install dist-gzip srpm rpm check vm update-po
.PHONY: all clean install devel-install dist-gzip srpm rpm check vm update-po