With this change the integration tests can now also be run as unit tests against the mocked server. The way it works is this: internal/client/unit_test.go sets up the mock server and is built when the `integration` build tag is *not* included. internal/client/integration_test.go sets up the connection to an existing server and is built when the `integration` build tag *is* included. The test code is built and run for both cases. Currently they all pass for the integration test run. The unit test cases need some work because the mocked server isn't a real server with real depsolving and package lists. A future commit will fix this.
108 lines
4.5 KiB
Makefile
108 lines
4.5 KiB
Makefile
COMMIT=$(shell git rev-parse HEAD)
|
|
|
|
.PHONY: build
|
|
build:
|
|
go build -o osbuild-composer ./cmd/osbuild-composer/
|
|
go build -o osbuild-worker ./cmd/osbuild-worker/
|
|
go build -o osbuild-pipeline ./cmd/osbuild-pipeline/
|
|
go build -o osbuild-upload-azure ./cmd/osbuild-upload-azure/
|
|
go build -o osbuild-upload-aws ./cmd/osbuild-upload-aws/
|
|
go test -c -tags=integration -o osbuild-tests ./cmd/osbuild-tests/main_test.go
|
|
go test -c -tags=integration -o osbuild-weldr-tests ./internal/client/
|
|
go test -c -tags=integration -o osbuild-dnf-json-tests ./cmd/osbuild-dnf-json-tests/main_test.go
|
|
go test -c -tags=integration -o osbuild-rcm-tests ./cmd/osbuild-rcm-tests/main_test.go
|
|
go test -c -tags=integration,travis -o osbuild-image-tests ./cmd/osbuild-image-tests/
|
|
|
|
.PHONY: install
|
|
install:
|
|
- mkdir -p /usr/libexec/osbuild-composer
|
|
cp osbuild-composer /usr/libexec/osbuild-composer/
|
|
cp osbuild-worker /usr/libexec/osbuild-composer/
|
|
cp dnf-json /usr/libexec/osbuild-composer/
|
|
- mkdir -p /usr/share/osbuild-composer/repositories
|
|
cp repositories/* /usr/share/osbuild-composer/repositories
|
|
- mkdir -p /etc/sysusers.d/
|
|
cp distribution/osbuild-composer.conf /etc/sysusers.d/
|
|
systemd-sysusers osbuild-composer.conf
|
|
- mkdir -p /etc/systemd/system/
|
|
cp distribution/*.service /etc/systemd/system/
|
|
cp distribution/*.socket /etc/systemd/system/
|
|
systemctl daemon-reload
|
|
|
|
.PHONY: ca
|
|
ca:
|
|
ifneq (/etc/osbuild-composer/ca-key.pem/etc/osbuild-composer/ca-crt.pem,$(wildcard /etc/osbuild-composer/ca-key.pem)$(wildcard /etc/osbuild-composer/ca-crt.pem))
|
|
@echo CA key or certificate file is missing, generating a new pair...
|
|
- mkdir -p /etc/osbuild-composer
|
|
openssl req -new -nodes -x509 -days 365 -keyout /etc/osbuild-composer/ca-key.pem -out /etc/osbuild-composer/ca-crt.pem -subj "/CN=osbuild.org"
|
|
else
|
|
@echo CA key and certificate files already exist, skipping...
|
|
endif
|
|
|
|
.PHONY: composer-key-pair
|
|
composer-key-pair: ca
|
|
openssl genrsa -out /etc/osbuild-composer/composer-key.pem 2048
|
|
openssl req -new -sha256 -key /etc/osbuild-composer/composer-key.pem -out /etc/osbuild-composer/composer-csr.pem -subj "/CN=localhost" # TODO: we need to generate certificates with another hostname
|
|
openssl x509 -req -in /etc/osbuild-composer/composer-csr.pem -CA /etc/osbuild-composer/ca-crt.pem -CAkey /etc/osbuild-composer/ca-key.pem -CAcreateserial -out /etc/osbuild-composer/composer-crt.pem
|
|
chown _osbuild-composer:_osbuild-composer /etc/osbuild-composer/composer-key.pem /etc/osbuild-composer/composer-csr.pem /etc/osbuild-composer/composer-crt.pem
|
|
|
|
.PHONY: worker-key-pair
|
|
worker-key-pair: ca
|
|
openssl genrsa -out /etc/osbuild-composer/worker-key.pem 2048
|
|
openssl req -new -sha256 -key /etc/osbuild-composer/worker-key.pem -out /etc/osbuild-composer/worker-csr.pem -subj "/CN=localhost"
|
|
openssl x509 -req -in /etc/osbuild-composer/worker-csr.pem -CA /etc/osbuild-composer/ca-crt.pem -CAkey /etc/osbuild-composer/ca-key.pem -CAcreateserial -out /etc/osbuild-composer/worker-crt.pem
|
|
|
|
|
|
#
|
|
# Building packages
|
|
#
|
|
# The following rules build osbuild-composer packages from the current HEAD
|
|
# commit, based on the spec file in this directory. The resulting packages
|
|
# have the commit hash in their version, so that they don't get overwritten
|
|
# when calling `make rpm` again after switching to another branch.
|
|
#
|
|
# All resulting files (spec files, source rpms, rpms) are written into
|
|
# ./rpmbuild, using rpmbuild's usual directory structure.
|
|
#
|
|
|
|
OLD_RPM_SPECFILE=rpmbuild/SPECS/golang-github-osbuild-composer-$(COMMIT).spec
|
|
RPM_SPECFILE=rpmbuild/SPECS/osbuild-composer-$(COMMIT).spec
|
|
RPM_TARBALL=rpmbuild/SOURCES/osbuild-composer-$(COMMIT).tar.gz
|
|
|
|
$(OLD_RPM_SPECFILE):
|
|
mkdir -p $(CURDIR)/rpmbuild/SPECS
|
|
(echo "%global commit $(COMMIT)"; git show HEAD:golang-github-osbuild-composer.spec) > $(OLD_RPM_SPECFILE)
|
|
|
|
$(RPM_SPECFILE):
|
|
mkdir -p $(CURDIR)/rpmbuild/SPECS
|
|
(echo "%global commit $(COMMIT)"; git show HEAD:osbuild-composer.spec) > $(RPM_SPECFILE)
|
|
|
|
$(RPM_TARBALL):
|
|
mkdir -p $(CURDIR)/rpmbuild/SOURCES
|
|
git archive --prefix=osbuild-composer-$(COMMIT)/ --format=tar.gz HEAD > $(RPM_TARBALL)
|
|
|
|
.PHONY: srpm
|
|
srpm: $(RPM_SPECFILE) $(RPM_TARBALL)
|
|
rpmbuild -bs \
|
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
|
--with tests \
|
|
$(RPM_SPECFILE)
|
|
|
|
.PHONY: rpm
|
|
rpm: $(RPM_SPECFILE) $(RPM_TARBALL)
|
|
rpmbuild -bb \
|
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
|
--with tests \
|
|
$(RPM_SPECFILE)
|
|
|
|
.PHONY: old-srpm
|
|
old-srpm: $(OLD_RPM_SPECFILE) $(RPM_TARBALL)
|
|
rpmbuild -bs \
|
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
|
$(OLD_RPM_SPECFILE)
|
|
|
|
.PHONY: old-rpm
|
|
old-rpm: $(OLD_RPM_SPECFILE) $(RPM_TARBALL)
|
|
rpmbuild -bb \
|
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
|
$(OLD_RPM_SPECFILE)
|