Skip to content

Commit 453381d

Browse files
committed
feat: add example + test GHA
1 parent d3a9594 commit 453381d

File tree

10 files changed

+112
-96
lines changed

10 files changed

+112
-96
lines changed

Diff for: .github/workflows/test.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: OpenTofu Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- feature/int-1001/initial-version
8+
pull_request:
9+
10+
permissions:
11+
actions: read
12+
checks: write
13+
contents: read
14+
id-token: write
15+
pull-requests: read
16+
17+
jobs:
18+
tofu-test:
19+
name: OpenTofu Test
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
24+
- name: Aqua Cache
25+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
26+
if: ${{ !github.event.act }} # Don't enable the cache step if we're using act for testing
27+
with:
28+
path: ~/.local/share/aquaproj-aqua
29+
key: v1-aqua-installer-${{runner.os}}-${{runner.arch}}-${{hashFiles('aqua.yaml')}}
30+
restore-keys: |
31+
v1-aqua-installer-${{runner.os}}-${{runner.arch}}-
32+
33+
- name: Install Aqua
34+
uses: aquaproj/aqua-installer@5e54e5cee8a95ee2ce7c04cb993da6dfad13e59c # v3.2.1
35+
with:
36+
aqua_version: v2.48.1
37+
38+
- name: Aqua Install
39+
shell: bash
40+
run: aqua install --tags tofu
41+
42+
- run: tofu init
43+
- run: tofu test

Diff for: .gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
*.draft
1818
*~
1919

20-
# Build Harness https://github.com/cloudposse/build-harness
21-
**/.build-harness
22-
**/build-harness
23-
2420
# Log files
2521
*.log
2622

Diff for: .trunk/trunk.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
33
version: 0.1
44
cli:
5-
version: 1.22.11
5+
version: 1.22.12
66
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
77
plugins:
88
sources:
99
- id: trunk
10-
ref: v1.6.7
10+
ref: v1.6.8
1111
uri: https://github.com/trunk-io/plugins
1212
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
1313
runtimes:
@@ -20,15 +20,16 @@ lint:
2020
# Incompatible with some Terraform features: https://github.com/tenable/terrascan/issues/1331
2121
- terrascan
2222
enabled:
23+
2324
2425
25-
26+
2627
- git-diff-check
2728
2829
2930
3031
31-
32+
3233
3334
ignore:
3435
- linters: [tofu]

Diff for: README.md

+1-40
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This Terraform module manages GitHub teams and their memberships within an organ
2424
2. Organization admin access.
2525
3. GitHub provider configuration with appropriate permissions.
2626

27-
### Basic Example
27+
### Example
2828

2929
```hcl
3030
module "github_teams" {
@@ -60,45 +60,6 @@ module "github_teams" {
6060
}
6161
```
6262

63-
### Advanced Example with All Features
64-
65-
```hcl
66-
module "github_teams" {
67-
source = "masterpointio/teams/github"
68-
version = "X.X.X"
69-
70-
github_organization = "example-org"
71-
72-
teams = {
73-
"platform-engineers" = {
74-
name = "Platform Engineers"
75-
description = "Team responsible for platform infrastructure"
76-
privacy = "closed"
77-
members = [
78-
{
79-
username = "lead-engineer"
80-
role = "maintainer"
81-
}
82-
]
83-
review_request_delegation = {
84-
algorithm = "ROUND_ROBIN"
85-
member_count = 2
86-
notify = true
87-
}
88-
}
89-
}
90-
91-
repository_collaborators = {
92-
"example-org/repo1" = [
93-
{
94-
username = "external-contributor"
95-
permission = "maintain"
96-
}
97-
]
98-
}
99-
}
100-
```
101-
10263
### Input Variables
10364

10465
| Name | Description | Type | Required |

Diff for: aqua.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# - all
99
registries:
1010
- type: standard
11-
ref: v4.210.0 # renovate: depName=aquaproj/aqua-registry
11+
ref: v4.346.0 # renovate: depName=aquaproj/aqua-registry
1212
packages:
13-
- name: terraform-docs/terraform-docs@v0.19.0
14-
- name: hashicorp/terraform@v1.9.3
15-
- name: opentofu/opentofu@v1.8.0
13+
- name: terraform-docs/terraform-docs@v0.20.0
14+
- name: hashicorp/terraform@v1.11.4
15+
- name: opentofu/opentofu@v1.9.0

Diff for: examples/complete/main.tf

+42-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
1-
# complete.tf
1+
module "github_teams" {
2+
source = "masterpointio/teams/github"
3+
version = "0.1.0"
4+
5+
github_organization = "example-org"
6+
7+
teams = {
8+
"platform-engineers" = {
9+
name = "Platform Engineers"
10+
description = "Team responsible for platform infrastructure"
11+
privacy = "closed"
12+
members = [
13+
{
14+
username = "lead-engineer"
15+
role = "maintainer"
16+
},
17+
{
18+
username = "senior-engineer"
19+
role = "member"
20+
},
21+
{
22+
username = "junior-engineer"
23+
role = "member"
24+
}
25+
]
26+
review_request_delegation = {
27+
algorithm = "ROUND_ROBIN"
28+
member_count = 2
29+
notify = true
30+
}
31+
}
32+
}
33+
34+
repository_collaborators = {
35+
"example-org/repo1" = [
36+
{
37+
username = "external-contributor"
38+
permission = "maintain"
39+
}
40+
]
41+
}
42+
}

Diff for: examples/complete/outputs.tf

-1
This file was deleted.

Diff for: examples/complete/variables.tf

-1
This file was deleted.

Diff for: examples/complete/versions.tf

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = "~> 1.7"
3+
4+
required_providers {
5+
random = {
6+
source = "integrations/github"
7+
version = "~> 6.0"
8+
}
9+
}
10+
}

Diff for: tests/main.tftest.hcl

+7-41
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Note: This test file uses OpenTofu-specific test syntax.
2+
# It is not compatible with Terraform due to differences in the testing framework.
3+
# Key differences:
4+
# - OpenTofu does not support source in mock_provider
5+
# - OpenTofu only allows overriding computed fields
6+
# - OpenTofu has different mock data handling
7+
18
mock_provider "github" {
29
alias = "mock"
310
}
@@ -134,44 +141,3 @@ run "validate_repository_collaborators" {
134141
error_message = "Phoebe should have maintain permission on repo2"
135142
}
136143
}
137-
138-
run "validate_outputs" {
139-
command = plan
140-
141-
providers = {
142-
github = github.mock
143-
}
144-
145-
# Test team outputs
146-
assert {
147-
condition = output.teams["developers"].name == "Developers"
148-
error_message = "Team output should contain correct name"
149-
}
150-
151-
assert {
152-
condition = output.teams["platform-engineers"].privacy == "closed"
153-
error_message = "Team output should contain correct privacy setting"
154-
}
155-
156-
# Test team membership outputs
157-
assert {
158-
condition = output.team_memberships["developers:rachel"].role == "maintainer"
159-
error_message = "Team membership output should contain correct role"
160-
}
161-
162-
assert {
163-
condition = output.team_memberships["developers:ross"].role == "member"
164-
error_message = "Team membership output should contain correct role"
165-
}
166-
167-
# Test repository collaborator outputs
168-
assert {
169-
condition = output.repository_collaborators["example-org/repo1:monica"].permission == "admin"
170-
error_message = "Repository collaborator output should contain correct permission"
171-
}
172-
173-
assert {
174-
condition = output.repository_collaborators["example-org/repo2:phoebe"].permission == "maintain"
175-
error_message = "Repository collaborator output should contain correct permission"
176-
}
177-
}

0 commit comments

Comments
 (0)