Skip to content

Commit 7e6acd9

Browse files
authored
Merge pull request #67 from confusdcodr/api-change
Add debug capability
2 parents 7e0ab79 + 798d217 commit 7e6acd9

12 files changed

Lines changed: 102 additions & 198 deletions

File tree

.bumpversion.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[bumpversion]
2-
current_version = 0.0.0
2+
current_version = 0.0.1
33
commit = True
44
message = Bumps version to {new_version}
55
tag = False
66
tag_name = {new_version}
7+

.dependabot/config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ update_configs:
1212
update_schedule: "daily"
1313

1414
- package_manager: "python"
15-
directory: "/"
15+
directory: "/src"
1616
update_schedule: "live"
17+
18+
- package_manager: "docker"
19+
directory: "/"
20+
update_schedule: "daily"

.gitignore

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
# Local .terraform directories
1+
# Terraform compiled files and folders
2+
*.tfstate
3+
*.tfstate.backup
24
.terraform/
5+
*.auto.tfvars
36

4-
# .tfstate files
5-
*.tfstate
6-
*.tfstate.*
7+
# ignore log files
8+
*.log
9+
10+
# tardigrade-ci
11+
.tardigrade-ci
12+
tardigrade-ci/
713

8-
# .tfvars files
9-
*.tfvars
14+
# eclint
15+
.git/

.travis.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,8 @@ stages:
1212
jobs:
1313
include:
1414
- stage: lint
15-
name: EditorConfig Syntax Verification
16-
install:
17-
- npm install -g eclint
18-
- eclint --version
19-
script: eclint check
20-
- stage: lint
21-
name: Shell Script Syntax Verification
22-
script: make sh/lint
23-
- stage: lint
24-
name: JSON Lint/Format Verification
25-
script: make json/lint
26-
- stage: lint
27-
name: Terraform Lint/Format Verification
28-
install:
29-
- make terraform/install
30-
- make terraform-docs/install
31-
script:
32-
- make terraform/lint
33-
- make docs/lint
34-
- stage: lint
35-
language: python
36-
python: 3.6
37-
name: Python Lint/Format Verification
38-
install: pip install -r requirements/dev.txt
39-
script: make python/lint
15+
name: Project Syntax Verification
16+
script: make && make docker/run target=lint
4017
- stage: deploy
4118
if: branch = master AND type = push AND repo = plus3it/terraform-aws-codecommit-pr-reminders
4219
before_script:

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM plus3it/tardigrade-ci:0.0.12
2+
3+
WORKDIR /ci-harness
4+
ENTRYPOINT ["make"]
5+

Makefile

Lines changed: 2 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,3 @@
1-
ARCH ?= amd64
2-
OS ?= $(shell uname -s | tr '[:upper:]' '[:lower:'])
3-
CURL ?= curl --fail -sSL
4-
XARGS ?= xargs -I {}
5-
BIN_DIR ?= ${HOME}/bin
6-
TMP ?= /tmp
7-
FIND_EXCLUDES ?= -not \( -name .terraform -prune \) -not \( -name .terragrunt-cache -prune \)
1+
SHELL := /bin/bash
82

9-
PATH := $(BIN_DIR):${PATH}
10-
11-
MAKEFLAGS += --no-print-directory
12-
SHELL := bash
13-
.SHELLFLAGS := -eu -o pipefail -c
14-
15-
.PHONY: guard/% %/install %/lint
16-
17-
GITHUB_ACCESS_TOKEN ?= 4224d33b8569bec8473980bb1bdb982639426a92
18-
# Macro to return the download url for a github release
19-
# For latest release, use version=latest
20-
# To pin a release, use version=tags/<tag>
21-
# $(call parse_github_download_url,owner,repo,version,asset select query)
22-
parse_github_download_url = $(CURL) https://api.github.com/repos/$(1)/$(2)/releases/$(3)?access_token=$(GITHUB_ACCESS_TOKEN) | jq --raw-output '.assets[] | select($(4)) | .browser_download_url'
23-
24-
# Macro to download a github binary release
25-
# $(call download_github_release,file,owner,repo,version,asset select query)
26-
download_github_release = $(CURL) -o $(1) $(shell $(call parse_github_download_url,$(2),$(3),$(4),$(5)))
27-
28-
# Macro to download a hashicorp archive release
29-
# $(call download_hashicorp_release,file,app,version)
30-
download_hashicorp_release = $(CURL) -o $(1) https://releases.hashicorp.com/$(2)/$(3)/$(2)_$(3)_$(OS)_$(ARCH).zip
31-
32-
guard/env/%:
33-
@ _="$(or $($*),$(error Make/environment variable '$*' not present))"
34-
35-
guard/program/%:
36-
@ which $* > /dev/null || $(MAKE) $*/install
37-
38-
$(BIN_DIR):
39-
@ echo "[make]: Creating directory '$@'..."
40-
mkdir -p $@
41-
42-
install/gh-release/%: guard/env/FILENAME guard/env/OWNER guard/env/REPO guard/env/VERSION guard/env/QUERY
43-
install/gh-release/%:
44-
@ echo "[$@]: Installing $*..."
45-
$(call download_github_release,$(FILENAME),$(OWNER),$(REPO),$(VERSION),$(QUERY))
46-
chmod +x $(FILENAME)
47-
$* --version
48-
@ echo "[$@]: Completed successfully!"
49-
50-
install/pip/%: PYTHON ?= python
51-
install/pip/%: | guard/env/PYPI_PKG_NAME
52-
@ echo "[$@]: Installing $*..."
53-
$(PYTHON) -m pip install --user $(PYPI_PKG_NAME)
54-
ln -sf ~/.local/bin/$* $(BIN_DIR)/$*
55-
$* --version
56-
@ echo "[$@]: Completed successfully!"
57-
58-
black/install:
59-
@ $(MAKE) install/pip/$(@D) PYPI_PKG_NAME=$(@D)
60-
61-
zip/install:
62-
@ echo "[$@]: Installing $(@D)..."
63-
apt-get install zip -y
64-
@ echo "[$@]: Completed successfully!"
65-
66-
terraform/install: TERRAFORM_VERSION_LATEST := $(CURL) https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | sed 's/^v//'
67-
terraform/install: TERRAFORM_VERSION ?= $(shell $(TERRAFORM_VERSION_LATEST))
68-
terraform/install: | $(BIN_DIR) guard/program/jq
69-
@ echo "[$@]: Installing $(@D)..."
70-
$(call download_hashicorp_release,$(@D).zip,$(@D),$(TERRAFORM_VERSION))
71-
unzip $(@D).zip && rm -f $(@D).zip && chmod +x $(@D)
72-
mv $(@D) "$(BIN_DIR)"
73-
$(@D) --version
74-
@ echo "[$@]: Completed successfully!"
75-
76-
#terraform-docs/install: TFDOCS_VERSION ?= latest
77-
terraform-docs/install: TFDOCS_VERSION ?= tags/v0.7.0
78-
terraform-docs/install: | $(BIN_DIR) guard/program/jq
79-
@ $(MAKE) install/gh-release/$(@D) FILENAME="$(BIN_DIR)/$(@D)" OWNER=segmentio REPO=$(@D) VERSION=$(TFDOCS_VERSION) QUERY='.name | endswith("$(OS)-$(ARCH)")'
80-
81-
jq/install: JQ_VERSION ?= latest
82-
jq/install: | $(BIN_DIR)
83-
@ $(MAKE) install/gh-release/$(@D) FILENAME="$(BIN_DIR)/$(@D)" OWNER=stedolan REPO=$(@D) VERSION=$(JQ_VERSION) QUERY='.name | endswith("$(OS)64")'
84-
85-
shellcheck/install: SHELLCHECK_VERSION ?= latest
86-
shellcheck/install: SHELLCHECK_URL ?= https://storage.googleapis.com/shellcheck/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz
87-
shellcheck/install: $(BIN_DIR) guard/program/xz
88-
$(CURL) $(SHELLCHECK_URL) | tar -xJv
89-
mv $(@D)-*/$(@D) $(BIN_DIR)
90-
rm -rf $(@D)-*
91-
$(@D) --version
92-
93-
terraform/lint: | guard/program/terraform
94-
@ echo "[$@]: Linting Terraform files..."
95-
terraform fmt -check=true -diff=true
96-
@ echo "[$@]: Terraform files PASSED lint test!"
97-
98-
terraform/format: | guard/program/terraform
99-
@ echo "[$@]: Formatting Terraform files..."
100-
terraform fmt -recursive
101-
@ echo "[$@]: Successfully formatted terraform files!"
102-
103-
sh/%: FIND_SH := find . $(FIND_EXCLUDES) -name '*.sh' -type f -print0
104-
sh/lint: | guard/program/shellcheck
105-
@ echo "[$@]: Linting shell scripts..."
106-
$(FIND_SH) | $(XARGS) shellcheck {}
107-
@ echo "[$@]: Shell scripts PASSED lint test!"
108-
109-
json/%: FIND_JSON := find . $(FIND_EXCLUDES) -name '*.json' -type f
110-
json/lint: | guard/program/jq
111-
@ echo "[$@]: Linting JSON files..."
112-
$(FIND_JSON) | $(XARGS) bash -c 'cmp {} <(jq --indent 4 -S . {}) || (echo "[{}]: Failed JSON Lint Test"; exit 1)'
113-
@ echo "[$@]: JSON files PASSED lint test!"
114-
115-
json/format: | guard/program/jq
116-
@ echo "[$@]: Formatting JSON files..."
117-
$(FIND_JSON) | $(XARGS) bash -c 'echo "$$(jq --indent 4 -S . "{}")" > "{}"'
118-
@ echo "[$@]: Successfully formatted JSON files!"
119-
120-
tfdocs-awk/install: $(BIN_DIR)
121-
tfdocs-awk/install: ARCHIVE := https://github.com/plus3it/tfdocs-awk/archive/0.0.2.tar.gz
122-
tfdocs-awk/install:
123-
$(CURL) $(ARCHIVE) | tar -C $(BIN_DIR) --strip-components=1 --wildcards '*.sh' --wildcards '*.awk' -xzvf -
124-
125-
docs/generate: | tfdocs-awk/install guard/program/terraform-docs
126-
@ echo "[$@]: Creating documentation files.."
127-
@ bash -eu -o pipefail autodocs.sh -g
128-
@ echo "[$@]: Documentation generated!"
129-
130-
docs/lint: | tfdocs-awk/install guard/program/terraform-docs
131-
@ echo "[$@] Linting documentation files.."
132-
@ bash -eu -o pipefail autodocs.sh -l
133-
@ echo "[$@] documentation linting complete!"
134-
135-
python/lint: | guard/program/black
136-
@ echo "[$@]: Linting Python files..."
137-
black --check .
138-
@ echo "[$@]: Python files PASSED lint test!"
139-
140-
python/format: | guard/program/black
141-
@ echo "[$@]: Formatting Python files..."
142-
black .
143-
@ echo "[$@]: Successfully formatted Python files!"
144-
145-
terratest/install: | guard/program/go
146-
cd tests && go mod init terraform-aws-codecommit-pr-reminders/tests
147-
cd tests && go build ./...
148-
cd tests && go mod tidy
149-
150-
terratest/test: | guard/program/go
151-
cd tests && go test -count=1 -timeout 20m
152-
153-
test: terratest/test
3+
-include $(shell curl -sSL -o .tardigrade-ci "https://raw.githubusercontent.com/plus3it/tardigrade-ci/master/bootstrap/Makefile.bootstrap"; echo .tardigrade-ci)

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22

33
Terraform module to deploy a lambda function that will enumerate CodeCommit repositories and publish the Open PRs to slack
44

5+
<!-- BEGIN TFDOCS -->
6+
## Providers
7+
8+
| Name | Version |
9+
|------|---------|
10+
| aws | n/a |
11+
512
## Inputs
613

714
| Name | Description | Type | Default | Required |
8-
|------|-------------|:----:|:-----:|:-----:|
9-
| hook\_url | Slack webhook URL; see <https://api.slack.com/incoming-webhooks> | string | n/a | yes |
10-
| name | \(Optional\) Name to associate with the lambda function | string | `"codecommit-pr-reminders"` | no |
11-
| schedule | \(Optional\) Schedule expression for CloudWatch event; see <https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html> | string | `"cron(0 7 ? * MON-FRI *)"` | no |
12-
| tags | Tags to add to the supported resources | map | `<map>` | no |
15+
|------|-------------|------|---------|:-----:|
16+
| hook\_url | Slack webhook URL; see <https://api.slack.com/incoming-webhooks> | `string` | n/a | yes |
17+
| dry\_run | toggle to control dryrun output of the lambda function | `bool` | `false` | no |
18+
| log\_level | The log level of the lambda function | `string` | `"INFO"` | no |
19+
| name | (Optional) Name to associate with the lambda function | `string` | `"codecommit-pr-reminders"` | no |
20+
| schedule | (Optional) Schedule expression for CloudWatch event; see <https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html> | `string` | `"cron(0 7 ? * MON-FRI *)"` | no |
21+
| tags | Tags to add to the supported resources | `map` | `{}` | no |
22+
23+
## Outputs
24+
25+
No output.
1326

27+
<!-- END TFDOCS -->

_docs/MAIN.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module "lambda" {
2020
environment = {
2121
variables = {
2222
SLACK_WEBHOOK = var.hook_url
23+
LOG_LEVEL = var.log_level
24+
DRYRUN = var.dry_run
2325
}
2426
}
2527
}

requirements/dev.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)