Skip to content

Commit 2f4a56e

Browse files
committed
test(integration): add IaC to manage integration testing repository
This commit adds OpenTofu infrastructure as code to manage the GitHub repo `revanit-io/example-osps-baseline-level-1`. Because this repository can be used for integration testing changes in the project, any changes to the repository should be visible and fail a CI run. Signed-off-by: Travis Truman <[email protected]>
1 parent 371db9c commit 2f4a56e

File tree

7 files changed

+131
-1
lines changed

7 files changed

+131
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Integration Test
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- 'iac/**'
8+
- '.github/workflows/integration-test.yml'
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
tofu-plan:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: iac
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
24+
25+
- name: Set up Tofu
26+
uses: opentofu/setup-opentofu@v1
27+
28+
- name: Initialize Tofu
29+
run: tofu init
30+
31+
- name: Run Tofu Plan
32+
id: plan
33+
run: |
34+
tofu plan -detailed-exitcode -no-color > plan.txt
35+
continue-on-error: true
36+
37+
- name: Check for changes
38+
run: |
39+
if [ "${{ steps.plan.outcome }}" != "success" ]; then
40+
echo "Tofu plan detected changes or failed."
41+
cat plan.txt
42+
exit 1
43+
fi
44+
shell: bash

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ config.yml
1010
output
1111

1212
# go test coverage output
13-
coverage.out
13+
coverage.out
14+
15+
.terraform/

iac/.terraform.lock.hcl

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iac/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Example README for OpenTofu-managed repository
2+
3+
This repository is managed by OpenTofu (Terraform alternative) via Infrastructure as Code.
4+
5+
- Repository: revanite-io/example-osps-baseline-level-1
6+
- Managed resources: repository settings, topics, README file
7+
8+
Feel free to update this file as needed.

iac/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
required_providers {
3+
github = {
4+
source = "integrations/github"
5+
version = ">= 5.0.0"
6+
}
7+
}
8+
}
9+
10+
provider "github" {
11+
owner = "revanite-io"
12+
}

iac/repo.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# OpenTofu configuration for managing the revanite-io/example-osps-baseline-level-1 repository
2+
3+
resource "github_repository" "example_osps_baseline_level_1" {
4+
name = "example-osps-baseline-level-1"
5+
description = "Example repository for integration testing of pvtr-github-repo"
6+
visibility = "public"
7+
has_issues = true
8+
has_wiki = true
9+
has_projects = true
10+
has_downloads = true
11+
vulnerability_alerts = true
12+
}
13+
14+
resource "github_repository_ruleset" "default_branch_protection" {
15+
name = "default"
16+
repository = github_repository.example_osps_baseline_level_1.name
17+
target = "branch"
18+
enforcement = "active"
19+
20+
conditions {
21+
ref_name {
22+
include = ["~DEFAULT_BRANCH"]
23+
exclude = []
24+
}
25+
}
26+
27+
rules {
28+
creation = false
29+
update = true
30+
deletion = true
31+
non_fast_forward = true
32+
pull_request {
33+
required_approving_review_count = 1
34+
}
35+
}
36+
}

iac/terraform.tfstate

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":4,"terraform_version":"1.10.6","serial":2,"lineage":"7bc637ea-e7ff-1f51-242c-395719e69890","outputs":{},"resources":[{"mode":"managed","type":"github_repository","name":"example_osps_baseline_level_1","provider":"provider[\"registry.opentofu.org/integrations/github\"]","instances":[{"schema_version":1,"attributes":{"allow_auto_merge":false,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_squash_merge":true,"allow_update_branch":false,"archive_on_destroy":null,"archived":false,"auto_init":false,"default_branch":"main","delete_branch_on_merge":false,"description":"Example repository for integration testing of pvtr-github-repo","etag":"W/\"a18fbc4b4371fb3fd92f89c85eff300333be99f12c796276ec71f4a170512568\"","full_name":"revanite-io/example-osps-baseline-level-1","git_clone_url":"git://github.com/revanite-io/example-osps-baseline-level-1.git","gitignore_template":null,"has_discussions":false,"has_downloads":true,"has_issues":true,"has_projects":true,"has_wiki":true,"homepage_url":"","html_url":"https://github.com/revanite-io/example-osps-baseline-level-1","http_clone_url":"https://github.com/revanite-io/example-osps-baseline-level-1.git","id":"example-osps-baseline-level-1","ignore_vulnerability_alerts_during_read":null,"is_template":false,"license_template":null,"merge_commit_message":"PR_TITLE","merge_commit_title":"MERGE_MESSAGE","name":"example-osps-baseline-level-1","node_id":"R_kgDOP0IKkg","pages":[],"primary_language":"Python","private":false,"repo_id":1061292690,"security_and_analysis":[{"advanced_security":[],"secret_scanning":[{"status":"disabled"}],"secret_scanning_push_protection":[{"status":"disabled"}]}],"squash_merge_commit_message":"COMMIT_MESSAGES","squash_merge_commit_title":"COMMIT_OR_PR_TITLE","ssh_clone_url":"[email protected]:revanite-io/example-osps-baseline-level-1.git","svn_url":"https://github.com/revanite-io/example-osps-baseline-level-1","template":[],"topics":[],"visibility":"public","vulnerability_alerts":true,"web_commit_signoff_required":false},"sensitive_attributes":[],"private":"eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ=="}]},{"mode":"managed","type":"github_repository_ruleset","name":"default_branch_protection","provider":"provider[\"registry.opentofu.org/integrations/github\"]","instances":[{"schema_version":1,"attributes":{"bypass_actors":[],"conditions":[{"ref_name":[{"exclude":[],"include":["~DEFAULT_BRANCH"]}]}],"enforcement":"active","etag":"W/\"4354911cc42f114f622f032d1fedae8c238317d7459bfaca137e33e449db18ab\"","id":"8281062","name":"default","node_id":"RRS_lACqUmVwb3NpdG9yec4_QgqSzgB-W-Y","repository":"example-osps-baseline-level-1","rules":[{"branch_name_pattern":[],"commit_author_email_pattern":[],"commit_message_pattern":[],"committer_email_pattern":[],"creation":false,"deletion":true,"merge_queue":[],"non_fast_forward":true,"pull_request":[{"dismiss_stale_reviews_on_push":false,"require_code_owner_review":false,"require_last_push_approval":false,"required_approving_review_count":1,"required_review_thread_resolution":false}],"required_code_scanning":[],"required_deployments":[],"required_linear_history":false,"required_signatures":false,"required_status_checks":[],"tag_name_pattern":[],"update":true,"update_allows_fetch_and_merge":false}],"ruleset_id":8281062,"target":"branch"},"sensitive_attributes":[],"private":"eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ=="}]}],"check_results":null}

0 commit comments

Comments
 (0)