Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BBL-440 | ci pre-commit + slack notif + makefile-lib versioned #12

Merged
merged 1 commit into from
Nov 16, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
246 changes: 237 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

jobs:
#
# Test 1 & Test 2
# Automated Tests
#
test-static-code-and-linting:
machine:
Expand All @@ -26,8 +26,27 @@ jobs:
git update-index --assume-unchanged "Makefile"

- run:
name: test1-terraform-format
command: make format-check
name: test-terraform-format-and-docs
command: |
#
# Install pre-commit
pip install pre-commit
#
# Install terraform
sudo apt-get install unzip
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VER}/terraform_${TERRAFORM_VER}_linux_amd64.zip
unzip terraform_${TERRAFORM_VER}_linux_amd64.zip
sudo mv terraform /usr/local/bin/
terraform --version
#
# Install terraform-docs
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.10.1/terraform-docs-v0.10.1-$(uname | tr '[:upper:]' '[:lower:]')-amd64
chmod +x ./terraform-docs
sudo mv ./terraform-docs /usr/local/bin/terraform-docs
#
# Run tests
make pre-commit

- run:
name: Install awscli
Expand Down Expand Up @@ -55,11 +74,81 @@ jobs:
cp /home/circleci/.aws/config /home/circleci/.aws/bb/config

- run:
name: test2-terraform-linting
name: test-terraform-linting
command: make tflint-deep

- slack/notify:
event: fail
mentions: '@leverage-support'
custom: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Failed Pipeline! :rotating_light::fire::bash-fire::bangbang::video-games-doom-mad::stopp:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":negative_squared_cross_mark: *Project*: $CIRCLE_PROJECT_REPONAME \n :negative_squared_cross_mark: *User*: $CIRCLE_USERNAME \n :negative_squared_cross_mark: *Job*: $CIRCLE_JOB in *repo* $CIRCLE_PROJECT_REPONAME \n :negative_squared_cross_mark: *Branch:* $CIRCLE_BRANCH \n :negative_squared_cross_mark: *PR:* $CIRCLE_PULL_REQUEST \n :negative_squared_cross_mark: *Last Commit:* $CIRCLE_SHA1"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": ":arrow_forward: View Job in CircleCi",
"emoji": true
},
"value": "click_me_123",
"url": "$CIRCLE_BUILD_URL",
"action_id": "button-action"
}
}
]
}
channel: 'tools-ci'
- slack/notify:
event: pass
custom: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Successful Pipeline! :checkered_flag: :video-games-star: :video-games-mario-luigi-dance: :tada: :binbash::bb-leverage: :heart: :open-source:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":heavy_check_mark: *Project*: $CIRCLE_PROJECT_REPONAME \n :heavy_check_mark: *User*: $CIRCLE_USERNAME \n :heavy_check_mark: *Job*: $CIRCLE_JOB in *repo* $CIRCLE_PROJECT_REPONAME \n :heavy_check_mark: *Branch:* $CIRCLE_BRANCH \n :heavy_check_mark: *PR:* $CIRCLE_PULL_REQUEST \n :heavy_check_mark: *Last Commit:* $CIRCLE_SHA1"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": ":arrow_forward: View Job in CircleCi",
"emoji": true
},
"value": "click_me_123",
"url": "$CIRCLE_BUILD_URL",
"action_id": "button-action"
}
}
]
}
channel: 'tools-ci'

#
# Test 3
# Tests E2E
#
test-e2e-terratests:
machine:
Expand Down Expand Up @@ -105,13 +194,83 @@ jobs:
command: aws ec2 describe-instances --region us-east-1 --profile $AWS_PROFILE_NAME

- run:
name: test3-terratests-dep-init
name: test-terratests-dep-init
command: make terratest-dep-init

- run:
name: test3-terratests-go-test
name: test-terratests-go-test
command: make terratest-go-test

- slack/notify:
event: fail
mentions: '@leverage-support'
custom: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Failed Pipeline! :rotating_light::fire::bash-fire::bangbang::video-games-doom-mad::stopp:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":negative_squared_cross_mark: *Project*: $CIRCLE_PROJECT_REPONAME \n :negative_squared_cross_mark: *User*: $CIRCLE_USERNAME \n :negative_squared_cross_mark: *Job*: $CIRCLE_JOB in *repo* $CIRCLE_PROJECT_REPONAME \n :negative_squared_cross_mark: *Branch:* $CIRCLE_BRANCH \n :negative_squared_cross_mark: *PR:* $CIRCLE_PULL_REQUEST \n :negative_squared_cross_mark: *Last Commit:* $CIRCLE_SHA1"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": ":arrow_forward: View Job in CircleCi",
"emoji": true
},
"value": "click_me_123",
"url": "$CIRCLE_BUILD_URL",
"action_id": "button-action"
}
}
]
}
channel: 'tools-ci'
- slack/notify:
event: pass
custom: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Successful Pipeline! :checkered_flag: :video-games-star: :video-games-mario-luigi-dance: :tada: :binbash::bb-leverage: :heart: :open-source:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":heavy_check_mark: *Project*: $CIRCLE_PROJECT_REPONAME \n :heavy_check_mark: *User*: $CIRCLE_USERNAME \n :heavy_check_mark: *Job*: $CIRCLE_JOB in *repo* $CIRCLE_PROJECT_REPONAME \n :heavy_check_mark: *Branch:* $CIRCLE_BRANCH \n :heavy_check_mark: *PR:* $CIRCLE_PULL_REQUEST \n :heavy_check_mark: *Last Commit:* $CIRCLE_SHA1"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": ":arrow_forward: View Job in CircleCi",
"emoji": true
},
"value": "click_me_123",
"url": "$CIRCLE_BUILD_URL",
"action_id": "button-action"
}
}
]
}
channel: 'tools-ci'

#
# Release
#
Expand Down Expand Up @@ -154,12 +313,83 @@ jobs:
echo "==============================================================================================="
fi

- slack/notify:
event: fail
mentions: '@leverage-support'
custom: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Failed Pipeline! :rotating_light::fire::bash-fire::bangbang::video-games-doom-mad::stopp:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":negative_squared_cross_mark: *Project*: $CIRCLE_PROJECT_REPONAME \n :negative_squared_cross_mark: *User*: $CIRCLE_USERNAME \n :negative_squared_cross_mark: *Job*: $CIRCLE_JOB in *repo* $CIRCLE_PROJECT_REPONAME \n :negative_squared_cross_mark: *Branch:* $CIRCLE_BRANCH \n :negative_squared_cross_mark: *PR:* $CIRCLE_PULL_REQUEST \n :negative_squared_cross_mark: *Last Commit:* $CIRCLE_SHA1"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": ":arrow_forward: View Job in CircleCi",
"emoji": true
},
"value": "click_me_123",
"url": "$CIRCLE_BUILD_URL",
"action_id": "button-action"
}
}
]
}
channel: 'tools-ci'
- slack/notify:
event: pass
custom: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Successful Pipeline! :checkered_flag: :video-games-star: :video-games-mario-luigi-dance: :tada: :binbash::bb-leverage: :heart: :open-source:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":heavy_check_mark: *Project*: $CIRCLE_PROJECT_REPONAME \n :heavy_check_mark: *User*: $CIRCLE_USERNAME \n :heavy_check_mark: *Job*: $CIRCLE_JOB in *repo* $CIRCLE_PROJECT_REPONAME \n :heavy_check_mark: *Branch:* $CIRCLE_BRANCH \n :heavy_check_mark: *PR:* $CIRCLE_PULL_REQUEST \n :heavy_check_mark: *Last Commit:* $CIRCLE_SHA1"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": ":arrow_forward: View Job in CircleCi",
"emoji": true
},
"value": "click_me_123",
"url": "$CIRCLE_BUILD_URL",
"action_id": "button-action"
}
}
]
}
channel: 'tools-ci'

#
# CircleCI orbs are open-source, shareable packages of parameterizable reusable
# configuration elements, including jobs, commands, and executors.
#
orbs:
sumologic: circleci/sumologic@1.0.6
slack: circleci/slack@4.1.1

#
# Jobs workflow
Expand Down Expand Up @@ -188,5 +418,3 @@ workflows:
- master
- sumologic/workflow-collector:
context: binbashar-org-global-context
requires:
- release-version-with-changelog
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default_language_version:
# force all unspecified python hooks to run python3
python: python3.8
python: python3

repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SHELL := /bin/bash
MAKEFILE_PATH := ./Makefile
MAKEFILES_DIR := ./@bin/makefiles
MAKEFILES_VER := v0.1.5

help:
@echo 'Available Commands:'
Expand All @@ -13,7 +14,8 @@ help:
init-makefiles: ## initialize makefiles
rm -rf ${MAKEFILES_DIR}
mkdir -p ${MAKEFILES_DIR}
git clone https://github.com/binbashar/le-dev-makefiles.git ${MAKEFILES_DIR}
git clone https://github.com/binbashar/le-dev-makefiles.git ${MAKEFILES_DIR} -q
cd ${MAKEFILES_DIR} && git checkout ${MAKEFILES_VER} -q

-include ${MAKEFILES_DIR}/circleci/circleci.mk
-include ${MAKEFILES_DIR}/release-mgmt/release.mk
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ We have a tfstate S3 Bucket per account
| Name | Version |
|------|---------|
| terraform | >= 0.12.28 |
| aws | ~> 2.70 |
| aws | ~> 3.0 |

## Providers

| Name | Version |
|------|---------|
| aws.main\_region | ~> 2.70 |
| aws.secondary\_region | ~> 2.70 |
| aws.main\_region | ~> 3.0 |
| aws.secondary\_region | ~> 3.0 |

## Inputs

Expand All @@ -68,7 +68,6 @@ We have a tfstate S3 Bucket per account
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `""` | no |
| read\_capacity | DynamoDB read capacity units | `number` | `5` | no |
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | `string` | `"/[^a-zA-Z0-9-]/"` | no |
| region | AWS Region the S3 bucket should reside in | `string` | n/a | yes |
| restrict\_public\_buckets | Whether Amazon S3 should restrict public bucket policies for this bucket. | `bool` | `false` | no |
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `""` | no |
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
Expand Down