84 lines
2.8 KiB
Makefile
84 lines
2.8 KiB
Makefile
# We want to be able to test in two **modes**:
|
|
# A. bots are used from official packages as defined in */Dockerfile.package
|
|
# B. bots are just picked up from binaries that are placed in corresponding directory. (Use 'make copy_binaries' to copy files from parent directory)
|
|
|
|
# The topology is defined in podman-compose file and can be spawned in two ways:
|
|
# 1. Privileged container (needs no additional dependancies)
|
|
# 2. podman-compose on a local machine (needs dependencies as defined in the Dockerfile)
|
|
|
|
|
|
# Typical workflow:
|
|
# A1:
|
|
# 1. clone this repo
|
|
# 2. run 'make test_package' (or 'make test' should detect this mode)
|
|
# B1:
|
|
# 1. clone workflow-pr/autogits repo with this repo as submodule
|
|
# 2. build binaries in workflow-pr/autogits
|
|
# 3. cd to the submodule
|
|
# 4. run 'make test_local' (or 'make test' should detect this mode)
|
|
# A2.
|
|
# 1. clone this repo
|
|
# 2. 'make build' - prepared images (recommended, otherwise there might be surprises if image fails to build during `make up`)
|
|
# 3. 'make up' - spawns podman-compose
|
|
# 4. 'pytest -v tests/*' - run tests
|
|
# 5. 'make down' - once the containers are not needed
|
|
# B2:
|
|
# 1. clone workflow-pr/autogits with the submodule
|
|
# 2. build go binaries
|
|
# 3. cd to the submodule
|
|
# 4. Run steps 2-5 from A2
|
|
|
|
|
|
AUTO_DETECT_MODE := $(shell if test -e ../workflow-pr/workflow-pr; then echo .local; else echo .package; fi)
|
|
|
|
# try to detect mode B1, otherwise mode A1
|
|
test: GIWTF_IMAGE_SUFFIX=$(AUTO_DETECT_MODE)
|
|
test: copy_binaries_if_needed build_container test_container
|
|
|
|
# mode A1
|
|
test_package: GIWTF_IMAGE_SUFFIX=.package
|
|
test_package: build_container test_container
|
|
|
|
# mode B1
|
|
test_local: GIWTF_IMAGE_SUFFIX=.local
|
|
test_local: build_container test_container
|
|
|
|
MODULES := gitea-events-rabbitmq-publisher obs-staging-bot workflow-pr
|
|
|
|
copy_binaries:
|
|
for f in $(MODULES); do cp ../$$f/$$f $$f/; done
|
|
|
|
copy_binaries_if_needed:
|
|
test .package == ""$(GIWTF_IMAGE_SUFFIX) || for f in $(MODULES); do cp ../$$f/$$f $$f/; done
|
|
|
|
# Prepare topology 1
|
|
build_container:
|
|
podman build . -t autogits_integration
|
|
|
|
# Run tests in topology 1
|
|
test_container:
|
|
podman run --rm --privileged -t -e GIWTF_IMAGE_SUFFIX=$(GIWTF_IMAGE_SUFFIX) autogits_integration /usr/bin/bash -c "make build && make up && sleep 15 && pytest -v tests/*"
|
|
|
|
|
|
# parse all service images from podman-compose and build them (topology 2)
|
|
build:
|
|
podman pull docker.io/library/rabbitmq:3.13.7-management
|
|
for i in $$(grep -A 1000 services: podman-compose.yml | grep -oE '^ [^: ]+'); do podman-compose build $$i || exit 1; done
|
|
|
|
# this will spawn prebuilt containers (topology 2)
|
|
up:
|
|
podman-compose up -d
|
|
|
|
# tear down (topology 2)
|
|
down:
|
|
podman-compose down
|
|
|
|
# mode A
|
|
up-bots-package:
|
|
GIWTF_IMAGE_SUFFIX=.package podman-compose up -d
|
|
|
|
# mode B
|
|
up-bots-local:
|
|
GIWTF_IMAGE_SUFFIX=.local podman-compose up -d
|
|
|