Skip to content

Find good practices and effective tooling for doing "as code"

Notifications You must be signed in to change notification settings

priorax/DoBetterAsCode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DoBetterAsCode

CircleCI

A self-documenting repository/website demonstrating tools and practices for developing higher-quality "as code" with a fast feedback cycle.

See it live at DoBetterAsCode.com.

Set up

Ensure you have Docker installed and running. You will also need a Java installation to use the batect task runner.

To configure the pre-commit hooks, install the therapist python module and run therapist install in the cloned repository.

Folder structure

The "infra" folder is divided into "modules" of Terraform code, and the "project" which ties the modules together to create our static site hosted on AWS S3 with CloudFront.

The "app" folder contains a Hugo site which is compiled to HTML/CSS and pushed to S3.

The ".batect" folder contains Docker container defintions used for running tasks.

The ".circleci" folder contains our pipeline as code.

Test

Validation

The following local validation tasks may be run from batect:

terraform-tflint - runs tflint to ensure our Terraform modules have valid syntax and match the AWS validation rules provided by AWS SDK

pipeline-validate - runs circleci-cli to make sure our CircleCI pipeline as code is valid

yaml-lint - runs yamllint to ensure all our yaml files are well formed

shell-lint - runs shellcheck to check the syntax of our bash scripts and warn of possible bugs

Unit

terraform-local-apply - runs a terraform apply against an AWS mock powered by localstack
localstack limitations mean we are only able to test our S3 module at this point in time

Integration

Tests for our infrastructure modules are located in infra/integration-test. These tests use kitchen-terraform and awspec to create resources in AWS and then verify that the resources exist and meet our requirements.

The terraform-integration-test task runs the full suite of tests.
You can specify an individual test to run by providing the name to batect (e.g. ./batect terraform-integration-test -- certificate)

Hooks

The pre-commit hooks powered by Therapist will run all relevant validation tasks based on the files you are changing/committing.

About

Find good practices and effective tooling for doing "as code"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 64.2%
  • HCL 12.6%
  • HTML 11.8%
  • Shell 5.3%
  • Ruby 3.5%
  • Dockerfile 1.1%
  • Other 1.5%