forked from cloudposse/terraform-github-repository-webhooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert to TF 0.12. Add tests. Add Codefresh test pipeline (cloudposs…
…e#10) * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline
- Loading branch information
Showing
22 changed files
with
441 additions
and
69 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
version: '1.0' | ||
|
||
stages: | ||
- Prepare | ||
- Test | ||
|
||
steps: | ||
wait: | ||
title: Wait | ||
stage: Prepare | ||
image: codefresh/cli:latest | ||
commands: | ||
- codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id' | ||
retry: | ||
maxAttempts: 10 | ||
delay: 20 | ||
exponentialFactor: 1.1 | ||
|
||
main_clone: | ||
title: "Clone repository" | ||
type: git-clone | ||
stage: Prepare | ||
description: "Initialize" | ||
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} | ||
git: CF-default | ||
revision: ${{CF_REVISION}} | ||
|
||
clean_init: | ||
title: Prepare build-harness and test-harness | ||
image: ${{TEST_IMAGE}} | ||
stage: Prepare | ||
commands: | ||
- cf_export PATH="/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
- make init | ||
- git -C build-harness checkout master | ||
- make -C test/ clean init TEST_HARNESS_BRANCH=master | ||
- make -C test/src clean init | ||
- find . -type d -name '.terraform' | xargs rm -rf | ||
- find . -type f -name 'terraform.tfstate*' -exec rm -f {} \; | ||
|
||
test: | ||
type: "parallel" | ||
title: "Run tests" | ||
description: "Run all tests in parallel" | ||
stage: Test | ||
steps: | ||
test_readme_lint: | ||
title: "Test README.md updated" | ||
stage: "Test" | ||
image: ${{TEST_IMAGE}} | ||
description: Test "readme/lint" | ||
commands: | ||
- make readme/lint | ||
|
||
test_module: | ||
title: Test module with bats | ||
image: ${{TEST_IMAGE}} | ||
stage: Test | ||
commands: | ||
- make -C test/ module | ||
|
||
test_examples_complete: | ||
title: Test "examples/complete" with bats | ||
image: ${{TEST_IMAGE}} | ||
stage: Test | ||
commands: | ||
- make -C test/ examples/complete | ||
|
||
# test_examples_complete_terratest: | ||
# title: Test "examples/complete" with terratest | ||
# image: ${{TEST_IMAGE}} | ||
# stage: Test | ||
# commands: | ||
# - make -C test/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
region = "us-west-1" | ||
|
||
github_organization = "cloudposse" | ||
|
||
github_repositories = ["terraform-github-repository-webhooks"] | ||
|
||
webhook_url = "https://archive.sweetops.com" | ||
|
||
events = ["issue_comment", "pull_request", "pull_request_review", "pull_request_review_comment"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
module "webhooks" { | ||
source = "../../" | ||
active = false | ||
github_token = var.github_token | ||
github_organization = var.github_organization | ||
github_repositories = var.github_repositories | ||
webhook_url = var.webhook_url | ||
events = var.events | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "webhook_url" { | ||
description = "Webhook URL" | ||
value = module.webhooks.webhook_url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
variable "region" { | ||
type = string | ||
description = "AWS region" | ||
} | ||
|
||
variable "github_token" { | ||
type = string | ||
default = "" | ||
description = "GitHub token used for API access. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable" | ||
} | ||
|
||
variable "github_organization" { | ||
type = string | ||
description = "GitHub organization to use when creating webhooks" | ||
} | ||
|
||
variable "github_repositories" { | ||
type = list(string) | ||
description = "List of repository names which should be associated with the webhook" | ||
default = [] | ||
} | ||
|
||
variable "webhook_url" { | ||
type = string | ||
description = "Webhook URL" | ||
} | ||
|
||
variable "events" { | ||
# Full list of events available here: https://developer.github.com/v3/activity/events/types/ | ||
type = list(string) | ||
description = "A list of events which should trigger the webhook." | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
provider "github" { | ||
token = "${var.github_token}" | ||
organization = "${var.github_organization}" | ||
token = var.github_token != "" ? var.github_token : null | ||
organization = var.github_organization | ||
} | ||
|
||
resource "github_repository_webhook" "default" { | ||
count = "${var.enabled == "true" && length(var.github_repositories) > 0 ? length(var.github_repositories) : 0}" | ||
count = var.enabled && length(var.github_repositories) > 0 ? length(var.github_repositories) : 0 | ||
|
||
repository = "${var.github_repositories[count.index]}" | ||
active = "${var.active}" | ||
repository = var.github_repositories[count.index] | ||
active = var.active | ||
|
||
configuration { | ||
url = "${var.webhook_url}" | ||
content_type = "${var.webhook_content_type}" | ||
secret = "${var.webhook_secret}" | ||
insecure_ssl = "${var.webhook_insecure_ssl}" | ||
url = var.webhook_url | ||
content_type = var.webhook_content_type | ||
secret = var.webhook_secret | ||
insecure_ssl = var.webhook_insecure_ssl | ||
} | ||
|
||
events = "${var.events}" | ||
events = var.events | ||
|
||
lifecycle { | ||
# This is required for idempotency | ||
ignore_changes = ["configuration.secret"] | ||
ignore_changes = ["configuration[0].secret"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
|
||
output "webhook_url" { | ||
description = "Webhook URL" | ||
value = join("", github_repository_webhook.default.*.url) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.test-harness |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
TEST_HARNESS ?= https://github.com/cloudposse/test-harness.git | ||
TEST_HARNESS_BRANCH ?= master | ||
TEST_HARNESS_PATH = $(realpath .test-harness) | ||
BATS_ARGS ?= --tap | ||
BATS_LOG ?= test.log | ||
|
||
# Define a macro to run the tests | ||
define RUN_TESTS | ||
@echo "Running tests in $(1)" | ||
@cd $(1) && bats $(BATS_ARGS) $(addsuffix .bats,$(addprefix $(TEST_HARNESS_PATH)/test/terraform/,$(TESTS))) | ||
endef | ||
|
||
default: all | ||
|
||
-include Makefile.* | ||
|
||
## Provision the test-harnesss | ||
.test-harness: | ||
[ -d $@ ] || git clone --depth=1 -b $(TEST_HARNESS_BRANCH) $(TEST_HARNESS) $@ | ||
|
||
## Initialize the tests | ||
init: .test-harness | ||
|
||
## Install all dependencies (OS specific) | ||
deps:: | ||
@exit 0 | ||
|
||
## Clean up the test harness | ||
clean: | ||
[ "$(TEST_HARNESS_PATH)" == "/" ] || rm -rf $(TEST_HARNESS_PATH) | ||
|
||
## Run all tests | ||
all: module examples/complete | ||
|
||
## Run basic sanity checks against the module itself | ||
module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions | ||
module: deps | ||
$(call RUN_TESTS, ../) | ||
|
||
## Run tests against example | ||
examples/complete: export TESTS ?= installed lint get-modules get-plugins validate | ||
examples/complete: deps | ||
$(call RUN_TESTS, ../$@) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ifneq (,$(wildcard /sbin/apk)) | ||
## Install all dependencies for alpine | ||
deps:: init | ||
@apk add --update terraform-docs@cloudposse json2hcl@cloudposse | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.gopath | ||
vendor/ |
Oops, something went wrong.