Skip to content

Commit

Permalink
chore: Separate Test Fixtures from Examples (#918)
Browse files Browse the repository at this point in the history
* move examples/tests to tests/fixtures/complete

* replace all s|examples/tests|tests/fixtures/scenarios/complete|g

* replace all s|examples/tests|tests/fixtures/scenarios/complete|g

* use common component directory for test fixtures

* debugging test example rename

* Update demo-folder paths and fix working-directory in test.yml

* removed shared components

* Remove cache.yaml from demo-stacks directory
  • Loading branch information
milldr authored Jan 6, 2025
1 parent a9b22a1 commit bc0841c
Show file tree
Hide file tree
Showing 212 changed files with 857 additions and 121 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,25 @@ jobs:
- { os: windows-latest, target: windows }
- { os: macos-latest, target: macos }
demo-folder:
- demo-atlantis
# - demo-component-manifest
- demo-component-versions
- demo-context
# - demo-custom-command
# - demo-json-validation
# - demo-opa-validation
# - demo-opentofu
# - demo-project
# - demo-stacks
# - demo-terraform
# - demo-terraform-overrides
# - demo-workflows
# - demo-yaml-anchors
# - demo-mock-architecture
# - demo-stack-templating
# - demo-multi-cloud
- demo-vendoring
- tests
- examples/demo-atlantis
# - examples/demo-component-manifest
- examples/demo-component-versions
- examples/demo-context
# - examples/demo-custom-command
# - examples/demo-json-validation
# - examples/demo-opa-validation
# - examples/demo-opentofu
# - examples/demo-project
# - examples/demo-stacks
# - examples/demo-terraform
# - examples/demo-terraform-overrides
# - examples/demo-workflows
# - examples/demo-yaml-anchors
# - examples/demo-mock-architecture
# - examples/demo-stack-templating
# - examples/demo-multi-cloud
- examples/demo-vendoring
- tests/fixtures/scenarios/complete

timeout-minutes: 20
steps:
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:
terraform_wrapper: false

- name: Run tests in ${{ matrix.demo-folder }} for ${{ matrix.flavor.target }}
working-directory: examples/${{ matrix.demo-folder }}
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'linux' || matrix.flavor.target == 'macos'
run: |
atmos test
Expand All @@ -366,7 +366,7 @@ jobs:
atmos version
- name: Run tests in ${{ matrix.demo-folder }} for ${{ matrix.flavor.target }}
working-directory: examples/${{ matrix.demo-folder }}
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'windows'
shell: pwsh
run: |
Expand Down
4 changes: 2 additions & 2 deletions pkg/atlantis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ projects:
- name: tenant1-ue2-staging-test-test-component-override-3
workspace: test-component-override-3-workspace
workflow: workflow-1
dir: examples/tests/components/terraform/test/test-component
dir: tests/fixtures/scenarios/complete/components/terraform/test/test-component
terraform_version: v1.2
delete_source_branch_on_merge: true
autoplan:
Expand All @@ -135,7 +135,7 @@ projects:
- name: tenant1-ue2-staging-infra-vpc
workspace: tenant1-ue2-staging
workflow: workflow-1
dir: examples/tests/components/terraform/infra/vpc
dir: tests/fixtures/scenarios/complete/components/terraform/infra/vpc
terraform_version: v1.2
delete_source_branch_on_merge: true
autoplan:
Expand Down
2 changes: 1 addition & 1 deletion pkg/atlantis/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/aws/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/describe/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
8 changes: 4 additions & 4 deletions pkg/describe/describe_affected_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestDescribeAffectedWithTargetRefClone(t *testing.T) {
atmosConfig, err := cfg.InitCliConfig(configAndStacksInfo, true)
assert.Nil(t, err)

// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../examples/tests",
// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../tests/fixtures/scenarios/complete",
// which will be wrong for the remote repo which is cloned into a temp dir.
// Set the correct base path for the cloned remote repo
atmosConfig.BasePath = "./examples/tests"
atmosConfig.BasePath = "./tests/fixtures/scenarios/complete"

// Git reference and commit SHA
// Refer to https://git-scm.com/book/en/v2/Git-Internals-Git-References for more details
Expand Down Expand Up @@ -53,10 +53,10 @@ func TestDescribeAffectedWithTargetRepoPath(t *testing.T) {
atmosConfig, err := cfg.InitCliConfig(configAndStacksInfo, true)
assert.Nil(t, err)

// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../examples/tests",
// We are using `atmos.yaml` from this dir. This `atmos.yaml` has set base_path: "../../tests/fixtures/scenarios/complete",
// which will be wrong for the remote repo which is cloned into a temp dir.
// Set the correct base path for the cloned remote repo
atmosConfig.BasePath = "./examples/tests"
atmosConfig.BasePath = "./tests/fixtures/scenarios/complete"

// Point to the same local repository
// This will compare this local repository with itself as the remote target, which should result in an empty `affected` list
Expand Down
2 changes: 1 addition & 1 deletion pkg/generate/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/list/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/spacelift/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
20 changes: 10 additions & 10 deletions pkg/spacelift/spacelift_stack_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ func TestSpaceliftStackProcessor(t *testing.T) {
}

func TestLegacySpaceliftStackProcessor(t *testing.T) {
stacksBasePath := "../../examples/tests/stacks"
terraformComponentsBasePath := "../../examples/tests/components/terraform"
helmfileComponentsBasePath := "../../examples/tests/components/helmfile"
stacksBasePath := "../../tests/fixtures/scenarios/complete/stacks"
terraformComponentsBasePath := "../../tests/fixtures/scenarios/complete/components/terraform"
helmfileComponentsBasePath := "../../tests/fixtures/scenarios/complete/components/helmfile"

filePaths := []string{
"../../examples/tests/stacks/orgs/cp/tenant1/dev/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant1/staging/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant1/test1/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant2/dev/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant2/prod/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant2/staging/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/dev/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/prod/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/staging/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/test1/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant2/dev/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant2/prod/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant2/staging/us-east-2.yaml",
}

processStackDeps := true
Expand Down
14 changes: 7 additions & 7 deletions pkg/stack/stack_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
)

func TestStackProcessor(t *testing.T) {
stacksBasePath := "../../examples/tests/stacks"
terraformComponentsBasePath := "../../examples/tests/components/terraform"
helmfileComponentsBasePath := "../../examples/tests/components/helmfile"
stacksBasePath := "../../tests/fixtures/scenarios/complete/stacks"
terraformComponentsBasePath := "../../tests/fixtures/scenarios/complete/components/terraform"
helmfileComponentsBasePath := "../../tests/fixtures/scenarios/complete/components/helmfile"

filePaths := []string{
"../../examples/tests/stacks/orgs/cp/tenant1/dev/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant1/prod/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant1/staging/us-east-2.yaml",
"../../examples/tests/stacks/orgs/cp/tenant1/test1/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/dev/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/prod/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/staging/us-east-2.yaml",
"../../tests/fixtures/scenarios/complete/stacks/orgs/cp/tenant1/test1/us-east-2.yaml",
}

processStackDeps := true
Expand Down
2 changes: 1 addition & 1 deletion pkg/validate/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/vender/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
2 changes: 1 addition & 1 deletion pkg/workflow/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# are independent settings (supporting both absolute and relative paths).
# If 'base_path' is provided, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path'
# are considered paths relative to 'base_path'.
base_path: "../../examples/tests"
base_path: "../../tests/fixtures/scenarios/complete"

components:
terraform:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ schemas:
atmos:
# Can also be set using 'ATMOS_SCHEMAS_ATMOS_MANIFEST' ENV var, or '--schemas-atmos-manifest' command-line argument
# Supports both absolute and relative paths (relative to the `base_path` setting in `atmos.yaml`)
manifest: "../quick-start-advanced/stacks/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"
manifest: "../../schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"

# CLI command aliases
aliases:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# > atmos vendor pull -c infra/vpc-flow-logs-bucket
# Pulling sources for the component 'infra/vpc-flow-logs-bucket' from 'github.com/cloudposse/terraform-aws-components.git//modules/vpc-flow-logs-bucket?ref=0.194.0'
# into 'examples/tests/components/terraform/infra/vpc-flow-logs-bucket'
# into 'tests/fixtures/scenarios/complete/components/terraform/infra/vpc-flow-logs-bucket'
#
# Including the file 'README.md' since it matches the '**/*.md' pattern from 'included_paths'
# Excluding the file 'context.tf' since it matches the '**/context.tf' pattern from 'excluded_paths'
Expand All @@ -17,9 +17,9 @@
# Including the file 'versions.tf' since it matches the '**/*.tf' pattern from 'included_paths'
#
# Pulling the mixin 'https://raw.githubusercontent.com/cloudposse/terraform-null-label/0.25.0/exports/context.tf'
# for the component 'infra/vpc-flow-logs-bucket' into 'examples/tests/components/terraform/infra/vpc-flow-logs-bucket'
# for the component 'infra/vpc-flow-logs-bucket' into 'tests/fixtures/scenarios/complete/components/terraform/infra/vpc-flow-logs-bucket'
# Pulling the mixin 'https://raw.githubusercontent.com/cloudposse/terraform-aws-components/0.194.0/modules/datadog-agent/introspection.mixin.tf'
# for the component 'infra/vpc-flow-logs-bucket' into 'examples/tests/components/terraform/infra/vpc-flow-logs-bucket'
# for the component 'infra/vpc-flow-logs-bucket' into 'tests/fixtures/scenarios/complete/components/terraform/infra/vpc-flow-logs-bucket'

apiVersion: atmos/v1
kind: ComponentVendorConfig
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ components:
workspace_enabled: false
depends_on:
1:
file: "examples/tests/components/terraform/mixins/introspection.mixin.tf"
file: "tests/fixtures/scenarios/complete/components/terraform/mixins/introspection.mixin.tf"
2:
folder: "examples/tests/components/helmfile/infra/infra-server"
folder: "tests/fixtures/scenarios/complete/components/helmfile/infra/infra-server"
vars:
enabled: true
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ components:
settings:
atlantis:

# For this `tenant1-ue2-dev` stack, override the org-wide config template specified in `examples/tests/stacks/orgs/cp/_defaults.yaml`
# For this `tenant1-ue2-dev` stack, override the org-wide config template specified in `tests/fixtures/scenarios/complete/stacks/orgs/cp/_defaults.yaml`
# in the `settings.atlantis.config_template_name` section
config_template:
version: 3
Expand All @@ -50,7 +50,7 @@ settings:
allowed_regexp_prefixes:
- dev/

# For this `tenant1-ue2-dev` stack, override the org-wide project template specified in `examples/tests/stacks/orgs/cp/_defaults.yaml`
# For this `tenant1-ue2-dev` stack, override the org-wide project template specified in `tests/fixtures/scenarios/complete/stacks/orgs/cp/_defaults.yaml`
# in the `settings.atlantis.project_template_name` section
project_template:
# generate a project entry for each component in every stack
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit bc0841c

Please sign in to comment.