From 737ce421b317865008cbf7a4b7b1352105f285e4 Mon Sep 17 00:00:00 2001 From: Vector Date: Wed, 10 Jun 2026 21:59:39 -0500 Subject: [PATCH 1/2] fix: stop provisioning cspell config --- src/main.tf | 3 --- src/templates/all/.cspell.config.yaml | 27 --------------------------- 2 files changed, 30 deletions(-) delete mode 100644 src/templates/all/.cspell.config.yaml diff --git a/src/main.tf b/src/main.tf index 1a9bc33..87ee0eb 100644 --- a/src/main.tf +++ b/src/main.tf @@ -34,9 +34,6 @@ locals { ".commitlintrc.yml" = { content = file("templates/all/.commitlintrc.yml") }, - ".cspell.config.yaml" = { - content = file("templates/all/.cspell.config.yaml") - }, ".make/base.mk" = { content = file("templates/all/.make/base.mk") }, diff --git a/src/templates/all/.cspell.config.yaml b/src/templates/all/.cspell.config.yaml deleted file mode 100644 index ccb7347..0000000 --- a/src/templates/all/.cspell.config.yaml +++ /dev/null @@ -1,27 +0,0 @@ ---- -## DO NOT EDIT! -# This file was provisioned by Terraform -# File origin: https://github.com/Arrow-air/tf-github/tree/main/src/templates/all/.cspell.config.yaml - -$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json -version: "0.2" -language: "en" -dictionaryDefinitions: - - name: project-words - path: "./.cspell.project-words.txt" - addWords: true -dictionaries: ["project-words"] -ignoreRegExp: - - '\..*' -ignorePaths: - - "node_modules" - - "build" - - "*.css" - - "*.svg" - - "*/**Makefile" - - "target" - - "logs" - - "out" - - "coverage" - - "src/*.plan" -noConfigSearch: true From 3fc708ef549fb6d9171e5f170a0fdbf90d101074 Mon Sep 17 00:00:00 2001 From: thomasg Date: Thu, 11 Jun 2026 16:17:39 -0500 Subject: [PATCH 2/2] fix: seed cspell config on creation instead of unmanaging it Move .cspell.config.yaml to a new seeded_repository_files mechanism: the file is created with template content when a repository is first provisioned, but ignored afterwards so each repository owns its own cspell configuration. The included moved block migrates all existing instances in state, so no manual 'terraform state rm' is needed and no files are deleted from managed repositories. --- src/main.tf | 11 +++++++ src/modules/github-repository/main.tf | 37 ++++++++++++++++++++-- src/modules/github-repository/variables.tf | 9 ++++++ src/repositories_embedded.tf | 1 + src/repositories_pod.tf | 1 + src/repositories_templates.tf | 4 +++ src/repositories_terraform.tf | 6 ++++ src/templates/all/.cspell.config.yaml | 27 ++++++++++++++++ 8 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 src/templates/all/.cspell.config.yaml diff --git a/src/main.tf b/src/main.tf index 87ee0eb..29ff7cc 100644 --- a/src/main.tf +++ b/src/main.tf @@ -53,6 +53,15 @@ locals { content = file("templates/all/CONTRIBUTING.md") }, } + + # Files seeded with initial content on repository creation. + # The repository owns these files afterwards, Terraform will not update them. + seeded_files = { + ".cspell.config.yaml" = { + content = file("templates/all/.cspell.config.yaml") + }, + } + template_files = { ".github/CODEOWNERS" = "templates/all/.github/CODEOWNERS.tftpl" "Makefile" = "templates/all/Makefile" @@ -168,6 +177,8 @@ module "repository" { try(each.value.repository_files, {}) ) + seeded_repository_files = local.seeded_files + collaborators = try(each.value.collaborators, {}) default_branch_protection_settings = try(each.value.default_branch_protection_settings, {}) diff --git a/src/modules/github-repository/main.tf b/src/modules/github-repository/main.tf index d199067..f761ab5 100644 --- a/src/modules/github-repository/main.tf +++ b/src/modules/github-repository/main.tf @@ -161,7 +161,8 @@ resource "github_branch_protection" "protection" { depends_on = [ github_branch.branch, github_repository_environment.env, - github_repository_file.files + github_repository_file.files, + github_repository_file.seeded_files ] } @@ -177,7 +178,8 @@ resource "github_branch_protection" "all" { depends_on = [ github_branch.branch, github_repository_environment.env, - github_repository_file.files + github_repository_file.files, + github_repository_file.seeded_files ] } @@ -216,6 +218,37 @@ resource "github_repository_file" "files" { depends_on = [github_repository_file.init] } +######################################################## +# +# Provision seeded repository files +# These files are created with initial content, but +# owned by the repository afterwards. Terraform will +# not update them after creation. +# +######################################################## +resource "github_repository_file" "seeded_files" { + for_each = var.seeded_repository_files + + repository = github_repository.repository.name + branch = github_branch_default.default.branch + + file = each.key + content = each.value.content + overwrite_on_create = each.value.overwrite_on_create + + commit_message = "fixup! ci: terraform provisioned file changes\n\n[skip ci]" + depends_on = [github_repository_file.init] + + lifecycle { + ignore_changes = [content] + } +} + +moved { + from = github_repository_file.files[".cspell.config.yaml"] + to = github_repository_file.seeded_files[".cspell.config.yaml"] +} + ######################################################## # # Create webhooks diff --git a/src/modules/github-repository/variables.tf b/src/modules/github-repository/variables.tf index 236cce9..8148318 100644 --- a/src/modules/github-repository/variables.tf +++ b/src/modules/github-repository/variables.tf @@ -248,3 +248,12 @@ variable "repository_files" { })) default = {} } + +variable "seeded_repository_files" { + description = "List of files that should be provisioned with initial content when the repository is created, but never updated afterwards. The repository owns these files after creation." + type = map(object({ + content = string + overwrite_on_create = optional(bool, true) + })) + default = {} +} diff --git a/src/repositories_embedded.tf b/src/repositories_embedded.tf index a961fc5..806326c 100644 --- a/src/repositories_embedded.tf +++ b/src/repositories_embedded.tf @@ -86,6 +86,7 @@ module "repository_stm32" { } } ) + seeded_repository_files = local.seeded_files # Settings with defaults owner_team = each.value.owner_team diff --git a/src/repositories_pod.tf b/src/repositories_pod.tf index 2d6bf25..7ca192a 100644 --- a/src/repositories_pod.tf +++ b/src/repositories_pod.tf @@ -88,6 +88,7 @@ module "repository_pod" { } } ) + seeded_repository_files = local.seeded_files # Settings with defaults owner_team = each.value.owner_team diff --git a/src/repositories_templates.tf b/src/repositories_templates.tf index 4ad2d4c..ce393b9 100644 --- a/src/repositories_templates.tf +++ b/src/repositories_templates.tf @@ -76,6 +76,8 @@ module "repository_emb_template" { ) } } ) + seeded_repository_files = local.seeded_files + default_branch_protection_settings = each.value.default_branch_protection_settings } @@ -108,5 +110,7 @@ module "repository_pod_template" { ) } } ) + seeded_repository_files = local.seeded_files + default_branch_protection_settings = each.value.default_branch_protection_settings } diff --git a/src/repositories_terraform.tf b/src/repositories_terraform.tf index 2e5c953..c2599fb 100644 --- a/src/repositories_terraform.tf +++ b/src/repositories_terraform.tf @@ -126,6 +126,8 @@ module "repository_tf" { } ) + seeded_repository_files = local.seeded_files + collaborators = { maintainers = ["services"] } @@ -163,6 +165,8 @@ module "repository_tf_gcp" { } ) + seeded_repository_files = local.seeded_files + collaborators = { maintainers = ["services"] } @@ -199,6 +203,8 @@ module "repository_tf_mod" { } ) + seeded_repository_files = local.seeded_files + collaborators = { maintainers = ["services"] } diff --git a/src/templates/all/.cspell.config.yaml b/src/templates/all/.cspell.config.yaml new file mode 100644 index 0000000..ccb7347 --- /dev/null +++ b/src/templates/all/.cspell.config.yaml @@ -0,0 +1,27 @@ +--- +## DO NOT EDIT! +# This file was provisioned by Terraform +# File origin: https://github.com/Arrow-air/tf-github/tree/main/src/templates/all/.cspell.config.yaml + +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: "0.2" +language: "en" +dictionaryDefinitions: + - name: project-words + path: "./.cspell.project-words.txt" + addWords: true +dictionaries: ["project-words"] +ignoreRegExp: + - '\..*' +ignorePaths: + - "node_modules" + - "build" + - "*.css" + - "*.svg" + - "*/**Makefile" + - "target" + - "logs" + - "out" + - "coverage" + - "src/*.plan" +noConfigSearch: true