Skip to content

Commit

Permalink
Merge pull request #28 from binbashar/feature/BBL-440-makefile-lib
Browse files Browse the repository at this point in the history
BBL-440 | ci pre-commit integrated + circleci slack notif + versioned
  • Loading branch information
exequielrafaela committed Nov 16, 2020
2 parents b9cc8c6 + fcc1635 commit 714e230
Show file tree
Hide file tree
Showing 17 changed files with 341 additions and 113 deletions.
277 changes: 255 additions & 22 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 All @@ -50,16 +69,86 @@ jobs:
aws configure set role_arn arn:aws:iam::$AWS_ACCOUNT_ID_DEV:role/DeployMaster --profile $AWS_PROFILE_NAME
aws configure set source_profile default --profile $AWS_PROFILE_NAME
# moving AWS credentials to specific project folder
# moving credentials to specific project folder
cp /home/circleci/.aws/credentials /home/circleci/.aws/bb/credentials
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 All @@ -73,6 +162,12 @@ jobs:
name: Context Info Cmds
command: pwd && ls -ltra && git branch

- run:
name: Initialize Repo Makefiles
command: |
make init-makefiles
git update-index --assume-unchanged "Makefile"
- run:
name: Install awscli
command: sudo -H pip install awscli
Expand All @@ -99,33 +194,91 @@ jobs:
command: aws ec2 describe-instances --region us-east-1 --profile $AWS_PROFILE_NAME

- run:
name: Initialize Repo Makefiles
command: |
cd modules/waf-global && make init-makefiles
git update-index --assume-unchanged "Makefile"
- run:
name: test3-terratests-dep-init
name: test-terratests-dep-init-waf-global-mod
command: cd modules/waf-global && make terratest-dep-init

- run:
name: test3-terratests-go-test
name: test-terratests-go-test-waf-global-mod
command: cd modules/waf-global && make terratest-go-test

- run:
name: Initialize Repo Makefiles
command: |
cd modules/waf-regional && make init-makefiles
git update-index --assume-unchanged "Makefile"
- run:
name: test4-terratests-dep-init
name: test-terratests-dep-init-waf-regional-mod
command: cd modules/waf-regional && make terratest-dep-init

- run:
name: test4-terratests-go-test
name: test-terratests-go-test-waf-regional-mod
command: cd modules/waf-regional && 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 @@ -168,6 +321,84 @@ 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 All @@ -193,3 +424,5 @@ workflows:
branches:
only: # only branches matching the below regex filters will run
- master
- sumologic/workflow-collector:
context: binbashar-org-global-context
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assignees: ''

## Describe the Feature

A clear and concise description of what the bug is.
A clear and concise description of what the bug is.

## Expected Behavior

Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Use bullet points to be concise and to the point.

## why
* Provide the justifications for the changes (e.g. business case).
* Provide the justifications for the changes (e.g. business case).
* Describe why these changes were made (e.g. why do these commits fix the problem?)
* Use bullet points to be concise and to the point.

## references
* Link to any supporting github issues or helpful documentation to add some context (e.g. stackoverflow).
* Link to any supporting github issues or helpful documentation to add some context (e.g. stackoverflow).
* Use `closes #123`, if this PR closes a GitHub issue `#123`

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
!*.circleci
!*.dockeringnore
!*.hosts
!/.gitignore
!.hosts.example
!*.gitignore
!/.chglog
!/.gitallowed
!/.github
!*.gitkeep
!*.editorconfig
!*.pre-commit-config.yaml

# SSH keys #
############
id_rsa
id_dsa
keys/

# OS generated files #
######################
Expand Down

0 comments on commit 714e230

Please sign in to comment.