Skip to content

Commit

Permalink
[ci/cd] Migrated from setup.py to setuptools/build (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaikaN57 authored Jan 5, 2023
1 parent 7c87b46 commit e33a556
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 827 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jobs:
- restore_cache:
keys:
- pip-{{ checksum "requirements.test.txt" }}-2023-01-03
- run: make lint
- run: make test
- run: make pyblack
- run: make build
workflows:
version: 2
default:
Expand Down
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[run]
omit = **/test/*

[report]
show_missing = True
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ build/
docs/.ropeproject
.DS_Store
.idea
dist/
version.rst
MANIFEST
.pytest_cache
220 changes: 0 additions & 220 deletions CHANGELOG.md

This file was deleted.

3 changes: 0 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
include README.rst
include CHANGELOG.md
include kingpin.1
include requirements*
recursive-include extras *
77 changes: 32 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,39 @@ HERE = $(shell pwd)
VENV_CMD := python3 -m venv
VENV_DIR := $(HERE)/.venv
PYTHON := $(VENV_DIR)/bin/python
PYTEST := $(VENV_DIR)/bin/pytest
PYFLAKES := $(VENV_DIR)/bin/pyflakes
PYBLACK := $(VENV_DIR)/bin/black

BUILD_DIRS = bin .build build include lib lib64 man share package *.egg
BUILD_DIRS = bin .build build include lib lib64 man share package *.egg dist *.egg-info .coverage .pytest_cache

# Are we DRY? Automatically default us to DRY.
DRY ?= true
ifeq ($(DRY),false)
PYBLACK := black
else
PYBLACK := black --diff --check
ifneq ($(DRY),false)
PYBLACK_OPTS := --diff --check
endif

.PHONY: all build clean test docs

# Only execute a subset of our integration tests by default
INTEGRATION_TESTS ?= aws,rightscale,http,rollbar,slack,spotinst

# Hack to ensure we get 100% unit test coverage
export URLLIB_DEBUG=true

.PHONY: all
all: build

.PHONY: venv
venv: $(VENV_DIR)

$(VENV_DIR): requirements.txt requirements.test.txt
$(VENV_CMD) $(VENV_DIR)
. $(VENV_DIR)/bin/activate && \
$(PYTHON) -m pip install -r requirements.test.txt --force && \
$(PYTHON) -m pip install -r requirements.txt --force && \
find $(VENV_DIR)/bin && \
touch $(VENV_DIR) || exit 1

.PHONY: build
build: $(VENV_DIR)
$(PYTHON) setup.py install

pyblack:
. $(VENV_DIR)/bin/activate && $(PYBLACK) kingpin
$(PYTHON) -m build

.PHONY: clean
clean:
find . -type f -name '*.pyc' -exec rm "{}" \;
clean: $(VENV_DIR)
find kingpin -type f -name '*.pyc' -exec rm "{}" \;
rm -f kingpin.zip
rm -rf $(BUILD_DIRS)
PATH=$(VENV_DIR)/bin:$(PATH) $(MAKE) -C docs clean

.PHONY: lint
lint: $(VENV_DIR)
$(PYBLACK) $(PYBLACK_OPTS) kingpin

.PHONY: test
test: build docs pyblack
$(PYTHON) setup.py test pyflakes
# A few simple dry-tests of yaml and json scripts to make sure that the
# full commandline actually works.
test: $(VENV_DIR)
PYTHONPATH=$(HERE) $(PYTEST) --cov=kingpin -v
PYTHONPATH=$(HERE) $(PYFLAKES) kingpin
PYTHONPATH=$(HERE) $(PYTHON) kingpin/bin/deploy.py --dry --script examples/test/sleep.json
PYTHONPATH=$(HERE) $(PYTHON) kingpin/bin/deploy.py --dry --script examples/test/sleep.yaml

.PHONY: integration
integration: build
. .venv/bin/activate
INTEGRATION_TESTS=$(INTEGRATION_TESTS) PYFLAKES_NODOCTEST=True \
$(PYTHON) setup.py integration

.PHONY: pack
pack: kingpin.zip
$(PYTHON) kingpin.zip --help 2>&1 >/dev/null && echo Success || echo Fail
Expand All @@ -78,5 +50,20 @@ kingpin.zip: $(VENV_DIR)
cd zip; zip -9mrv ../kingpin.zip .
rm -rf zip

docs:
.PHONY: docs
docs: $(VENV_DIR)
PATH=$(VENV_DIR)/bin:$(PATH) $(MAKE) -C docs html

.PHONY: venv
venv: $(VENV_DIR)

$(VENV_DIR): requirements.txt requirements.test.txt
$(VENV_CMD) $(VENV_DIR)
$(PYTHON) -m pip install -U pip setuptools wheel
$(PYTHON) -m pip install -r requirements.test.txt
$(PYTHON) -m pip install -r requirements.txt
touch $(VENV_DIR)




Loading

0 comments on commit e33a556

Please sign in to comment.