2017-02-15 16:39:19 +00:00
|
|
|
SHELL := /bin/bash
|
|
|
|
|
2018-05-04 18:03:18 +00:00
|
|
|
export PATH := ./venv/bin:$(PATH)
|
|
|
|
|
2017-02-15 16:39:19 +00:00
|
|
|
SHA := $(shell git rev-parse --short HEAD )
|
|
|
|
REPO := quay.io/quay/quay
|
|
|
|
TAG := $(REPO):$(SHA)
|
|
|
|
|
2017-04-06 12:41:25 +00:00
|
|
|
MODIFIED_FILES_COUNT = $(shell git diff --name-only origin/master | grep -E .+\.py$ | wc -l)
|
2017-04-11 08:30:25 +00:00
|
|
|
GIT_MERGE_BASED = $(shell git merge-base origin/master HEAD)
|
|
|
|
MODIFIED_FILES = $(shell git diff --name-only $(GIT_MERGE_BASED) | grep -E .+\.py$ | paste -sd ' ')
|
2017-04-06 12:41:25 +00:00
|
|
|
|
|
|
|
show-modified:
|
|
|
|
echo $(MODIFIED_FILES)
|
|
|
|
|
2018-05-04 18:03:18 +00:00
|
|
|
.PHONY: all unit-test registry-test registry-test-old test pkgs build run clean
|
2017-02-15 16:39:19 +00:00
|
|
|
|
|
|
|
all: clean pkgs test build
|
|
|
|
|
|
|
|
pkgs: requirements.txt requirements-dev.txt requirements-tests.txt
|
|
|
|
pip install -r $<
|
|
|
|
|
|
|
|
requirements.txt: requirements-nover.txt
|
|
|
|
# Create a new virtualenv and activate it
|
|
|
|
pyenv virtualenv 2.7.12 quay-deps
|
|
|
|
pyenv activate quay-deps
|
|
|
|
|
|
|
|
# Install unversioned dependencies with your changes
|
|
|
|
pip install -r requirements-nover.txt
|
|
|
|
|
|
|
|
# Run the unit test suite
|
|
|
|
$(MAKE) unit
|
|
|
|
|
|
|
|
# Freeze the versions of all of the dependencies
|
|
|
|
pip freeze > requirements.txt
|
|
|
|
|
|
|
|
# Delete the virtualenv
|
|
|
|
pyenv uninstall quay-deps
|
|
|
|
|
|
|
|
QUAY_CONFIG ?= ../quay-config
|
|
|
|
conf/stack/license: $(QUAY_CONFIG)/local/license
|
|
|
|
mkdir -p conf/stack
|
|
|
|
ln -s $(QUAY_CONFIG)/local/license conf/stack/license
|
|
|
|
|
2017-06-20 09:30:27 +00:00
|
|
|
unit-test:
|
2018-06-21 16:07:00 +00:00
|
|
|
TEST=true PYTHONPATH="." py.test \
|
2017-06-20 09:30:27 +00:00
|
|
|
--cov="." --cov-report=html --cov-report=term-missing \
|
|
|
|
--timeout=3600 --verbose -x \
|
|
|
|
./
|
|
|
|
|
|
|
|
registry-test:
|
2018-06-21 16:07:00 +00:00
|
|
|
TEST=true PYTHONPATH="." py.test \
|
2017-06-20 09:30:27 +00:00
|
|
|
--cov="." --cov-report=html --cov-report=term-missing \
|
|
|
|
--timeout=3600 --verbose --show-count -x \
|
2018-05-01 10:52:35 +00:00
|
|
|
test/registry/registry_tests.py
|
2017-06-20 09:30:27 +00:00
|
|
|
|
2018-05-04 18:03:18 +00:00
|
|
|
registry-test-old:
|
2018-06-21 16:07:00 +00:00
|
|
|
TEST=true PYTHONPATH="." py.test \
|
2018-05-04 18:03:18 +00:00
|
|
|
--cov="." --cov-report=html --cov-report=term-missing \
|
|
|
|
--timeout=3600 --verbose --show-count -x \
|
|
|
|
./test/registry_tests.py
|
|
|
|
|
2018-08-23 19:41:00 +00:00
|
|
|
certs-test:
|
|
|
|
./test/test_certs_install.sh
|
|
|
|
|
2018-05-04 18:03:18 +00:00
|
|
|
full-db-test: ensure-test-db
|
|
|
|
TEST=true PYTHONPATH=. alembic upgrade head
|
|
|
|
TEST=true PYTHONPATH=. SKIP_DB_SCHEMA=true py.test --timeout=7200 \
|
|
|
|
--verbose --show-count -x --ignore=endpoints/appr/test/ \
|
|
|
|
./
|
|
|
|
|
2017-06-20 09:30:27 +00:00
|
|
|
test: unit-test registry-test
|
2017-02-15 16:39:19 +00:00
|
|
|
|
2018-05-04 18:03:18 +00:00
|
|
|
ensure-test-db:
|
|
|
|
@if [ -z $(TEST_DATABASE_URI) ]; then \
|
|
|
|
echo "TEST_DATABASE_URI is undefined"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2017-02-15 16:39:19 +00:00
|
|
|
|
2017-07-11 18:41:03 +00:00
|
|
|
PG_PASSWORD := quay
|
|
|
|
PG_USER := quay
|
|
|
|
PG_HOST := postgresql://$(PG_USER):$(PG_PASSWORD)@localhost/quay
|
|
|
|
|
|
|
|
test_postgres : TEST_ENV := SKIP_DB_SCHEMA=true TEST=true \
|
|
|
|
TEST_DATABASE_URI=$(PG_HOST) PYTHONPATH=.
|
|
|
|
|
|
|
|
test_postgres:
|
|
|
|
docker rm -f postgres-testrunner-postgres || true
|
|
|
|
docker run --name postgres-testrunner-postgres \
|
|
|
|
-e POSTGRES_PASSWORD=$(PG_PASSWORD) -e POSTGRES_USER=${PG_USER} \
|
|
|
|
-p 5432:5432 -d postgres:9.2
|
|
|
|
until pg_isready -d $(PG_HOST); do sleep 1; echo "Waiting for postgres"; done
|
|
|
|
$(TEST_ENV) alembic upgrade head
|
|
|
|
$(TEST_ENV) py.test --timeout=7200 --verbose --show-count ./ --color=no \
|
|
|
|
--ignore=endpoints/appr/test/ -x
|
|
|
|
docker rm -f postgres-testrunner-postgres || true
|
2017-02-15 16:39:19 +00:00
|
|
|
|
|
|
|
WEBPACK := node_modules/.bin/webpack
|
|
|
|
$(WEBPACK): package.json
|
|
|
|
npm install webpack
|
|
|
|
npm install
|
|
|
|
|
|
|
|
BUNDLE := static/js/build/bundle.js
|
|
|
|
$(BUNDLE): $(WEBPACK) tsconfig.json webpack.config.js typings.json
|
|
|
|
$(WEBPACK)
|
|
|
|
|
|
|
|
GRUNT := grunt/node_modules/.bin/grunt
|
|
|
|
$(GRUNT): grunt/package.json
|
|
|
|
cd grunt && npm install
|
|
|
|
|
|
|
|
JS := quay-frontend.js quay-frontend.min.js template-cache.js
|
|
|
|
CSS := quay-frontend.css
|
|
|
|
DIST := $(addprefix static/dist/, $(JS) $(CSS) cachebusters.json)
|
|
|
|
$(DIST): $(GRUNT)
|
|
|
|
cd grunt && ../$(GRUNT)
|
|
|
|
|
|
|
|
build: $(WEBPACK) $(GRUNT)
|
|
|
|
|
|
|
|
docker-build: pkgs build
|
|
|
|
ifneq (0,$(shell git status --porcelain | awk 'BEGIN {print $N}'))
|
|
|
|
echo 'dirty build not supported - run `FORCE=true make clean` to remove'
|
|
|
|
exit 1
|
|
|
|
endif
|
|
|
|
# get named head (ex: branch, tag, etc..)
|
|
|
|
NAME = $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
# checkout commit so .git/HEAD points to full sha (used in Dockerfile)
|
|
|
|
git checkout $(SHA)
|
|
|
|
docker build -t $(TAG) .
|
|
|
|
git checkout $(NAME)
|
|
|
|
echo $(TAG)
|
|
|
|
|
|
|
|
run: license
|
|
|
|
goreman start
|
|
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
find . -name "*.pyc" -exec rm -rf {} \;
|
|
|
|
rm -rf node_modules 2> /dev/null
|
|
|
|
rm -rf grunt/node_modules 2> /dev/null
|
|
|
|
rm -rf dest 2> /dev/null
|
|
|
|
rm -rf dist 2> /dev/null
|
|
|
|
rm -rf .cache 2> /dev/null
|
|
|
|
rm -rf static/js/build
|
|
|
|
rm -rf static/build
|
|
|
|
rm -rf static/dist
|
|
|
|
rm -rf build
|
|
|
|
rm -rf conf/stack
|
|
|
|
rm -rf screenshots
|
2017-04-06 12:41:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
yapf-all:
|
2017-04-11 08:30:25 +00:00
|
|
|
yapf -r . -p -i
|
2017-04-06 12:41:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
yapf-diff:
|
|
|
|
if [ $(MODIFIED_FILES_COUNT) -ne 0 ]; then yapf -d -p $(MODIFIED_FILES) ; fi
|
|
|
|
|
|
|
|
|
|
|
|
yapf-test:
|
|
|
|
if [ `yapf -d -p $(MODIFIED_FILES) | wc -l` -gt 0 ] ; then false ; else true ;fi
|