Skip to content

Commit 31dc1d6

Browse files
authored
Convert to TF 0.12. Add tests. Add Codefresh test pipeline (#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
1 parent 85b4ee0 commit 31dc1d6

22 files changed

+441
-69
lines changed

.travis.yml

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

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# terraform-github-repository-webhooks
77

8-
[![Build Status](https://travis-ci.org/cloudposse/terraform-github-repository-webhooks.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-github-repository-webhooks) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-github-repository-webhooks.svg)](https://github.com/cloudposse/terraform-github-repository-webhooks/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
8+
[![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-github-repository-webhooks?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d1bcc1a1bde727a7172235e) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-github-repository-webhooks.svg)](https://github.com/cloudposse/terraform-github-repository-webhooks/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
99

1010

1111
Terraform module to provision webhooks on a set of GitHub repositories.
@@ -52,13 +52,15 @@ Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest re
5252

5353
Create a GitHub Personal Access Token that has `admin:repo_hook` for full control of repository hooks; in otherwords, we need `write:repo_hook` to write repository hooks and `read:repo_hook` to read repository hooks.
5454

55+
For a complete example, see [examples/complete](examples/complete).
56+
5557
```hcl
5658
module "github_webhooks" {
5759
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=master"
5860
github_organization = "cloudposse"
5961
github_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
60-
github_repositories = "geodesic"
61-
webhook_url = "https://atlantis.prod.company.com/"
62+
github_repositories = ["geodesic"]
63+
webhook_url = "https://atlantis.prod.company.com"
6264
webhook_content_type = "application/json"
6365
events = ["issues"]
6466
}
@@ -83,17 +85,23 @@ Available targets:
8385

8486
| Name | Description | Type | Default | Required |
8587
|------|-------------|:----:|:-----:|:-----:|
86-
| active | Indicate of the webhook should receive events | string | `true` | no |
87-
| enabled | Whether or not to enable this module | string | `true` | no |
88-
| events | A list of events which should trigger the webhook. | list | `<list>` | no |
88+
| active | Indicate of the webhook should receive events | bool | `true` | no |
89+
| enabled | Whether or not to enable this module | bool | `true` | no |
90+
| events | A list of events which should trigger the webhook. | list(string) | `<list>` | no |
8991
| github_organization | GitHub organization to use when creating webhooks | string | - | yes |
90-
| github_repositories | List of repository names which should be associated with the webhook | list | `<list>` | no |
92+
| github_repositories | List of repository names which should be associated with the webhook | list(string) | `<list>` | no |
9193
| github_token | GitHub token used for API access. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | string | `` | no |
92-
| webhook_content_type | Webhook Content Type (E.g. json) | string | `json` | no |
93-
| webhook_insecure_ssl | Webhook Insecure SSL (E.g. trust self-signed certificates) | string | `false` | no |
94+
| webhook_content_type | Webhook Content Type (e.g. `json`) | string | `json` | no |
95+
| webhook_insecure_ssl | Webhook Insecure SSL (e.g. trust self-signed certificates) | bool | `false` | no |
9496
| webhook_secret | Webhook secret | string | `` | no |
9597
| webhook_url | Webhook URL | string | - | yes |
9698

99+
## Outputs
100+
101+
| Name | Description |
102+
|------|-------------|
103+
| webhook_url | Webhook URL |
104+
97105

98106

99107

@@ -243,11 +251,11 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
243251
|---|---|---|
244252

245253
[osterman_homepage]: https://github.com/osterman
246-
[osterman_avatar]: https://github.com/osterman.png?size=150
254+
[osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png
247255
[goruha_homepage]: https://github.com/goruha
248-
[goruha_avatar]: https://github.com/goruha.png?size=150
256+
[goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png
249257
[aknysh_homepage]: https://github.com/aknysh
250-
[aknysh_avatar]: https://github.com/aknysh.png?size=150
258+
[aknysh_avatar]: https://img.cloudposse.com/150x150/https://github.com/aknysh.png
251259

252260

253261

README.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ description: |-
2020
2121
# Badges to display
2222
badges:
23-
- name: "Build Status"
24-
image: "https://travis-ci.org/cloudposse/terraform-github-repository-webhooks.svg?branch=master"
25-
url: "https://travis-ci.org/cloudposse/terraform-github-repository-webhooks"
23+
- name: "Codefresh Build Status"
24+
image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-github-repository-webhooks?type=cf-1"
25+
url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d1bcc1a1bde727a7172235e"
2626
- name: "Latest Release"
2727
image: "https://img.shields.io/github/release/cloudposse/terraform-github-repository-webhooks.svg"
2828
url: "https://github.com/cloudposse/terraform-github-repository-webhooks/releases/latest"
@@ -34,13 +34,15 @@ badges:
3434
usage: |-
3535
Create a GitHub Personal Access Token that has `admin:repo_hook` for full control of repository hooks; in otherwords, we need `write:repo_hook` to write repository hooks and `read:repo_hook` to read repository hooks.
3636
37+
For a complete example, see [examples/complete](examples/complete).
38+
3739
```hcl
3840
module "github_webhooks" {
3941
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=master"
4042
github_organization = "cloudposse"
4143
github_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
42-
github_repositories = "geodesic"
43-
webhook_url = "https://atlantis.prod.company.com/"
44+
github_repositories = ["geodesic"]
45+
webhook_url = "https://atlantis.prod.company.com"
4446
webhook_content_type = "application/json"
4547
events = ["issues"]
4648
}

codefresh/test.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
version: '1.0'
2+
3+
stages:
4+
- Prepare
5+
- Test
6+
7+
steps:
8+
wait:
9+
title: Wait
10+
stage: Prepare
11+
image: codefresh/cli:latest
12+
commands:
13+
- codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
14+
retry:
15+
maxAttempts: 10
16+
delay: 20
17+
exponentialFactor: 1.1
18+
19+
main_clone:
20+
title: "Clone repository"
21+
type: git-clone
22+
stage: Prepare
23+
description: "Initialize"
24+
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
25+
git: CF-default
26+
revision: ${{CF_REVISION}}
27+
28+
clean_init:
29+
title: Prepare build-harness and test-harness
30+
image: ${{TEST_IMAGE}}
31+
stage: Prepare
32+
commands:
33+
- cf_export PATH="/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
34+
- make init
35+
- git -C build-harness checkout master
36+
- make -C test/ clean init TEST_HARNESS_BRANCH=master
37+
- make -C test/src clean init
38+
- find . -type d -name '.terraform' | xargs rm -rf
39+
- find . -type f -name 'terraform.tfstate*' -exec rm -f {} \;
40+
41+
test:
42+
type: "parallel"
43+
title: "Run tests"
44+
description: "Run all tests in parallel"
45+
stage: Test
46+
steps:
47+
test_readme_lint:
48+
title: "Test README.md updated"
49+
stage: "Test"
50+
image: ${{TEST_IMAGE}}
51+
description: Test "readme/lint"
52+
commands:
53+
- make readme/lint
54+
55+
test_module:
56+
title: Test module with bats
57+
image: ${{TEST_IMAGE}}
58+
stage: Test
59+
commands:
60+
- make -C test/ module
61+
62+
test_examples_complete:
63+
title: Test "examples/complete" with bats
64+
image: ${{TEST_IMAGE}}
65+
stage: Test
66+
commands:
67+
- make -C test/ examples/complete
68+
69+
# test_examples_complete_terratest:
70+
# title: Test "examples/complete" with terratest
71+
# image: ${{TEST_IMAGE}}
72+
# stage: Test
73+
# commands:
74+
# - make -C test/src

docs/terraform.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
| Name | Description | Type | Default | Required |
44
|------|-------------|:----:|:-----:|:-----:|
5-
| active | Indicate of the webhook should receive events | string | `true` | no |
6-
| enabled | Whether or not to enable this module | string | `true` | no |
7-
| events | A list of events which should trigger the webhook. | list | `<list>` | no |
5+
| active | Indicate of the webhook should receive events | bool | `true` | no |
6+
| enabled | Whether or not to enable this module | bool | `true` | no |
7+
| events | A list of events which should trigger the webhook. | list(string) | `<list>` | no |
88
| github_organization | GitHub organization to use when creating webhooks | string | - | yes |
9-
| github_repositories | List of repository names which should be associated with the webhook | list | `<list>` | no |
9+
| github_repositories | List of repository names which should be associated with the webhook | list(string) | `<list>` | no |
1010
| github_token | GitHub token used for API access. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable | string | `` | no |
11-
| webhook_content_type | Webhook Content Type (E.g. json) | string | `json` | no |
12-
| webhook_insecure_ssl | Webhook Insecure SSL (E.g. trust self-signed certificates) | string | `false` | no |
11+
| webhook_content_type | Webhook Content Type (e.g. `json`) | string | `json` | no |
12+
| webhook_insecure_ssl | Webhook Insecure SSL (e.g. trust self-signed certificates) | bool | `false` | no |
1313
| webhook_secret | Webhook secret | string | `` | no |
1414
| webhook_url | Webhook URL | string | - | yes |
1515

16+
## Outputs
17+
18+
| Name | Description |
19+
|------|-------------|
20+
| webhook_url | Webhook URL |
21+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
region = "us-west-1"
2+
3+
github_organization = "cloudposse"
4+
5+
github_repositories = ["terraform-github-repository-webhooks"]
6+
7+
webhook_url = "https://archive.sweetops.com"
8+
9+
events = ["issue_comment", "pull_request", "pull_request_review", "pull_request_review_comment"]

examples/complete/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
provider "aws" {
2+
region = var.region
3+
}
4+
5+
module "webhooks" {
6+
source = "../../"
7+
active = false
8+
github_token = var.github_token
9+
github_organization = var.github_organization
10+
github_repositories = var.github_repositories
11+
webhook_url = var.webhook_url
12+
events = var.events
13+
}

examples/complete/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "webhook_url" {
2+
description = "Webhook URL"
3+
value = module.webhooks.webhook_url
4+
}

examples/complete/variables.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
variable "region" {
2+
type = string
3+
description = "AWS region"
4+
}
5+
6+
variable "github_token" {
7+
type = string
8+
default = ""
9+
description = "GitHub token used for API access. If not provided, can be sourced from the `GITHUB_TOKEN` environment variable"
10+
}
11+
12+
variable "github_organization" {
13+
type = string
14+
description = "GitHub organization to use when creating webhooks"
15+
}
16+
17+
variable "github_repositories" {
18+
type = list(string)
19+
description = "List of repository names which should be associated with the webhook"
20+
default = []
21+
}
22+
23+
variable "webhook_url" {
24+
type = string
25+
description = "Webhook URL"
26+
}
27+
28+
variable "events" {
29+
# Full list of events available here: https://developer.github.com/v3/activity/events/types/
30+
type = list(string)
31+
description = "A list of events which should trigger the webhook."
32+
}

examples/simple/main.tf

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

0 commit comments

Comments
 (0)