Best_practice
A plugin/cli tool/container/library for automating best practice in a code repository. For example:
- Build a drone yaml file based on the technologies in the repo
- Give general programming language specific recommendations
- Recommend other Harness products based on your project
It has the following scanners:
- Docker scanner, for best practice
- Drone scanner, analyses your build file to give you recommendations
- Golang scanner, for best practice
- Java scanner, for best practice
- Javascript scanner, for best practice
- Ruby scanner, for best practice
And the following output formats:
- Best practice for existing Drone builds
- Drone build file creation (creates a drone file, or a .drone.yml.new file if you have an existing drone file)
- Harness product recommendations
Example output:
Usage
There are 4 ways to use this project:
Download the Binaries from the release section. Then, you can use it as a cli tool.
./best-practice
Execute the newly created drone build file
# install drone-cli if necessary
brew install drone-cli
# execute the drone build
drone exec .drone.yml
Using the container locally
You can use a container locally. This will run it against your current working directory.
docker pull tphoney/best_practice
docker run -it --rm -v $(pwd):/plugin -e PLUGIN_WORKING_DIRECTORY=/plugin tphoney/best_practice
Execute the newly created drone build file
# install drone-cli if necessary
brew install drone-cli
# execute the drone build
drone exec .drone.yml
Using it in your drone build
Below is an example .drone.yml that uses this plugin.
kind: pipeline
name: default
steps:
- name: run tphoney/best_practice plugin
image: tphoney/best_practice
pull: if-not-exists
Using it as a library
Select your scanners and pass it through to the output formatters:
# set the working directory to the root of your project
workingDirectory, err := os.Getwd()
# set your scanners, this uses all of the scanners by default
requestedScanners = scanner.ListScannersNames()
# set your output formatters, this uses all of the output formatters by default
requestesOutputFormatters = output.ListOutputFormattersNames()
# run the scanners
scanResults, scanErr := scanner.RunScanners(ctx, requestedScanners, requestesOutputFormatters)
# run the output formatters
outputErr := outputter.RunOutput(ctx, outputters, scanResults)
Developer notes
Building
Build the plugin binaries:
scripts/build.sh
Build the plugin image:
docker build -t tphoney/best_practice -f docker/Dockerfile .