Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Clean up dev environment, remove PyInvoke (#189)
Browse files Browse the repository at this point in the history
* Clean up dev environment, remove PyInvoke
  • Loading branch information
kmcquade committed Apr 28, 2021
1 parent a34473e commit 5c2c35e
Show file tree
Hide file tree
Showing 27 changed files with 4,616 additions and 3,924 deletions.
15 changes: 12 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE
Expand Up @@ -9,8 +9,17 @@ multiple changes are involved, a bulleted list is often useful.)

## Completion checklist


- [ ] Additions and changes have unit tests
- [ ] Python Unit tests, Pylint, security testing, and Integration tests are passing.
- [ ] Javascript tests are passing (`npm test`)
- [ ] If the UI contents or JavaScript files have been modified, generate a new example report (`npm build` and `python3 ./utils/generate_example_report.py`)
- [ ] The pull request has been appropriately labeled using the provided PR labels
- [ ] GitHub actions automation is passing (`make test`, `make lint`, `make security-test`, `make test-js`)
- [ ] If the UI contents or JavaScript files have been modified, generate a new example report:

```bash
# Generate the updated Javascript bundle
make build-js

# Generate the example report
make generate-report
```

25 changes: 14 additions & 11 deletions .github/workflows/publish.yml
Expand Up @@ -20,18 +20,21 @@ jobs:

- name: Install dependencies
run: |
sleep 4m
pip install -r requirements.txt
pip install -r requirements-dev.txt
make setup-dev
- name: Install the package to make sure nothing is randomly broken
run: |
make install
- name: Pylint
run: |
make lint
- name: Run pytest (unit tests) and bandit (security test)
run: |
make security-test
make test
- run: invoke build.install-package
- run: invoke test.lint
- run: invoke test.security
- run: invoke unit.pytest
- run: invoke integration.version
- run: invoke integration.expand-policy
- run: invoke integration.scan
- run: invoke build.uninstall-package
publish-package:
needs: test
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/test.yml
Expand Up @@ -17,14 +17,17 @@ jobs:

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-dev.txt
- run: invoke build.install-package
- run: invoke test.lint
- run: invoke test.security
- run: invoke unit.pytest
- run: invoke integration.version
- run: invoke integration.expand-policy
- run: invoke integration.scan
- run: invoke build.uninstall-package
make setup-dev
- name: Install the package to make sure nothing is randomly broken
run: |
make install
- name: Pylint
run: |
make lint
- name: Run pytest (unit tests) and bandit (security test)
run: |
make security-test
make test
File renamed without changes.
14 changes: 1 addition & 13 deletions .gitignore
Expand Up @@ -10,6 +10,7 @@ private/default-iam-results.json
default-results-summary.csv
iam-new-principal-policy-mapping-example.json
iam-findings-example.json
iam-results-example.json
private/*
current.json
TODO.md
Expand Down Expand Up @@ -121,19 +122,6 @@ Network Trash Folder
Temporary Items
.apdisk

########## Terraform ##########
# Local .terraform directories
**/.terraform/*
*.plan

# .tfstate files
*.tfstate
*.tfstate.*

# .tfvars files
*.tfvars
!terraform.tfvars

########## Python ##########
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
49 changes: 28 additions & 21 deletions Makefile
Expand Up @@ -3,44 +3,41 @@ SHELL:=/bin/bash
PROJECT := cloudsplaining
PROJECT_UNDERSCORE := cloudsplaining

.PHONY: virtualenv
virtualenv:
python3 -m venv ./venv && source venv/bin/activate

.PHONY: setup-env
setup-env: virtualenv
python3 -m pip install -r requirements.txt

.PHONY: setup-dev
setup-dev: setup-env
python3 -m pip install -r requirements-dev.txt

.PHONY: build-docs
# Create the documentation files and open them locally
build-docs: clean virtualenv
mkdocs build

.PHONY: serve-docs
build-docs: clean virtualenv
# Serve the docs locally as you edit them
serve-docs: clean virtualenv
mkdocs serve --dev-addr "127.0.0.1:8001"

.PHONY: build
# Build the cloudsplaining package from the current directory contents for use with PyPi
build: setup-env clean
python3 -m pip install --upgrade setuptools wheel
python3 -m setup -q sdist bdist_wheel

.PHONY: install
# Install the package locally
install: build
python3 -m pip install -q ./dist/${PROJECT}*.tar.gz
${PROJECT} --help

.PHONY: uninstall
# Uninstall the package
uninstall:
python3 -m pip uninstall ${PROJECT} -y
python3 -m pip uninstall -r requirements.txt -y
python3 -m pip uninstall -r requirements-dev.txt -y
python3 -m pip freeze | xargs python3 -m pip uninstall -y

.PHONY: clean
# Clean the directory of extra python files
clean:
rm -rf dist/
rm -rf build/
Expand All @@ -51,49 +48,59 @@ clean:
find . -name '*.pyc' -exec rm --force {} +
find . -name '*.pyo' -exec rm --force {} +

.PHONY: test
# Run unit tests
test: setup-dev
python3 -m coverage run -m pytest -v

.PHONY: security-test
# Run python security tests
security-test: setup-dev
bandit -r ./${PROJECT_UNDERSCORE}/

.PHONY: fmt
# Auto format your python files
fmt: setup-dev
black ${PROJECT_UNDERSCORE}/

.PHONY: lint
# Run Pylint to lint your code
lint: setup-dev
pylint ${PROJECT_UNDERSCORE}/

.PHONY: publish
# Publish to PyPi
publish: build
python3 -m pip install --upgrade twine
python3 -m twine upload dist/*
python3 -m pip install ${PROJECT}

.PHONY: count-loc
# count lines of code
count-loc:
echo "If you don't have tokei installed, you can install it with 'brew install tokei'"
echo "Website: https://github.com/XAMPPRocky/tokei#installation'"
tokei ./* --exclude --exclude '**/*.html' --exclude '**/*.json' --exclude "docs/*" --exclude "examples/*" --exclude "test/*"

.PHONY: generate-report
# Generate the example report
generate-report:
python3 ./utils/generate_example_iam_data.py
python3 ./utils/generate_example_report.py

.PHONY: install-js
# Install javascript packages
install-js:
npm install

.PHONY: build-js
build-js: install-js setup-env
# Install javascript packages, but only the ones needed for the final report (not dev ones)
install-js-production:
rm -rf node_modules/
npm install --production

# Generate the updated Javascript bundle
build-js: setup-env install-js-production
python3 ./utils/generate_example_iam_data.py
npm build
npm run build

# Run Javascript unit tests
.PHONY: test-js
test-js: install-js
npm test

# Serve the example Javascript report locally for development
.PHONY: serve-js
serve-js: install-js-production
npm run serve

0 comments on commit 5c2c35e

Please sign in to comment.