Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=bcgov_lear&metric=alert_status)](https://sonarcloud.io/dashboard?id=bcgov_lear)[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=bcgov_lear&metric=ncloc)](https://sonarcloud.io/dashboard?id=bcgov_lear)

# lear
Legal Entities and Asset Registry
102 changes: 102 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!make

.PHONY: show-help
.PHONY: local-project setup-local-env build-local-project run-local-project stop-local-project

# -----------------------------------------------------------------------------
# -=- Local Project Tasks
# -----------------------------------------------------------------------------

## Task Alias: Builds the whole project locally
local-project: setup-local-env build-local-project run-local-project

## Sets the configuration to a local-build
setup-local-env:
@cp ./coops-ui/public/config/local-configuration.json ./coops-ui/public/config/configuration.json
@cp -R ./legal-api/src/legal_api/models ./legal-test-fixture/legal_api
@cp -R ./legal-api/src/legal_api/exceptions ./legal-test-fixture/legal_api
@cp ./legal-api/src/legal_api/schemas.py ./legal-test-fixture/legal_api

## Builds the local project
build-local-project:
@docker-compose -f ./docker-compose.yml build

## Runs the locally built project
run-local-project:
@docker-compose -f ./docker-compose.yml up -d

## Stops the locally running project
stop-local-project:
@docker-compose -f ./docker-compose.yml down

## Shell into local container
local-workspace:
@echo "Shelling into local application..."
@docker exec -it bcros_frontend bash

## Shell into local development logs
logs:
@echo "Watching logging output for local development container..."
@docker logs -f $(shell docker inspect --format="{{.Id}}" bcros_frontend)


#################################################################################
# Self Documenting Commands #
#################################################################################

.DEFAULT_GOAL := show-help

# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
# sed script explained:
# /^##/:
# * save line in hold space
# * purge line
# * Loop:
# * append newline + line to hold space
# * go to next line
# * if line starts with doc comment, strip comment character off and loop
# * remove target prerequisites
# * append hold space (+ newline) to line
# * replace newline plus comments by `---`
# * print line
# Separate expressions are necessary because labels cannot be delimited by
# semicolon; see <http://stackoverflow.com/a/11799865/1968>
.PHONY: show-help
show-help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)"
@echo
@sed -n -e "/^## / { \
h; \
s/.*//; \
:doc" \
-e "H; \
n; \
s/^## //; \
t doc" \
-e "s/:.*//; \
G; \
s/\\n## /---/; \
s/\\n/ /g; \
p; \
}" ${MAKEFILE_LIST} \
| LC_ALL='C' sort --ignore-case \
| awk -F '---' \
-v ncol=$$(tput cols) \
-v indent=19 \
-v col_on="$$(tput setaf 6)" \
-v col_off="$$(tput sgr0)" \
'{ \
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
n = split($$2, words, " "); \
line_length = ncol - indent; \
for (i = 1; i <= n; i++) { \
line_length -= length(words[i]) + 1; \
if (line_length <= 0) { \
line_length = ncol - indent - length(words[i]) - 1; \
printf "\n%*s ", -indent, " "; \
} \
printf "%s ", words[i]; \
} \
printf "\n"; \
}' \
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')
Binary file added ppr-api/.DS_Store
Binary file not shown.
65 changes: 65 additions & 0 deletions ppr-api/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# third party Services
#SENTRY_DSN=
#CODECOV_TOKEN=
#LD_SDK_KEY=

# Registry Integration Services
PAYMENT_SVC_URL=
#AUTH_SVC_URL=
AUTH_SVC_URL=
#REPORT_SVC_URL=
REPORT_SVC_URL=

# Flask shite
FLASK_ENV=development
FLASK_APP=wsgi.py
SECRET=some md5 hash
APP_SETTINGS=dev

# SQL Alchemy
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_NAME=
DATABASE_HOST=
DATABASE_PORT=

## TEST DB
DATABASE_TEST_USERNAME=
DATABASE_TEST_PASSWORD=
DATABASE_TEST_NAME=
DATABASE_TEST_HOST=localhost
DATABASE_TEST_PORT=5432

# ## NATS - STAN
NATS_SERVERS=nats://localhost:4222
NATS_CLIENT_NAME=entity.legal_api
NATS_CLUSTER_ID=test-cluster
NATS_FILER_SUBJECT=entity.filing.filer
NATS_QUEUE=entity-filer-worker

# JWT Settings
JWT_OIDC_WELL_KNOWN_CONFIG=
JWT_OIDC_ALGORITHMS=RS256
JWT_OIDC_AUDIENCE=
JWT_OIDC_CLIENT_SECRET=
JWT_OIDC_CACHING_ENABLED=True
JWT_OIDC_JWKS_CACHE_TIMEOUT=300

# Service Accounts
# Accounts
ACCOUNT_SVC_URL=
ACCOUNT_SVC_CLIENT_ID=
ACCOUNT_SVC_CLIENT_SECRET=
ACCOUNT_SVC_TIMEOUT=20

# ## MVP Settings
GO_LIVE_DATE=2019-08-12

# ## INTEGRATION TESTS
#RUN_AFFILIATION_TESTS=True
#TEST_NATS_DOCKER=True
#RUN_COLIN_TESTS=True
#RUN_NATS_TESTS=True
#RUN_PAYMENT_TESTS=True
#RUN_AUTHORIZATION_TESTS=True
NOT_GITHUB_CI=True
13 changes: 13 additions & 0 deletions ppr-api/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright © 2018 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
7 changes: 7 additions & 0 deletions ppr-api/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include requirements.txt
include config.py
include gunicorn_config.py
include logging.conf
include LICENSE
include README.md
include config
171 changes: 171 additions & 0 deletions ppr-api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
.PHONY: license
.PHONY: setup build-req clean clean-build clean-pyc clean-test

.PHONY: docker-setup network build start qa style safety test test-travis flake8 \
isort isort-save stop docker-clean logs
.PHONY: mac-cov pylint flake8

project_name := ppr_api

SHELL:=/bin/bash
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
current_abs_dir := $(patsubst %/,%,$(dir $(mkfile_path)))

#################################################################################
# COMMANDS #
#################################################################################
clean: clean-build clean-pyc clean-test
rm -rf venv/

clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-test:
find . -name '.pytest_cache' -exec rm -fr {} +
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/

build-req: clean venv/bin/activate

setup: clean setup-venv install-dev

venv/bin/activate: requirements/prod.txt requirements/dev.txt
rm -rf venv/
test -f venv/bin/activate || python3.8 -m venv $(current_abs_dir)/venv
. venv/bin/activate ;\
pip install --upgrade pip ;\
pip install -Ur requirements/prod.txt ;\
pip freeze | sort > requirements.txt ;\
cat requirements/bcregistry-libraries.txt >> requirements.txt ;\
pip install -Ur requirements/bcregistry-libraries.txt ;\
pip install -Ur requirements/dev.txt
touch venv/bin/activate # update so it's as new as requirements/prod.txt

setup-venv: requirements.txt
rm -rf venv/
test -f venv/bin/activate || python3.8 -m venv $(current_abs_dir)/venv
. venv/bin/activate ;\
pip install --upgrade pip ;\
pip install -Ur requirements.txt

.PHONY: install-dev
install-dev: venv/bin/activate
. venv/bin/activate ; \
pip install -Ur requirements/dev.txt; \
pip install -e .

.PHONY: activate
activate: venv/bin/activate
. venv/bin/activate

.PHONY: local-test
local-test: venv/bin/activate
. venv/bin/activate ; \
pytest

.PHONY: local-coverage
local-coverage: venv/bin/activate
. venv/bin/activate ; \
coverage run -m pytest

.PHONY: coverage-report
coverage-report: local-coverage
. venv/bin/activate ; \
coverage report ; \
coverage html

## Run the coverage report and display in a browser window
mac-cov: install-dev coverage-report
open -a "Google Chrome" htmlcov/index.html

## run pylint on the package and tests
pylint:
pylint --rcfile=setup.cfg \
--load-plugins=pylint_flask \
src/$(project_name)

## run flake8 on the package and tests
flake8:
flake8 src/$(project_name) tests

## Verify source code license headers.
license:
./scripts/verify_license_headers.sh src/$(project_name) tests

.PHONY: test-ratio
test-ratio:
./scripts/test_ratio.sh


#################################################################################
# Self Documenting Commands #
#################################################################################

.DEFAULT_GOAL := show-help

# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
# sed script explained:
# /^##/:
# * save line in hold space
# * purge line
# * Loop:
# * append newline + line to hold space
# * go to next line
# * if line starts with doc comment, strip comment character off and loop
# * remove target prerequisites
# * append hold space (+ newline) to line
# * replace newline plus comments by `---`
# * print line
# Separate expressions are necessary because labels cannot be delimited by
# semicolon; see <http://stackoverflow.com/a/11799865/1968>
.PHONY: show-help
show-help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)"
@echo
@sed -n -e "/^## / { \
h; \
s/.*//; \
:doc" \
-e "H; \
n; \
s/^## //; \
t doc" \
-e "s/:.*//; \
G; \
s/\\n## /---/; \
s/\\n/ /g; \
p; \
}" ${MAKEFILE_LIST} \
| LC_ALL='C' sort --ignore-case \
| awk -F '---' \
-v ncol=$$(tput cols) \
-v indent=19 \
-v col_on="$$(tput setaf 6)" \
-v col_off="$$(tput sgr0)" \
'{ \
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
n = split($$2, words, " "); \
line_length = ncol - indent; \
for (i = 1; i <= n; i++) { \
line_length -= length(words[i]) + 1; \
if (line_length <= 0) { \
line_length = ncol - indent - length(words[i]) - 1; \
printf "\n%*s ", -indent, " "; \
} \
printf "%s ", words[i]; \
} \
printf "\n"; \
}' \
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')
Loading