From 8a1920bc97d0bd34fd94f5ea882aaf339c0b5d3e Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 01:41:12 +0100 Subject: [PATCH 01/32] Incupsulate configs --- .github/workflows/feature-branch.yml | 28 +- .github/workflows/main-branch.yaml | 16 ++ .github/workflows/release-published.yml | 12 + .github/workflows/test-matrix-2-levels.yml | 57 ++++ .github/workflows/test-matrix-3-levels.yml | 57 ++++ .github/workflows/test-positive.yml | 56 ++++ action.yml | 85 ++++-- src/filter.sh | 31 -- test/run.sh | 15 - tests/atmos-gitops.yaml | 11 + tests/components/terraform/test/atmos.yaml | 266 ++++++++++++++++++ tests/components/terraform/test/main.tf | 12 + .../stacks}/orgs/test/_defaults.yaml | 0 .../stacks}/orgs/test/core/_defaults.yaml | 0 .../stacks}/orgs/test/core/auto/test.yaml | 0 .../stacks}/orgs/test/plat/_defaults.yaml | 0 .../stacks}/orgs/test/plat/dev/test.yaml | 0 .../stacks}/orgs/test/plat/sandbox/test.yaml | 0 18 files changed, 551 insertions(+), 95 deletions(-) create mode 100644 .github/workflows/main-branch.yaml create mode 100644 .github/workflows/release-published.yml create mode 100644 .github/workflows/test-matrix-2-levels.yml create mode 100644 .github/workflows/test-matrix-3-levels.yml create mode 100644 .github/workflows/test-positive.yml delete mode 100755 src/filter.sh delete mode 100755 test/run.sh create mode 100644 tests/atmos-gitops.yaml create mode 100644 tests/components/terraform/test/atmos.yaml create mode 100644 tests/components/terraform/test/main.tf rename {stacks => tests/stacks}/orgs/test/_defaults.yaml (100%) rename {stacks => tests/stacks}/orgs/test/core/_defaults.yaml (100%) rename {stacks => tests/stacks}/orgs/test/core/auto/test.yaml (100%) rename {stacks => tests/stacks}/orgs/test/plat/_defaults.yaml (100%) rename {stacks => tests/stacks}/orgs/test/plat/dev/test.yaml (100%) rename {stacks => tests/stacks}/orgs/test/plat/sandbox/test.yaml (100%) diff --git a/.github/workflows/feature-branch.yml b/.github/workflows/feature-branch.yml index 44b1140..7ebd292 100644 --- a/.github/workflows/feature-branch.yml +++ b/.github/workflows/feature-branch.yml @@ -1,25 +1,15 @@ +name: Feature branch on: - workflow_dispatch: pull_request: branches: [ main ] types: [opened, synchronize, reopened] jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.ref }} - fetch-depth: 1 - - - uses: cloudposse/github-action-setup-atmos@v1.0.0 - with: - atmos-version: "latest" - - - uses: dcarbone/install-jq-action@v1.0.1 - with: - version: "1.6" - - - name: Run Tests - run: ./test/run.sh + perform: + uses: cloudposse/github-actions-workflows-github-action-composite/.github/workflows/feature-branch.yml@main + with: + organization: "${{ github.event.repository.owner.login }}" + repository: "${{ github.event.repository.name }}" + ref: "${{ github.event.pull_request.head.ref }}" + secrets: + github-private-actions-pat: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/main-branch.yaml b/.github/workflows/main-branch.yaml new file mode 100644 index 0000000..96e3a91 --- /dev/null +++ b/.github/workflows/main-branch.yaml @@ -0,0 +1,16 @@ +name: Main branch +on: + push: + branches: [ main ] + +permissions: + contents: write + +jobs: + perform: + uses: cloudposse/github-actions-workflows-github-action-composite/.github/workflows/main-branch.yml@main + with: + organization: "${{ github.event.repository.owner.login }}" + repository: "${{ github.event.repository.name }}" + secrets: + github-private-actions-pat: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}" diff --git a/.github/workflows/release-published.yml b/.github/workflows/release-published.yml new file mode 100644 index 0000000..7bfa5b3 --- /dev/null +++ b/.github/workflows/release-published.yml @@ -0,0 +1,12 @@ +name: release-published + +on: + release: + types: + - published + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: cloudposse/github-action-major-release-tagger@v1 \ No newline at end of file diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml new file mode 100644 index 0000000..56b838a --- /dev/null +++ b/.github/workflows/test-matrix-2-levels.yml @@ -0,0 +1,57 @@ +name: Test select components with 2 levels of nested matrices +on: +# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered +# # +# # Added pull_request to register workflow from the PR. +# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo +# pull_request: {} + workflow_dispatch: {} + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Setup + run: echo "Do setup" + + test: + runs-on: ubuntu-latest + needs: [setup] + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: add mock atmos to the path + run: echo "./tests/fixtures" >> $GITHUB_PATH + + - uses: ./ + id: current + with: + install-atmos: false + atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + nested-matrices-count: '2' + + outputs: + affected: "${{ steps.current.outputs.affected }}" + matrix: "${{ steps.current.outputs.matrix }}" + + assert: + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: nick-fields/assert-action@v1 + with: + expected: '[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]' + actual: "${{ needs.test.outputs.affected }}" + + - uses: nick-fields/assert-action@v1 + with: + expected: '{"include":[' + actual: "${{ needs.test.outputs.matrix }}" + comparison: contains + + - uses: nick-fields/assert-action@v1 + with: + expected: '{"include":[{"name":"core-audit","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"core-gbl-audit\",\"stack_slug\":\"core-gbl-audit-datadog-integration\",\"affected\":\"component\"}]}"},{"name":"core-auto","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"core-gbl-auto\",\"stack_slug\":\"core-gbl-auto-datadog-integration\",\"spacelift_stack\":\"core-gbl-auto-datadog-integration\",\"affected\":\"component\"},{\"component\":\"infrastructure-cplive-core\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/spacelift\",\"stack\":\"core-gbl-auto\",\"stack_slug\":\"core-gbl-auto-infrastructure-cplive-core\",\"spacelift_stack\":\"core-gbl-auto-infrastructure-cplive-core\",\"affected\":\"stack.vars\"},{\"component\":\"infrastructure-cplive-plat\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/spacelift\",\"stack\":\"core-gbl-auto\",\"stack_slug\":\"core-gbl-auto-infrastructure-cplive-plat\",\"spacelift_stack\":\"core-gbl-auto-infrastructure-cplive-plat\",\"affected\":\"stack.vars\"}]}"},{"name":"core-root","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"core-ue2-root\",\"stack_slug\":\"core-ue2-root-datadog-integration\",\"affected\":\"component\"}]}"},{"name":"plat-prod","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"plat-gbl-prod\",\"stack_slug\":\"plat-gbl-prod-datadog-integration\",\"spacelift_stack\":\"plat-gbl-prod-datadog-integration\",\"affected\":\"component\"}]}"}]}' + actual: "${{ needs.test.outputs.matrix }}" diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml new file mode 100644 index 0000000..bcb23dd --- /dev/null +++ b/.github/workflows/test-matrix-3-levels.yml @@ -0,0 +1,57 @@ +name: Test select components with 3 levels of nested matrices +on: +# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered +# # +# # Added pull_request to register workflow from the PR. +# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo +# pull_request: {} + workflow_dispatch: {} + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Setup + run: echo "Do setup" + + test: + runs-on: ubuntu-latest + needs: [setup] + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: add mock atmos to the path + run: echo "./tests/fixtures" >> $GITHUB_PATH + + - uses: ./ + id: current + with: + install-atmos: false + atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + nested-matrices-count: '3' + + outputs: + affected: "${{ steps.current.outputs.affected }}" + matrix: "${{ steps.current.outputs.matrix }}" + + assert: + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: nick-fields/assert-action@v1 + with: + expected: '[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]' + actual: "${{ needs.test.outputs.affected }}" + + - uses: nick-fields/assert-action@v1 + with: + expected: '{"include":[' + actual: "${{ needs.test.outputs.matrix }}" + comparison: contains + + - uses: nick-fields/assert-action@v1 + with: + expected: '{"include":[{"name":"core-audit","items":"{\"include\":[{\"name\":\"core-gbl-audit-datadog-integration - core-gbl-audit-datadog-integration\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"core-gbl-audit\\\",\\\"stack_slug\\\":\\\"core-gbl-audit-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"}]}\"}]}"},{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-gbl-auto-datadog-integration - core-gbl-auto-infrastructure-cplive-plat\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"core-gbl-auto\\\",\\\"stack_slug\\\":\\\"core-gbl-auto-datadog-integration\\\",\\\"spacelift_stack\\\":\\\"core-gbl-auto-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"},{\\\"component\\\":\\\"infrastructure-cplive-core\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/spacelift\\\",\\\"stack\\\":\\\"core-gbl-auto\\\",\\\"stack_slug\\\":\\\"core-gbl-auto-infrastructure-cplive-core\\\",\\\"spacelift_stack\\\":\\\"core-gbl-auto-infrastructure-cplive-core\\\",\\\"affected\\\":\\\"stack.vars\\\"},{\\\"component\\\":\\\"infrastructure-cplive-plat\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/spacelift\\\",\\\"stack\\\":\\\"core-gbl-auto\\\",\\\"stack_slug\\\":\\\"core-gbl-auto-infrastructure-cplive-plat\\\",\\\"spacelift_stack\\\":\\\"core-gbl-auto-infrastructure-cplive-plat\\\",\\\"affected\\\":\\\"stack.vars\\\"}]}\"}]}"},{"name":"core-root","items":"{\"include\":[{\"name\":\"core-ue2-root-datadog-integration - core-ue2-root-datadog-integration\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"core-ue2-root\\\",\\\"stack_slug\\\":\\\"core-ue2-root-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"}]}\"}]}"},{"name":"plat-prod","items":"{\"include\":[{\"name\":\"plat-gbl-prod-datadog-integration - plat-gbl-prod-datadog-integration\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"plat-gbl-prod\\\",\\\"stack_slug\\\":\\\"plat-gbl-prod-datadog-integration\\\",\\\"spacelift_stack\\\":\\\"plat-gbl-prod-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"}]}\"}]}"}]}' + actual: "${{ needs.test.outputs.matrix }}" diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml new file mode 100644 index 0000000..3bf9353 --- /dev/null +++ b/.github/workflows/test-positive.yml @@ -0,0 +1,56 @@ +name: Test select components +on: +# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered +# # +# # Added pull_request to register workflow from the PR. +# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo + pull_request: {} + workflow_dispatch: {} + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Setup + run: echo "Do setup" + + test: + runs-on: ubuntu-latest + needs: [setup] + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: add mock atmos to the path + run: echo "./tests/fixtures" >> $GITHUB_PATH + + - uses: ./ + id: current + with: + install-atmos: false + atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + + outputs: + affected: "${{ steps.current.outputs.affected }}" + matrix: "${{ steps.current.outputs.matrix }}" + + assert: + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: nick-fields/assert-action@v1 + with: + expected: '[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]' + actual: "${{ needs.test.outputs.affected }}" + + - uses: nick-fields/assert-action@v1 + with: + expected: '{"include":[' + actual: "${{ needs.test.outputs.matrix }}" + comparison: contains + + - uses: nick-fields/assert-action@v1 + with: + expected: '{"include":[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]}' + actual: "${{ needs.test.outputs.matrix }}" diff --git a/action.yml b/action.yml index 1c8bb53..4fe1391 100644 --- a/action.yml +++ b/action.yml @@ -7,23 +7,16 @@ branding: inputs: jq-query: description: jq query that will be used to select atmos components - required: true - default-branch: - description: The default branch to use for the base ref. required: false - default: ${{ github.event.repository.default_branch }} - atmos-version: - description: The version of atmos to install if install-atmos is true + default: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' + head-ref: + description: The head ref to checkout. If not provided, the head default branch is used. required: false - default: "latest" - atmos-config-path: - description: The path to the atmos.yaml file + default: ${{ github.sha }} + atmos-gitops-config-path: + description: The path to the atmos-gitops.yaml file required: false - default: atmos.yaml - terraform-version: - description: The version of terraform to install if install-terraform is true - required: false - default: "latest" + default: ./.github/config/atmos-gitops.yaml jq-version: description: The version of jq to install if install-jq is true required: false @@ -32,13 +25,17 @@ inputs: description: "Enable action debug mode. Default: 'false'" default: 'false' required: false + nested-matrices-count: + required: false + description: 'Matrices nested levels count (from 1 to 3)' + default: "2" outputs: selected-components: description: Selected GitOps components value: ${{ steps.selected-components.outputs.components }} matrix: description: Matrix for Selected GitOps components - value: ${{ steps.matrix.outputs.matrix }} + value: ${{ steps.matrix.outputs.output }} has-selected-components: description: Whether there are selected components value: ${{ steps.selected-components.outputs.components != '[]' }} @@ -46,10 +43,22 @@ outputs: runs: using: "composite" steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.head-ref }} + + - name: config + uses: blablacar/action-config-levels@dc8ddbca36875e29f870e53bcc1160b7000ff5b2 + id: config + with: + output_properties: true + patterns: | + - ${{ inputs.atmos-gitops-config-path }} + - name: Install Terraform uses: hashicorp/setup-terraform@v2 with: - terraform_version: ${{ inputs.terraform-version }} + terraform_version: ${{ steps.config.outputs.terraform-version }} terraform_wrapper: false - name: Install Atmos @@ -57,7 +66,7 @@ runs: env: ATMOS_CLI_CONFIG_PATH: ${{inputs.atmos-config-path}} with: - atmos-version: ${{ inputs.atmos-version }} + atmos-version: ${{ steps.config.outputs.atmos-version }} install-wrapper: false - name: Install JQ @@ -65,26 +74,42 @@ runs: with: version: ${{ inputs.jq-version }} - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ inputs.default-branch }} - - name: Filter Components id: selected-components shell: bash env: - ATMOS_CLI_CONFIG_PATH: ${{inputs.atmos-config-path}} + ATMOS_CLI_CONFIG_PATH: ${{ steps.config.outputs.atmos-config-path }} + ATMOS_BASE_PATH: ${{ github.workspace }} + JQUERY: | + with_entries(.value |= (.components.terraform)) | ## Deal with components type of terraform + map_values(map_values(select(.settings.github.actions_enabled // false))) | ## Filter components by enabled github actions + map_values(select(. != {})) | ## Skip stacks that have 0 selected components + map_values(. | keys) | ## Reduce to component names + with_entries( ## Construct component object + .key as $stack | + .value |= map({ + "component": ., + "stack": $stack, + "stack_slug": [$stack, .] | join("-") + }) + ) | map(.) | flatten ## Reduce to flat array run: | - JQ_QUERY='${{ inputs.jq-query }}' DEBUG="${{ inputs.debug }}" ${{ github.action_path }}/src/filter.sh + atmos describe stacks --format json | jq -ce "${JQUERY}" > components.json components=$(cat components.json) echo "Selected components: $components" printf "%s" "components=$components" >> $GITHUB_OUTPUT - - name: Build Matrix - id: matrix - shell: bash - run: | - matrix=$(jq -c '{include:[.[]]}' < components.json) - echo "matrix=$matrix" >> $GITHUB_OUTPUT + - uses: cloudposse/github-action-matrix-unlimited-jq-query@v0 + id: query + with: + sort-by: ${{ steps.config.outputs.sort-by }} + group-by: ${{ steps.config.outputs.group-by }} + nested-matrices-count: ${{ inputs.nested-matrices-count }} + + - id: matrix + uses: cloudposse/github-action-jq@v0 + with: + compact: true + input: components.json + script: ${{ steps.query.outputs.query }} \ No newline at end of file diff --git a/src/filter.sh b/src/filter.sh deleted file mode 100755 index cacf33b..0000000 --- a/src/filter.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -JQ_QUERY=${JQ_QUERY:-'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")'} - -atmos describe stacks --format json --file stacks.json -[ "$DEBUG" == "true" ] && cat stacks.json - -jq -r "$JQ_QUERY" stacks.json > components.csv -[ "$DEBUG" == "true" ] && cat components.csv - -echo -n "" > enriched_components.csv -while IFS=',' read -r stack component -do - component_path=$(atmos describe component $component -s $stack --format json | jq -rc '.. | select(.component_info)? | .component_info.component_path') - echo "$stack,$component,$component_path" >> enriched_components.csv -done < components.csv - -[ "$DEBUG" == "true" ] && cat enriched_components.csv - -echo -n '[' > components.json -while IFS=',' read -r stack component component_path; do - stack_slug="$stack-$component" - printf '{"stack": "%s", "component": "%s", "stack_slug": "%s", "component_path": "%s"},' "$stack" "$component" "$stack_slug" "$component_path" >> components.json -done < enriched_components.csv -sed -i.bak '$ s/,$//' components.json # Removing the last comma and appending closing brackets -echo -n ']' >> components.json - -[ "$DEBUG" == "true" ] && cat components.json - -components=$(jq -c < components.json) -echo -n "$components" > components.json diff --git a/test/run.sh b/test/run.sh deleted file mode 100755 index 8b16140..0000000 --- a/test/run.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -./src/filter.sh - -expected_content='[{"stack":"core-ue2-auto","component":"test-2","stack_slug":"core-ue2-auto-test-2","component_path":""},{"stack":"plat-ue2-dev","component":"test-4","stack_slug":"plat-ue2-dev-test-4","component_path":""},{"stack":"plat-ue2-sandbox","component":"test-5","stack_slug":"plat-ue2-sandbox-test-5","component_path":""}]' -file_content=$(' command-line argument in 'atmos atlantis generate repo-config' command + config_templates: + config-1: + version: 3 + automerge: true + delete_source_branch_on_merge: true + parallel_plan: true + parallel_apply: true + allowed_regexp_prefixes: + - dev/ + - staging/ + - prod/ + + # Project templates + # Select a template by using the '--project-template ' command-line argument in 'atmos atlantis generate repo-config' command + project_templates: + project-1: + # generate a project entry for each component in every stack + name: "{tenant}-{environment}-{stage}-{component}" + workspace: "{workspace}" + dir: "{component-path}" + terraform_version: v1.2 + delete_source_branch_on_merge: true + autoplan: + enabled: true + when_modified: + - "**/*.tf" + - "varfiles/$PROJECT_NAME.tfvars.json" + apply_requirements: + - "approved" + + # Workflow templates + # https://www.runatlantis.io/docs/custom-workflows.html#custom-init-plan-apply-commands + # https://www.runatlantis.io/docs/custom-workflows.html#custom-run-command + # Select a template by using the '--workflow-template ' command-line argument in 'atmos atlantis generate repo-config' command + workflow_templates: + workflow-1: + plan: + steps: + - run: terraform init -input=false + # When using workspaces, you need to select the workspace using the $WORKSPACE environment variable + - run: terraform workspace select $WORKSPACE || terraform workspace new $WORKSPACE + # You must output the plan using '-out $PLANFILE' because Atlantis expects plans to be in a specific location + - run: terraform plan -input=false -refresh -out $PLANFILE -var-file varfiles/$PROJECT_NAME.tfvars.json + apply: + steps: + - run: terraform apply $PLANFILE + +# Validation schemas (for validating atmos stacks and components) +schemas: + # https://json-schema.org + jsonschema: + # Can also be set using 'ATMOS_SCHEMAS_JSONSCHEMA_BASE_PATH' ENV var, or '--schemas-jsonschema-dir' command-line arguments + # Supports both absolute and relative paths + base_path: "stacks/schemas/jsonschema" + # https://www.openpolicyagent.org + opa: + # Can also be set using 'ATMOS_SCHEMAS_OPA_BASE_PATH' ENV var, or '--schemas-opa-dir' command-line arguments + # Supports both absolute and relative paths + base_path: "stacks/schemas/opa" + # https://cuelang.org + cue: + # Can also be set using 'ATMOS_SCHEMAS_CUE_BASE_PATH' ENV var, or '--schemas-cue-dir' command-line arguments + # Supports both absolute and relative paths + base_path: "stacks/schemas/cue" diff --git a/tests/components/terraform/test/main.tf b/tests/components/terraform/test/main.tf new file mode 100644 index 0000000..d25a48e --- /dev/null +++ b/tests/components/terraform/test/main.tf @@ -0,0 +1,12 @@ +variable "seed" { + type = string + default = "foo" +} + +resource "random_id" "this" { + keepers = { + # Generate a new id each time we switch to a new seed + seed = "${var.seed}" + } + byte_length = 8 +} diff --git a/stacks/orgs/test/_defaults.yaml b/tests/stacks/orgs/test/_defaults.yaml similarity index 100% rename from stacks/orgs/test/_defaults.yaml rename to tests/stacks/orgs/test/_defaults.yaml diff --git a/stacks/orgs/test/core/_defaults.yaml b/tests/stacks/orgs/test/core/_defaults.yaml similarity index 100% rename from stacks/orgs/test/core/_defaults.yaml rename to tests/stacks/orgs/test/core/_defaults.yaml diff --git a/stacks/orgs/test/core/auto/test.yaml b/tests/stacks/orgs/test/core/auto/test.yaml similarity index 100% rename from stacks/orgs/test/core/auto/test.yaml rename to tests/stacks/orgs/test/core/auto/test.yaml diff --git a/stacks/orgs/test/plat/_defaults.yaml b/tests/stacks/orgs/test/plat/_defaults.yaml similarity index 100% rename from stacks/orgs/test/plat/_defaults.yaml rename to tests/stacks/orgs/test/plat/_defaults.yaml diff --git a/stacks/orgs/test/plat/dev/test.yaml b/tests/stacks/orgs/test/plat/dev/test.yaml similarity index 100% rename from stacks/orgs/test/plat/dev/test.yaml rename to tests/stacks/orgs/test/plat/dev/test.yaml diff --git a/stacks/orgs/test/plat/sandbox/test.yaml b/tests/stacks/orgs/test/plat/sandbox/test.yaml similarity index 100% rename from stacks/orgs/test/plat/sandbox/test.yaml rename to tests/stacks/orgs/test/plat/sandbox/test.yaml From 3f438b0ed29ed1939facc496b06796e063d05190 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 01:50:32 +0100 Subject: [PATCH 02/32] Incupsulate configs --- .github/workflows/release-published.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .github/workflows/release-published.yml diff --git a/.github/workflows/release-published.yml b/.github/workflows/release-published.yml deleted file mode 100644 index 7bfa5b3..0000000 --- a/.github/workflows/release-published.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: release-published - -on: - release: - types: - - published - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: cloudposse/github-action-major-release-tagger@v1 \ No newline at end of file From 5c84dc8b5ff8ce40c5f28b6a528d362187f7e4e6 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 01:53:53 +0100 Subject: [PATCH 03/32] Incupsulate configs --- .github/workflows/test-matrix-2-levels.yml | 2 +- .github/workflows/test-matrix-3-levels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index 56b838a..16802bc 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo -# pull_request: {} + pull_request: {} workflow_dispatch: {} jobs: diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index bcb23dd..5a839b8 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo -# pull_request: {} + pull_request: {} workflow_dispatch: {} jobs: From 7b990e9f0ef2df5735ee10d1670c1965ab79b240 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:01:24 +0100 Subject: [PATCH 04/32] Incupsulate configs --- .github/workflows/test-matrix-2-levels.yml | 2 +- .github/workflows/test-matrix-3-levels.yml | 2 +- .github/workflows/test-positive.yml | 9 +-- tests/atmos-gitops.yaml | 2 +- tests/atmos.yaml | 69 ++++++++++++++++++++++ 5 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 tests/atmos.yaml diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index 16802bc..56b838a 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo - pull_request: {} +# pull_request: {} workflow_dispatch: {} jobs: diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index 5a839b8..bcb23dd 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo - pull_request: {} +# pull_request: {} workflow_dispatch: {} jobs: diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index 3bf9353..299a9ee 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -4,7 +4,7 @@ on: # # # # Added pull_request to register workflow from the PR. # # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo - pull_request: {} +# pull_request: {} workflow_dispatch: {} jobs: @@ -19,16 +19,9 @@ jobs: needs: [setup] continue-on-error: true steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: add mock atmos to the path - run: echo "./tests/fixtures" >> $GITHUB_PATH - - uses: ./ id: current with: - install-atmos: false atmos-gitops-config-path: "./tests/atmos-gitops.yaml" outputs: diff --git a/tests/atmos-gitops.yaml b/tests/atmos-gitops.yaml index ad949b6..db46a85 100644 --- a/tests/atmos-gitops.yaml +++ b/tests/atmos-gitops.yaml @@ -1,5 +1,5 @@ atmos-version: 1.45.3 -atmos-config-path: ./rootfs/usr/local/etc/atmos/ +atmos-config-path: ./tests/ terraform-state-bucket: cptest-core-ue2-auto-gitops terraform-state-table: cptest-core-ue2-auto-gitops terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha diff --git a/tests/atmos.yaml b/tests/atmos.yaml new file mode 100644 index 0000000..8ee70cf --- /dev/null +++ b/tests/atmos.yaml @@ -0,0 +1,69 @@ +# CLI config is loaded from the following locations (from lowest to highest priority): +# system dir (`/usr/local/etc/atmos` on Linux, `%LOCALAPPDATA%/atmos` on Windows) +# home dir (~/.atmos) +# current directory +# ENV vars +# Command-line arguments +# +# It supports POSIX-style Globs for file names/paths (double-star `**` is supported) +# https://en.wikipedia.org/wiki/Glob_(programming) + +# Base path for components, stacks and workflows configurations. +# Can also be set using `ATMOS_BASE_PATH` ENV var, or `--base-path` command-line argument. +# Supports both absolute and relative paths. +# If not provided or is an empty string, `components.terraform.base_path`, `components.helmfile.base_path`, `stacks.base_path` and `workflows.base_path` +# 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: "./tests" + +components: + terraform: + # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_BASE_PATH` ENV var, or `--terraform-dir` command-line argument + # Supports both absolute and relative paths + base_path: "components/terraform" + # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE` ENV var + apply_auto_approve: false + # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT` ENV var, or `--deploy-run-init` command-line argument + deploy_run_init: true + # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE` ENV var, or `--init-run-reconfigure` command-line argument + init_run_reconfigure: true + # Can also be set using `ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE` ENV var, or `--auto-generate-backend-file` command-line argument + auto_generate_backend_file: true + helmfile: + # Can also be set using `ATMOS_COMPONENTS_HELMFILE_BASE_PATH` ENV var, or `--helmfile-dir` command-line argument + # Supports both absolute and relative paths + base_path: "components/helmfile" + # Can also be set using `ATMOS_COMPONENTS_HELMFILE_KUBECONFIG_PATH` ENV var + kubeconfig_path: "/conf/.kube/" + # Can also be set using `ATMOS_COMPONENTS_HELMFILE_HELM_AWS_PROFILE_PATTERN` ENV var + helm_aws_profile_pattern: "{namespace}-{tenant}-gbl-{stage}-helm" + # Can also be set using `ATMOS_COMPONENTS_HELMFILE_CLUSTER_NAME_PATTERN` ENV var + cluster_name_pattern: "{namespace}-{tenant}-{environment}-{stage}-eks-cluster" + +stacks: + # Can also be set using `ATMOS_STACKS_BASE_PATH` ENV var, or `--config-dir` and `--stacks-dir` command-line arguments + # Supports both absolute and relative paths + base_path: "stacks" + # Can also be set using `ATMOS_STACKS_INCLUDED_PATHS` ENV var (comma-separated values string) + # Since we are distinguishing stacks based on namespace, and namespace is not part + # of the stack name, we have to set `included_paths` via the ENV var in the Dockerfile + included_paths: + - "orgs/**/*" + # Can also be set using `ATMOS_STACKS_EXCLUDED_PATHS` ENV var (comma-separated values string) + excluded_paths: + - "**/_defaults.yaml" + # exclude workflows directory if otherwise included in `included_paths` above + # - "workflows/**/*" + + # Can also be set using `ATMOS_STACKS_NAME_PATTERN` ENV var + name_pattern: "{tenant}-{environment}-{stage}" + +workflows: + # Can also be set using `ATMOS_WORKFLOWS_BASE_PATH` ENV var, or `--workflows-dir` command-line arguments + # Supports both absolute and relative paths + base_path: "stacks/workflows" + +logs: + verbose: false + colors: true From 8b6fc684f7e99a855cb01b05daf1c9c1910648e6 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:03:22 +0100 Subject: [PATCH 05/32] Incupsulate configs --- .github/workflows/test-matrix-2-levels.yml | 5 ----- .github/workflows/test-matrix-3-levels.yml | 4 ---- .github/workflows/test-positive.yml | 3 +++ 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index 56b838a..f854afb 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -21,14 +21,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: add mock atmos to the path - run: echo "./tests/fixtures" >> $GITHUB_PATH - - uses: ./ id: current with: - install-atmos: false atmos-gitops-config-path: "./tests/atmos-gitops.yaml" nested-matrices-count: '2' diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index bcb23dd..9acfdca 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -22,13 +22,9 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: add mock atmos to the path - run: echo "./tests/fixtures" >> $GITHUB_PATH - - uses: ./ id: current with: - install-atmos: false atmos-gitops-config-path: "./tests/atmos-gitops.yaml" nested-matrices-count: '3' diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index 299a9ee..c6ce733 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -19,6 +19,9 @@ jobs: needs: [setup] continue-on-error: true steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: ./ id: current with: From a8dace276e5d598d7bc4098a424437961e724a77 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:05:52 +0100 Subject: [PATCH 06/32] Incupsulate configs --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 4fe1391..8b11946 100644 --- a/action.yml +++ b/action.yml @@ -79,7 +79,6 @@ runs: shell: bash env: ATMOS_CLI_CONFIG_PATH: ${{ steps.config.outputs.atmos-config-path }} - ATMOS_BASE_PATH: ${{ github.workspace }} JQUERY: | with_entries(.value |= (.components.terraform)) | ## Deal with components type of terraform map_values(map_values(select(.settings.github.actions_enabled // false))) | ## Filter components by enabled github actions From 9d9b1b7b55dc1e2cc15a4d85400075dfc465f3ad Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:08:42 +0100 Subject: [PATCH 07/32] Incupsulate configs --- .github/workflows/test-positive.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index c6ce733..1fc2d93 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -28,7 +28,7 @@ jobs: atmos-gitops-config-path: "./tests/atmos-gitops.yaml" outputs: - affected: "${{ steps.current.outputs.affected }}" + selected-components: "${{ steps.current.outputs.selected-components }}" matrix: "${{ steps.current.outputs.matrix }}" assert: @@ -38,7 +38,7 @@ jobs: - uses: nick-fields/assert-action@v1 with: expected: '[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]' - actual: "${{ needs.test.outputs.affected }}" + actual: "${{ needs.test.outputs.selected-components }}" - uses: nick-fields/assert-action@v1 with: From 0983bd0a37b7bae36058b5dfa1a6be7d022198b2 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:10:51 +0100 Subject: [PATCH 08/32] Incupsulate configs --- .github/workflows/test-positive.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index 1fc2d93..a201f18 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: nick-fields/assert-action@v1 with: - expected: '[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]' + expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' actual: "${{ needs.test.outputs.selected-components }}" - uses: nick-fields/assert-action@v1 From 1a4eb7b5e0af8b6ec7c117efe8c4be4a77282f26 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:14:10 +0100 Subject: [PATCH 09/32] Incupsulate configs --- .github/workflows/test-positive.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index a201f18..c17ec63 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -48,5 +48,5 @@ jobs: - uses: nick-fields/assert-action@v1 with: - expected: '{"include":[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]}' + expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"component\":\"test-2\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-2\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"component\":\"test-4\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-4\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"component\":\"test-5\",\"stack\":\"plat-ue2-sandbox\",\"stack_slug\":\"plat-ue2-sandbox-test-5\"}]}"}]}' actual: "${{ needs.test.outputs.matrix }}" From 3cbcb638a4c26e958e6bd384e50e9f02b50d2e56 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:16:23 +0100 Subject: [PATCH 10/32] Incupsulate configs --- .github/workflows/test-matrix-2-levels.yml | 2 +- .github/workflows/test-matrix-3-levels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index f854afb..1d4845b 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: nick-fields/assert-action@v1 with: - expected: '[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]' + expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' actual: "${{ needs.test.outputs.affected }}" - uses: nick-fields/assert-action@v1 diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index 9acfdca..0f72186 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -38,7 +38,7 @@ jobs: steps: - uses: nick-fields/assert-action@v1 with: - expected: '[{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-ue2-root","stack_slug":"core-ue2-root-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-audit","stack_slug":"core-gbl-audit-datadog-integration","affected":"component"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-datadog-integration","spacelift_stack":"core-gbl-auto-datadog-integration","affected":"component"},{"component":"infrastructure-cplive-plat","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-plat","spacelift_stack":"core-gbl-auto-infrastructure-cplive-plat","affected":"stack.vars"},{"component":"infrastructure-cplive-core","component_type":"terraform","component_path":"components/terraform/spacelift","stack":"core-gbl-auto","stack_slug":"core-gbl-auto-infrastructure-cplive-core","spacelift_stack":"core-gbl-auto-infrastructure-cplive-core","affected":"stack.vars"},{"component":"datadog-integration","component_type":"terraform","component_path":"components/terraform/datadog-integration","stack":"plat-gbl-prod","stack_slug":"plat-gbl-prod-datadog-integration","spacelift_stack":"plat-gbl-prod-datadog-integration","affected":"component"}]' + expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' actual: "${{ needs.test.outputs.affected }}" - uses: nick-fields/assert-action@v1 From b845864103f441c3304378f028c5d2f72eab8cb0 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:18:09 +0100 Subject: [PATCH 11/32] Incupsulate configs --- .github/workflows/test-matrix-2-levels.yml | 4 ++-- .github/workflows/test-matrix-3-levels.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index 1d4845b..a173409 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -28,7 +28,7 @@ jobs: nested-matrices-count: '2' outputs: - affected: "${{ steps.current.outputs.affected }}" + selected-components: "${{ steps.current.outputs.selected-components }}" matrix: "${{ steps.current.outputs.matrix }}" assert: @@ -38,7 +38,7 @@ jobs: - uses: nick-fields/assert-action@v1 with: expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' - actual: "${{ needs.test.outputs.affected }}" + actual: "${{ needs.test.outputs.selected-components }}" - uses: nick-fields/assert-action@v1 with: diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index 0f72186..8fcfb39 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -29,7 +29,7 @@ jobs: nested-matrices-count: '3' outputs: - affected: "${{ steps.current.outputs.affected }}" + selected-components: "${{ steps.current.outputs.selected-components }}" matrix: "${{ steps.current.outputs.matrix }}" assert: @@ -39,7 +39,7 @@ jobs: - uses: nick-fields/assert-action@v1 with: expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' - actual: "${{ needs.test.outputs.affected }}" + actual: "${{ needs.test.outputs.selected-components }}" - uses: nick-fields/assert-action@v1 with: From b6bb80dc44a64cee0f20a94f9a6172fd5d1006a5 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:20:22 +0100 Subject: [PATCH 12/32] Incupsulate configs --- .github/workflows/test-matrix-2-levels.yml | 2 +- .github/workflows/test-matrix-3-levels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index a173409..b81b670 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -48,5 +48,5 @@ jobs: - uses: nick-fields/assert-action@v1 with: - expected: '{"include":[{"name":"core-audit","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"core-gbl-audit\",\"stack_slug\":\"core-gbl-audit-datadog-integration\",\"affected\":\"component\"}]}"},{"name":"core-auto","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"core-gbl-auto\",\"stack_slug\":\"core-gbl-auto-datadog-integration\",\"spacelift_stack\":\"core-gbl-auto-datadog-integration\",\"affected\":\"component\"},{\"component\":\"infrastructure-cplive-core\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/spacelift\",\"stack\":\"core-gbl-auto\",\"stack_slug\":\"core-gbl-auto-infrastructure-cplive-core\",\"spacelift_stack\":\"core-gbl-auto-infrastructure-cplive-core\",\"affected\":\"stack.vars\"},{\"component\":\"infrastructure-cplive-plat\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/spacelift\",\"stack\":\"core-gbl-auto\",\"stack_slug\":\"core-gbl-auto-infrastructure-cplive-plat\",\"spacelift_stack\":\"core-gbl-auto-infrastructure-cplive-plat\",\"affected\":\"stack.vars\"}]}"},{"name":"core-root","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"core-ue2-root\",\"stack_slug\":\"core-ue2-root-datadog-integration\",\"affected\":\"component\"}]}"},{"name":"plat-prod","items":"{\"include\":[{\"component\":\"datadog-integration\",\"component_type\":\"terraform\",\"component_path\":\"components/terraform/datadog-integration\",\"stack\":\"plat-gbl-prod\",\"stack_slug\":\"plat-gbl-prod-datadog-integration\",\"spacelift_stack\":\"plat-gbl-prod-datadog-integration\",\"affected\":\"component\"}]}"}]}' + expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"component\":\"test-2\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-2\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"component\":\"test-4\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-4\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"component\":\"test-5\",\"stack\":\"plat-ue2-sandbox\",\"stack_slug\":\"plat-ue2-sandbox-test-5\"}]}"}]}' actual: "${{ needs.test.outputs.matrix }}" diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index 8fcfb39..9ff2bb8 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -49,5 +49,5 @@ jobs: - uses: nick-fields/assert-action@v1 with: - expected: '{"include":[{"name":"core-audit","items":"{\"include\":[{\"name\":\"core-gbl-audit-datadog-integration - core-gbl-audit-datadog-integration\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"core-gbl-audit\\\",\\\"stack_slug\\\":\\\"core-gbl-audit-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"}]}\"}]}"},{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-gbl-auto-datadog-integration - core-gbl-auto-infrastructure-cplive-plat\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"core-gbl-auto\\\",\\\"stack_slug\\\":\\\"core-gbl-auto-datadog-integration\\\",\\\"spacelift_stack\\\":\\\"core-gbl-auto-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"},{\\\"component\\\":\\\"infrastructure-cplive-core\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/spacelift\\\",\\\"stack\\\":\\\"core-gbl-auto\\\",\\\"stack_slug\\\":\\\"core-gbl-auto-infrastructure-cplive-core\\\",\\\"spacelift_stack\\\":\\\"core-gbl-auto-infrastructure-cplive-core\\\",\\\"affected\\\":\\\"stack.vars\\\"},{\\\"component\\\":\\\"infrastructure-cplive-plat\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/spacelift\\\",\\\"stack\\\":\\\"core-gbl-auto\\\",\\\"stack_slug\\\":\\\"core-gbl-auto-infrastructure-cplive-plat\\\",\\\"spacelift_stack\\\":\\\"core-gbl-auto-infrastructure-cplive-plat\\\",\\\"affected\\\":\\\"stack.vars\\\"}]}\"}]}"},{"name":"core-root","items":"{\"include\":[{\"name\":\"core-ue2-root-datadog-integration - core-ue2-root-datadog-integration\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"core-ue2-root\\\",\\\"stack_slug\\\":\\\"core-ue2-root-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"}]}\"}]}"},{"name":"plat-prod","items":"{\"include\":[{\"name\":\"plat-gbl-prod-datadog-integration - plat-gbl-prod-datadog-integration\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"datadog-integration\\\",\\\"component_type\\\":\\\"terraform\\\",\\\"component_path\\\":\\\"components/terraform/datadog-integration\\\",\\\"stack\\\":\\\"plat-gbl-prod\\\",\\\"stack_slug\\\":\\\"plat-gbl-prod-datadog-integration\\\",\\\"spacelift_stack\\\":\\\"plat-gbl-prod-datadog-integration\\\",\\\"affected\\\":\\\"component\\\"}]}\"}]}"}]}' + expected: '"include":[{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-ue2-auto-test-2 - core-ue2-auto-test-2\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-2\\\",\\\"stack\\\":\\\"core-ue2-auto\\\",\\\"stack_slug\\\":\\\"core-ue2-auto-test-2\\\"}]}\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"name\":\"plat-ue2-dev-test-4 - plat-ue2-dev-test-4\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-4\\\",\\\"stack\\\":\\\"plat-ue2-dev\\\",\\\"stack_slug\\\":\\\"plat-ue2-dev-test-4\\\"}]}\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"name\":\"plat-ue2-sandbox-test-5 - plat-ue2-sandbox-test-5\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-5\\\",\\\"stack\\\":\\\"plat-ue2-sandbox\\\",\\\"stack_slug\\\":\\\"plat-ue2-sandbox-test-5\\\"}]}\"}]}"}]}' actual: "${{ needs.test.outputs.matrix }}" From 7f3680768e80b5f1cf217676fd0656751044bb21 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:22:25 +0100 Subject: [PATCH 13/32] Incupsulate configs --- .github/workflows/test-matrix-3-levels.yml | 2 +- components/terraform/test/main.tf | 12 - tests/components/terraform/test/atmos.yaml | 266 --------------------- 3 files changed, 1 insertion(+), 279 deletions(-) delete mode 100644 components/terraform/test/main.tf delete mode 100644 tests/components/terraform/test/atmos.yaml diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index 9ff2bb8..a52c44b 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -49,5 +49,5 @@ jobs: - uses: nick-fields/assert-action@v1 with: - expected: '"include":[{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-ue2-auto-test-2 - core-ue2-auto-test-2\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-2\\\",\\\"stack\\\":\\\"core-ue2-auto\\\",\\\"stack_slug\\\":\\\"core-ue2-auto-test-2\\\"}]}\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"name\":\"plat-ue2-dev-test-4 - plat-ue2-dev-test-4\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-4\\\",\\\"stack\\\":\\\"plat-ue2-dev\\\",\\\"stack_slug\\\":\\\"plat-ue2-dev-test-4\\\"}]}\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"name\":\"plat-ue2-sandbox-test-5 - plat-ue2-sandbox-test-5\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-5\\\",\\\"stack\\\":\\\"plat-ue2-sandbox\\\",\\\"stack_slug\\\":\\\"plat-ue2-sandbox-test-5\\\"}]}\"}]}"}]}' + expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"name\":\"core-ue2-auto-test-2 - core-ue2-auto-test-2\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-2\\\",\\\"stack\\\":\\\"core-ue2-auto\\\",\\\"stack_slug\\\":\\\"core-ue2-auto-test-2\\\"}]}\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"name\":\"plat-ue2-dev-test-4 - plat-ue2-dev-test-4\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-4\\\",\\\"stack\\\":\\\"plat-ue2-dev\\\",\\\"stack_slug\\\":\\\"plat-ue2-dev-test-4\\\"}]}\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"name\":\"plat-ue2-sandbox-test-5 - plat-ue2-sandbox-test-5\",\"items\":\"{\\\"include\\\":[{\\\"component\\\":\\\"test-5\\\",\\\"stack\\\":\\\"plat-ue2-sandbox\\\",\\\"stack_slug\\\":\\\"plat-ue2-sandbox-test-5\\\"}]}\"}]}"}]}' actual: "${{ needs.test.outputs.matrix }}" diff --git a/components/terraform/test/main.tf b/components/terraform/test/main.tf deleted file mode 100644 index d25a48e..0000000 --- a/components/terraform/test/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -variable "seed" { - type = string - default = "foo" -} - -resource "random_id" "this" { - keepers = { - # Generate a new id each time we switch to a new seed - seed = "${var.seed}" - } - byte_length = 8 -} diff --git a/tests/components/terraform/test/atmos.yaml b/tests/components/terraform/test/atmos.yaml deleted file mode 100644 index e9c4330..0000000 --- a/tests/components/terraform/test/atmos.yaml +++ /dev/null @@ -1,266 +0,0 @@ -# CLI config is loaded from the following locations (from lowest to highest priority): -# system dir ('/usr/local/etc/atmos' on Linux, '%LOCALAPPDATA%/atmos' on Windows) -# home dir (~/.atmos) -# current directory -# ENV vars -# Command-line arguments -# -# It supports POSIX-style Globs for file names/paths (double-star '**' is supported) -# https://en.wikipedia.org/wiki/Glob_(programming) - -# Base path for components, stacks and workflows configurations. -# Can also be set using 'ATMOS_BASE_PATH' ENV var, or '--base-path' command-line argument. -# Supports both absolute and relative paths. -# If not provided or is an empty string, 'components.terraform.base_path', 'components.helmfile.base_path', 'stacks.base_path' and 'workflows.base_path' -# 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: "./tests" - -components: - terraform: - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_BASE_PATH' ENV var, or '--terraform-dir' command-line argument - # Supports both absolute and relative paths - base_path: "components/terraform" - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_APPLY_AUTO_APPROVE' ENV var - apply_auto_approve: false - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_DEPLOY_RUN_INIT' ENV var, or '--deploy-run-init' command-line argument - deploy_run_init: true - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE' ENV var, or '--init-run-reconfigure' command-line argument - init_run_reconfigure: true - # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_AUTO_GENERATE_BACKEND_FILE' ENV var, or '--auto-generate-backend-file' command-line argument - auto_generate_backend_file: false - helmfile: - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_BASE_PATH' ENV var, or '--helmfile-dir' command-line argument - # Supports both absolute and relative paths - base_path: "components/helmfile" - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_USE_EKS' ENV var - # If not specified, defaults to 'true' - use_eks: true - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_KUBECONFIG_PATH' ENV var - kubeconfig_path: "/dev/shm" - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_HELM_AWS_PROFILE_PATTERN' ENV var - helm_aws_profile_pattern: "{namespace}-gbl-{stage}-helm" - # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_CLUSTER_NAME_PATTERN' ENV var - cluster_name_pattern: "{namespace}-{environment}-{stage}-eks-cluster" - -stacks: - # Can also be set using 'ATMOS_STACKS_BASE_PATH' ENV var, or '--config-dir' and '--stacks-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks" - # Can also be set using 'ATMOS_STACKS_INCLUDED_PATHS' ENV var (comma-separated values string) - included_paths: - - "orgs/**/*" - # Can also be set using 'ATMOS_STACKS_EXCLUDED_PATHS' ENV var (comma-separated values string) - excluded_paths: - - "**/_defaults.yaml" - # Can also be set using 'ATMOS_STACKS_NAME_PATTERN' ENV var - name_pattern: "{tenant}-{environment}-{stage}" - -workflows: - # Can also be set using 'ATMOS_WORKFLOWS_BASE_PATH' ENV var, or '--workflows-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/workflows" - -logs: - verbose: false - colors: true - -# Custom CLI commands -commands: - - name: tf - description: Execute 'terraform' commands - # subcommands - commands: - - name: plan - description: This command plans terraform components - arguments: - - name: component - description: Name of the component - flags: - - name: stack - shorthand: s - description: Name of the stack - required: true - env: - - key: ENV_VAR_1 - value: ENV_VAR_1_value - - key: ENV_VAR_2 - # 'valueCommand' is an external command to execute to get the value for the ENV var - # Either 'value' or 'valueCommand' can be specified for the ENV var, but not both - valueCommand: echo ENV_VAR_2_value - # steps support Go templates - steps: - - atmos terraform plan {{ .Arguments.component }} -s {{ .Flags.stack }} - - name: terraform - description: Execute 'terraform' commands - # subcommands - commands: - - name: provision - description: This command provisions terraform components - arguments: - - name: component - description: Name of the component - flags: - - name: stack - shorthand: s - description: Name of the stack - required: true - # ENV var values support Go templates - env: - - key: ATMOS_COMPONENT - value: "{{ .Arguments.component }}" - - key: ATMOS_STACK - value: "{{ .Flags.stack }}" - steps: - - atmos terraform plan $ATMOS_COMPONENT -s $ATMOS_STACK - - atmos terraform apply $ATMOS_COMPONENT -s $ATMOS_STACK - - name: play - description: This command plays games - steps: - - echo Playing... - # subcommands - commands: - - name: hello - description: This command says Hello world - steps: - - echo Hello world - - name: ping - description: This command plays ping-pong - # If 'verbose' is set to 'true', atmos will output some info messages to the console before executing the command's steps - # If 'verbose' is not defined, it implicitly defaults to 'false' - verbose: true - steps: - - echo Playing ping-pong... - - echo pong - - name: show - description: Execute 'show' commands - # subcommands - commands: - - name: component - description: Execute 'show component' command - arguments: - - name: component - description: Name of the component - flags: - - name: stack - shorthand: s - description: Name of the stack - required: true - # ENV var values support Go templates and have access to {{ .ComponentConfig.xxx.yyy.zzz }} Go template variables - env: - - key: ATMOS_COMPONENT - value: "{{ .Arguments.component }}" - - key: ATMOS_STACK - value: "{{ .Flags.stack }}" - - key: ATMOS_TENANT - value: "{{ .ComponentConfig.vars.tenant }}" - - key: ATMOS_STAGE - value: "{{ .ComponentConfig.vars.stage }}" - - key: ATMOS_ENVIRONMENT - value: "{{ .ComponentConfig.vars.environment }}" - - key: ATMOS_IS_PROD - value: "{{ .ComponentConfig.settings.config.is_prod }}" - # If a custom command defines 'component_config' section with 'component' and 'stack', 'atmos' generates the config for the component in the stack - # and makes it available in {{ .ComponentConfig.xxx.yyy.zzz }} Go template variables, - # exposing all the component sections (which are also shown by 'atmos describe component' command) - component_config: - component: "{{ .Arguments.component }}" - stack: "{{ .Flags.stack }}" - # Steps support using Go templates and can access all configuration settings (e.g. {{ .ComponentConfig.xxx.yyy.zzz }}) - # Steps also have access to the ENV vars defined in the 'env' section of the 'command' - steps: - - 'echo Atmos component from argument: "{{ .Arguments.component }}"' - - 'echo ATMOS_COMPONENT: "$ATMOS_COMPONENT"' - - 'echo Atmos stack: "{{ .Flags.stack }}"' - - 'echo Terraform component: "{{ .ComponentConfig.component }}"' - - 'echo Backend S3 bucket: "{{ .ComponentConfig.backend.bucket }}"' - - 'echo Terraform workspace: "{{ .ComponentConfig.workspace }}"' - - 'echo Namespace: "{{ .ComponentConfig.vars.namespace }}"' - - 'echo Tenant: "{{ .ComponentConfig.vars.tenant }}"' - - 'echo Environment: "{{ .ComponentConfig.vars.environment }}"' - - 'echo Stage: "{{ .ComponentConfig.vars.stage }}"' - - 'echo settings.spacelift.workspace_enabled: "{{ .ComponentConfig.settings.spacelift.workspace_enabled }}"' - - 'echo Dependencies: "{{ .ComponentConfig.deps }}"' - - 'echo settings.config.is_prod: "{{ .ComponentConfig.settings.config.is_prod }}"' - - 'echo ATMOS_IS_PROD: "$ATMOS_IS_PROD"' - -# Integrations -integrations: - # Atlantis integration - # https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html - atlantis: - # Path and name of the Atlantis config file 'atlantis.yaml' - # Supports absolute and relative paths - # All the intermediate folders will be created automatically (e.g. 'path: /config/atlantis/atlantis.yaml') - # Can be overridden on the command line by using '--output-path' command-line argument in 'atmos atlantis generate repo-config' command - # If not specified (set to an empty string/omitted here, and set to an empty string on the command line), the content of the file will be dumped to 'stdout' - # On Linux/macOS, you can also use '--output-path=/dev/stdout' to dump the content to 'stdout' without setting it to an empty string in 'atlantis.path' - path: "atlantis.yaml" - - # Config templates - # Select a template by using the '--config-template ' command-line argument in 'atmos atlantis generate repo-config' command - config_templates: - config-1: - version: 3 - automerge: true - delete_source_branch_on_merge: true - parallel_plan: true - parallel_apply: true - allowed_regexp_prefixes: - - dev/ - - staging/ - - prod/ - - # Project templates - # Select a template by using the '--project-template ' command-line argument in 'atmos atlantis generate repo-config' command - project_templates: - project-1: - # generate a project entry for each component in every stack - name: "{tenant}-{environment}-{stage}-{component}" - workspace: "{workspace}" - dir: "{component-path}" - terraform_version: v1.2 - delete_source_branch_on_merge: true - autoplan: - enabled: true - when_modified: - - "**/*.tf" - - "varfiles/$PROJECT_NAME.tfvars.json" - apply_requirements: - - "approved" - - # Workflow templates - # https://www.runatlantis.io/docs/custom-workflows.html#custom-init-plan-apply-commands - # https://www.runatlantis.io/docs/custom-workflows.html#custom-run-command - # Select a template by using the '--workflow-template ' command-line argument in 'atmos atlantis generate repo-config' command - workflow_templates: - workflow-1: - plan: - steps: - - run: terraform init -input=false - # When using workspaces, you need to select the workspace using the $WORKSPACE environment variable - - run: terraform workspace select $WORKSPACE || terraform workspace new $WORKSPACE - # You must output the plan using '-out $PLANFILE' because Atlantis expects plans to be in a specific location - - run: terraform plan -input=false -refresh -out $PLANFILE -var-file varfiles/$PROJECT_NAME.tfvars.json - apply: - steps: - - run: terraform apply $PLANFILE - -# Validation schemas (for validating atmos stacks and components) -schemas: - # https://json-schema.org - jsonschema: - # Can also be set using 'ATMOS_SCHEMAS_JSONSCHEMA_BASE_PATH' ENV var, or '--schemas-jsonschema-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/schemas/jsonschema" - # https://www.openpolicyagent.org - opa: - # Can also be set using 'ATMOS_SCHEMAS_OPA_BASE_PATH' ENV var, or '--schemas-opa-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/schemas/opa" - # https://cuelang.org - cue: - # Can also be set using 'ATMOS_SCHEMAS_CUE_BASE_PATH' ENV var, or '--schemas-cue-dir' command-line arguments - # Supports both absolute and relative paths - base_path: "stacks/schemas/cue" From 97736d0588f35dadd2571553d3c02685c947d676 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:25:39 +0100 Subject: [PATCH 14/32] Incupsulate configs --- .github/workflows/test-matrix-2-levels.yml | 1 + .github/workflows/test-matrix-3-levels.yml | 1 + .github/workflows/test-positive.yml | 1 + action.yml | 6 +++--- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-matrix-2-levels.yml b/.github/workflows/test-matrix-2-levels.yml index b81b670..9bb65c2 100644 --- a/.github/workflows/test-matrix-2-levels.yml +++ b/.github/workflows/test-matrix-2-levels.yml @@ -25,6 +25,7 @@ jobs: id: current with: atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + select-filter: '.settings.github.actions_enabled // false' nested-matrices-count: '2' outputs: diff --git a/.github/workflows/test-matrix-3-levels.yml b/.github/workflows/test-matrix-3-levels.yml index a52c44b..43626e5 100644 --- a/.github/workflows/test-matrix-3-levels.yml +++ b/.github/workflows/test-matrix-3-levels.yml @@ -26,6 +26,7 @@ jobs: id: current with: atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + select-filter: '.settings.github.actions_enabled // false' nested-matrices-count: '3' outputs: diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index c17ec63..c7d611e 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -26,6 +26,7 @@ jobs: id: current with: atmos-gitops-config-path: "./tests/atmos-gitops.yaml" + select-filter: '.settings.github.actions_enabled // false' outputs: selected-components: "${{ steps.current.outputs.selected-components }}" diff --git a/action.yml b/action.yml index 8b11946..eb2c82d 100644 --- a/action.yml +++ b/action.yml @@ -5,10 +5,10 @@ branding: icon: "file" color: "white" inputs: - jq-query: + select-filter: description: jq query that will be used to select atmos components required: false - default: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' + default: '.' head-ref: description: The head ref to checkout. If not provided, the head default branch is used. required: false @@ -81,7 +81,7 @@ runs: ATMOS_CLI_CONFIG_PATH: ${{ steps.config.outputs.atmos-config-path }} JQUERY: | with_entries(.value |= (.components.terraform)) | ## Deal with components type of terraform - map_values(map_values(select(.settings.github.actions_enabled // false))) | ## Filter components by enabled github actions + map_values(map_values(select(${{ inputs.select-filter }}))) | ## Filter components by enabled github actions map_values(select(. != {})) | ## Skip stacks that have 0 selected components map_values(. | keys) | ## Reduce to component names with_entries( ## Construct component object From 9a98c487356054080b052d22bef6ed66710df797 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:27:39 +0100 Subject: [PATCH 15/32] Incupsulate configs --- .github/workflows/test-positive.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index c7d611e..c17ec63 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -26,7 +26,6 @@ jobs: id: current with: atmos-gitops-config-path: "./tests/atmos-gitops.yaml" - select-filter: '.settings.github.actions_enabled // false' outputs: selected-components: "${{ steps.current.outputs.selected-components }}" From c0ca40f56547bd974f1633913f71f5cd1a29ff6d Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:30:39 +0100 Subject: [PATCH 16/32] Incupsulate configs --- .github/workflows/test-positive.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index c17ec63..d943d68 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -37,7 +37,7 @@ jobs: steps: - uses: nick-fields/assert-action@v1 with: - expected: '[{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' + expected: '[{"component":"test-1","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-1"},{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-3","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-3"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]' actual: "${{ needs.test.outputs.selected-components }}" - uses: nick-fields/assert-action@v1 @@ -48,5 +48,5 @@ jobs: - uses: nick-fields/assert-action@v1 with: - expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"component\":\"test-2\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-2\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"component\":\"test-4\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-4\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"component\":\"test-5\",\"stack\":\"plat-ue2-sandbox\",\"stack_slug\":\"plat-ue2-sandbox-test-5\"}]}"}]}' + expected: '{"include":[{"component":"test-1","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-1"},{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-3","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-3"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]}' actual: "${{ needs.test.outputs.matrix }}" From a44b8965e20c7d852105effde351f7f869e60472 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 02:32:15 +0100 Subject: [PATCH 17/32] Incupsulate configs --- .github/workflows/test-positive.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index d943d68..2c7f5d3 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -48,5 +48,5 @@ jobs: - uses: nick-fields/assert-action@v1 with: - expected: '{"include":[{"component":"test-1","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-1"},{"component":"test-2","stack":"core-ue2-auto","stack_slug":"core-ue2-auto-test-2"},{"component":"test-3","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-3"},{"component":"test-4","stack":"plat-ue2-dev","stack_slug":"plat-ue2-dev-test-4"},{"component":"test-5","stack":"plat-ue2-sandbox","stack_slug":"plat-ue2-sandbox-test-5"}]}' + expected: '{"include":[{"name":"core-auto","items":"{\"include\":[{\"component\":\"test-1\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-1\"},{\"component\":\"test-2\",\"stack\":\"core-ue2-auto\",\"stack_slug\":\"core-ue2-auto-test-2\"}]}"},{"name":"plat-dev","items":"{\"include\":[{\"component\":\"test-3\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-3\"},{\"component\":\"test-4\",\"stack\":\"plat-ue2-dev\",\"stack_slug\":\"plat-ue2-dev-test-4\"}]}"},{"name":"plat-sandbox","items":"{\"include\":[{\"component\":\"test-5\",\"stack\":\"plat-ue2-sandbox\",\"stack_slug\":\"plat-ue2-sandbox-test-5\"}]}"}]}' actual: "${{ needs.test.outputs.matrix }}" From a0f6fe1f9ec2db776a4433da1c7663de1b758816 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 7 Dec 2023 23:34:11 +0100 Subject: [PATCH 18/32] Use cloudposse action config --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index eb2c82d..d78cb8a 100644 --- a/action.yml +++ b/action.yml @@ -48,7 +48,7 @@ runs: ref: ${{ inputs.head-ref }} - name: config - uses: blablacar/action-config-levels@dc8ddbca36875e29f870e53bcc1160b7000ff5b2 + uses: cloudposse/github-action-config-levels@nodejs20 id: config with: output_properties: true From 2cac00d7fd1b827b04f407285dcbe4907d92ce4f Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Sat, 9 Dec 2023 00:16:47 +0100 Subject: [PATCH 19/32] Use extended matrix GHA --- action.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index d78cb8a..c9f22e7 100644 --- a/action.yml +++ b/action.yml @@ -35,7 +35,7 @@ outputs: value: ${{ steps.selected-components.outputs.components }} matrix: description: Matrix for Selected GitOps components - value: ${{ steps.matrix.outputs.output }} + value: ${{ steps.matrix.outputs.matrix }} has-selected-components: description: Whether there are selected components value: ${{ steps.selected-components.outputs.components != '[]' }} @@ -99,16 +99,10 @@ runs: echo "Selected components: $components" printf "%s" "components=$components" >> $GITHUB_OUTPUT - - uses: cloudposse/github-action-matrix-unlimited-jq-query@v0 - id: query + - uses: cloudposse/github-action-matrix-extended@incapsulate-jq + id: matrix with: + matrix: components.json sort-by: ${{ steps.config.outputs.sort-by }} group-by: ${{ steps.config.outputs.group-by }} nested-matrices-count: ${{ inputs.nested-matrices-count }} - - - id: matrix - uses: cloudposse/github-action-jq@v0 - with: - compact: true - input: components.json - script: ${{ steps.query.outputs.query }} \ No newline at end of file From 8a1573fdcf7646db144e75d0b05747bc3fdd6550 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Sat, 9 Dec 2023 22:13:28 +0100 Subject: [PATCH 20/32] Update README --- README.md | 61 +++++++++++++++++++++++++++++++++++++++++-- README.yaml | 60 +++++++++++++++++++++++++++++++++++++++++- action.yml | 10 +++---- docs/github-action.md | 9 +++---- 4 files changed, 127 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 28e6ce6..3318034 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,26 @@ Output of this action is a list of basic component information. For example: +### Config + +The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. +The config should have the following structure: + +```yaml + atmos-version: 1.45.3 + atmos-config-path: ./rootfs/usr/local/etc/atmos/ + terraform-state-bucket: cptest-core-ue2-auto-gitops + terraform-state-table: cptest-core-ue2-auto-gitops + terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha + terraform-plan-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + terraform-apply-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + terraform-version: 1.5.2 + aws-region: us-east-2 + enable-infracost: false + sort-by: .stack_slug + group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") +``` + ### GitHub Actions Workflow Example In following GitHub workflow example first job will filter components that have settings `github.actions_enabled: true` and then in following job `stack_slug` will be printed to stdout. @@ -122,6 +142,41 @@ In following GitHub workflow example first job will filter components that have echo "${{ matrix.stack_slug }}" ``` +### Migrate from `v0` to `v1` + +`v1` replace `jq-query` input with `selected-filter` variable and simplify the query. +Now you need to specify only part used in select function of `jq-query`. + +`v1` moved variables from `inputs` to atmos gitops config path `./.github/config/atmos-gitops.yaml` + +| name | +|--------------------------| +| `atmos-version` | +| `atmos-config-path` | + + +If you want `v1` having the same behaviour as `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. + +```yaml + - name: Selected Components + id: components + uses: cloudposse/github-action-atmos-terraform-select-components@v1 + with: + atmos-gitops-config-path: ./.github/config/atmos-gitops.yaml + select-filter: '.settings.github.actions_enabled // false' +``` + +same behaviour as + +```yaml + - name: Selected Components + id: components + uses: cloudposse/github-action-atmos-terraform-select-components@v0 + with: + atmos-config-path: "${{ github.workspace }}/rootfs/usr/local/etc/atmos/" + jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' +``` + @@ -284,8 +339,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply ### Contributors -| [![Zinovii Dmytriv][zdmytriv_avatar]][zdmytriv_homepage]
[Zinovii Dmytriv][zdmytriv_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Daniel Miller][milldr_avatar]][milldr_homepage]
[Daniel Miller][milldr_homepage] | -|---|---|---| +| [![Zinovii Dmytriv][zdmytriv_avatar]][zdmytriv_homepage]
[Zinovii Dmytriv][zdmytriv_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Daniel Miller][milldr_avatar]][milldr_homepage]
[Daniel Miller][milldr_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | +|---|---|---|---| [zdmytriv_homepage]: https://github.com/zdmytriv @@ -294,6 +349,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply [osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png [milldr_homepage]: https://github.com/milldr [milldr_avatar]: https://img.cloudposse.com/150x150/https://github.com/milldr.png + [goruha_homepage]: https://github.com/goruha + [goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png [![README Footer][readme_footer_img]][readme_footer_link] [![Beacon][beacon]][website] diff --git a/README.yaml b/README.yaml index ba25f53..be45988 100644 --- a/README.yaml +++ b/README.yaml @@ -64,6 +64,26 @@ references: url: "https://github.com/cloudposse/example-github-action-release-workflow" usage: | + ### Config + + The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. + The config should have the following structure: + + ```yaml + atmos-version: 1.45.3 + atmos-config-path: ./rootfs/usr/local/etc/atmos/ + terraform-state-bucket: cptest-core-ue2-auto-gitops + terraform-state-table: cptest-core-ue2-auto-gitops + terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha + terraform-plan-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + terraform-apply-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops + terraform-version: 1.5.2 + aws-region: us-east-2 + enable-infracost: false + sort-by: .stack_slug + group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") + ``` + ### GitHub Actions Workflow Example In following GitHub workflow example first job will filter components that have settings `github.actions_enabled: true` and then in following job `stack_slug` will be printed to stdout. @@ -97,6 +117,42 @@ usage: | echo "${{ matrix.stack_slug }}" ``` + ### Migrate from `v0` to `v1` + + `v1` replace `jq-query` input with `selected-filter` variable and simplify the query. + Now you need to specify only part used in select function of `jq-query`. + + `v1` moved variables from `inputs` to atmos gitops config path `./.github/config/atmos-gitops.yaml` + + | name | + |--------------------------| + | `atmos-version` | + | `atmos-config-path` | + + + If you want `v1` having the same behaviour as `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. + + ```yaml + - name: Selected Components + id: components + uses: cloudposse/github-action-atmos-terraform-select-components@v1 + with: + atmos-gitops-config-path: ./.github/config/atmos-gitops.yaml + select-filter: '.settings.github.actions_enabled // false' + ``` + + same behaviour as + + ```yaml + - name: Selected Components + id: components + uses: cloudposse/github-action-atmos-terraform-select-components@v0 + with: + atmos-config-path: "${{ github.workspace }}/rootfs/usr/local/etc/atmos/" + jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' + ``` + + include: contributors: @@ -105,4 +161,6 @@ contributors: - name: "Erik Osterman" github: "osterman" - name: "Daniel Miller" - github: "milldr" \ No newline at end of file + github: "milldr" + - name: "Igor Rodionov" + github: "goruha" \ No newline at end of file diff --git a/action.yml b/action.yml index c9f22e7..10db825 100644 --- a/action.yml +++ b/action.yml @@ -80,18 +80,18 @@ runs: env: ATMOS_CLI_CONFIG_PATH: ${{ steps.config.outputs.atmos-config-path }} JQUERY: | - with_entries(.value |= (.components.terraform)) | ## Deal with components type of terraform + with_entries(.value |= (.components.terraform)) | ## Deal with components type of terraform map_values(map_values(select(${{ inputs.select-filter }}))) | ## Filter components by enabled github actions - map_values(select(. != {})) | ## Skip stacks that have 0 selected components - map_values(. | keys) | ## Reduce to component names - with_entries( ## Construct component object + map_values(select(. != {})) | ## Skip stacks that have 0 selected components + map_values(. | keys) | ## Reduce to component names + with_entries( ## Construct component object .key as $stack | .value |= map({ "component": ., "stack": $stack, "stack_slug": [$stack, .] | join("-") }) - ) | map(.) | flatten ## Reduce to flat array + ) | map(.) | flatten ## Reduce to flat array run: | atmos describe stacks --format json | jq -ce "${JQUERY}" > components.json diff --git a/docs/github-action.md b/docs/github-action.md index 5db4999..c920330 100644 --- a/docs/github-action.md +++ b/docs/github-action.md @@ -4,13 +4,12 @@ | Name | Description | Default | Required | |------|-------------|---------|----------| -| atmos-config-path | The path to the atmos.yaml file | atmos.yaml | false | -| atmos-version | The version of atmos to install if install-atmos is true | latest | false | +| atmos-gitops-config-path | The path to the atmos-gitops.yaml file | ./.github/config/atmos-gitops.yaml | false | | debug | Enable action debug mode. Default: 'false' | false | false | -| default-branch | The default branch to use for the base ref. | ${{ github.event.repository.default\_branch }} | false | -| jq-query | jq query that will be used to select atmos components | N/A | true | +| head-ref | The head ref to checkout. If not provided, the head default branch is used. | ${{ github.sha }} | false | | jq-version | The version of jq to install if install-jq is true | 1.6 | false | -| terraform-version | The version of terraform to install if install-terraform is true | latest | false | +| nested-matrices-count | Matrices nested levels count (from 1 to 3) | 2 | false | +| select-filter | jq query that will be used to select atmos components | . | false | ## Outputs From cc9475a0f24686a34fca166d6395ade8ee056a02 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Sat, 9 Dec 2023 22:56:20 +0100 Subject: [PATCH 21/32] Update README --- README.md | 4 ++-- README.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3318034..428afb3 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ In following GitHub workflow example first job will filter components that have echo "${{ matrix.stack_slug }}" ``` -### Migrate from `v0` to `v1` +### Migrating from `v0` to `v1` `v1` replace `jq-query` input with `selected-filter` variable and simplify the query. Now you need to specify only part used in select function of `jq-query`. @@ -155,7 +155,7 @@ Now you need to specify only part used in select function of `jq-query`. | `atmos-config-path` | -If you want `v1` having the same behaviour as `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. +If you want the same behavior in `v1` as in`v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. ```yaml - name: Selected Components diff --git a/README.yaml b/README.yaml index be45988..de84cef 100644 --- a/README.yaml +++ b/README.yaml @@ -117,7 +117,7 @@ usage: | echo "${{ matrix.stack_slug }}" ``` - ### Migrate from `v0` to `v1` + ### Migrating from `v0` to `v1` `v1` replace `jq-query` input with `selected-filter` variable and simplify the query. Now you need to specify only part used in select function of `jq-query`. @@ -130,7 +130,7 @@ usage: | | `atmos-config-path` | - If you want `v1` having the same behaviour as `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. + If you want the same behavior in `v1` as in`v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. ```yaml - name: Selected Components From ab834c0db33c2307e061c7c1486be98ed415aef9 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Tue, 12 Dec 2023 03:59:10 +0300 Subject: [PATCH 22/32] Apply suggestions from code review Co-authored-by: Dan Miller --- README.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.yaml b/README.yaml index de84cef..8557472 100644 --- a/README.yaml +++ b/README.yaml @@ -130,7 +130,7 @@ usage: | | `atmos-config-path` | - If you want the same behavior in `v1` as in`v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. + If you want the same behavior in `v1` as in `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. ```yaml - name: Selected Components From 4e47d34f939e787a27009b7baf4139f2ecba6cac Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Tue, 12 Dec 2023 02:02:15 +0100 Subject: [PATCH 23/32] Update README --- README.md | 158 ++++++++++++++---------------------------------------- 1 file changed, 41 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index 428afb3..cb5698e 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,6 @@ GitHub Action that outputs list of Atmos components by jq query --- This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. -[][share_email] -[][share_googleplus] -[][share_facebook] -[][share_reddit] -[][share_linkedin] -[][share_twitter] - - It's 100% Open Source and licensed under the [APACHE2](LICENSE). @@ -83,8 +75,6 @@ Output of this action is a list of basic component information. For example: - - ## Usage @@ -155,7 +145,7 @@ Now you need to specify only part used in select function of `jq-query`. | `atmos-config-path` | -If you want the same behavior in `v1` as in`v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. +If you want the same behavior in `v1` as in `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. ```yaml - name: Selected Components @@ -185,15 +175,6 @@ same behaviour as - -## Share the Love - -Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/github-action-atmos-terraform-select-components)! (it helps us **a lot**) - -Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =) - - - ## Related Projects Check out these related projects. @@ -210,81 +191,70 @@ For additional context, refer to some of these links. - [example-github-action-release-workflow](https://github.com/cloudposse/example-github-action-release-workflow) - Example application with complicated release workflow -## Help - -**Got a question?** We got answers. +## ✨ Contributing -File a GitHub [issue](https://github.com/cloudposse/github-action-atmos-terraform-select-components/issues), send us an [email][email] or join our [Slack Community][slack]. +This project is under active development, and we encourage contributions from our community. +Many thanks to our outstanding contributors: -[![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] + + + -## DevOps Accelerator for Startups +### 🐛 Bug Reports & Feature Requests +Please use the [issue tracker](https://github.com/cloudposse/github-action-atmos-terraform-select-components/issues) to report any bugs or file feature requests. -We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us. +### 💻 Developing -[![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support] +If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. -Work directly with our team of DevOps experts via email, slack, and video conferencing. +In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. -We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet. + 1. **Fork** the repo on GitHub + 2. **Clone** the project to your own machine + 3. **Commit** changes to your own branch + 4. **Push** your work back up to your fork + 5. Submit a **Pull Request** so that we can review your changes -- **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. -- **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments. -- **Site Reliability Engineering.** You'll have total visibility into your apps and microservices. -- **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes. -- **GitOps.** You'll be able to operate your infrastructure via Pull Requests. -- **Training.** You'll receive hands-on training so your team can operate what we build. -- **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel. -- **Troubleshooting.** You'll get help to triage when things aren't working. -- **Code Reviews.** You'll receive constructive feedback on Pull Requests. -- **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects. +**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! -## Slack Community +### 🌎 Slack Community Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure. -## Discourse Forums - -Participate in our [Discourse Forums][discourse]. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account. - -## Newsletter +### 📰 Newsletter Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover. -## Office Hours +### 📆 Office Hours [Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone! -[![zoom](https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png")][office_hours] - -## Contributing - -### Bug Reports & Feature Requests +## About -Please use the [issue tracker](https://github.com/cloudposse/github-action-atmos-terraform-select-components/issues) to report any bugs or file feature requests. - -### Developing - -If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email]. - -In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. - - 1. **Fork** the repo on GitHub - 2. **Clone** the project to your own machine - 3. **Commit** changes to your own branch - 4. **Push** your work back up to your fork - 5. Submit a **Pull Request** so that we can review your changes - -**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request! +This project is maintained and funded by [Cloud Posse, LLC][website]. + +We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us. -## Copyright +[![Learn More](https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge)][commercial_support] -Copyright © 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright) +Work directly with our team of DevOps experts via email, slack, and video conferencing. +We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet. +- **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code. +- **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments. +- **Site Reliability Engineering.** You'll have total visibility into your apps and microservices. +- **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes. +- **GitOps.** You'll be able to operate your infrastructure via Pull Requests. +- **Training.** You'll receive hands-on training so your team can operate what we build. +- **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel. +- **Troubleshooting.** You'll get help to triage when things aren't working. +- **Code Reviews.** You'll receive constructive feedback on Pull Requests. +- **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects. +[![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link] ## License [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) @@ -310,48 +280,11 @@ specific language governing permissions and limitations under the License. ``` - - - - - - - - ## Trademarks All other trademarks referenced herein are the property of their respective owners. - -## About - -This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]! - -[![Cloud Posse][logo]][website] - -We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source]. - -We offer [paid support][commercial_support] on all of our projects. - -Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation. - - - -### Contributors - - -| [![Zinovii Dmytriv][zdmytriv_avatar]][zdmytriv_homepage]
[Zinovii Dmytriv][zdmytriv_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Daniel Miller][milldr_avatar]][milldr_homepage]
[Daniel Miller][milldr_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | -|---|---|---|---| - - - [zdmytriv_homepage]: https://github.com/zdmytriv - [zdmytriv_avatar]: https://img.cloudposse.com/150x150/https://github.com/zdmytriv.png - [osterman_homepage]: https://github.com/osterman - [osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png - [milldr_homepage]: https://github.com/milldr - [milldr_avatar]: https://img.cloudposse.com/150x150/https://github.com/milldr.png - [goruha_homepage]: https://github.com/goruha - [goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png - +--- +Copyright © 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright) [![README Footer][readme_footer_img]][readme_footer_link] [![Beacon][beacon]][website] @@ -362,12 +295,9 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply [jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=jobs [hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=hire [slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=slack - [linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=linkedin [twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=twitter - [testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=testimonial [office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=office_hours [newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=newsletter - [discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=discourse [email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=email [commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=commercial_support [we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=we_love_open_source @@ -378,11 +308,5 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply [readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=readme_footer_link [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-atmos-terraform-select-components&utm_content=readme_commercial_support_link - [share_twitter]: https://twitter.com/intent/tweet/?text=github-action-atmos-terraform-select-components&url=https://github.com/cloudposse/github-action-atmos-terraform-select-components - [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=github-action-atmos-terraform-select-components&url=https://github.com/cloudposse/github-action-atmos-terraform-select-components - [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/github-action-atmos-terraform-select-components - [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/github-action-atmos-terraform-select-components - [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/github-action-atmos-terraform-select-components - [share_email]: mailto:?subject=github-action-atmos-terraform-select-components&body=https://github.com/cloudposse/github-action-atmos-terraform-select-components [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/github-action-atmos-terraform-select-components?pixel&cs=github&cm=readme&an=github-action-atmos-terraform-select-components From f9ca38aa658a4db9fd1b7a0095dbfd06e0ef7763 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 13 Dec 2023 03:08:57 +0300 Subject: [PATCH 24/32] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 10db825..b7b572c 100644 --- a/action.yml +++ b/action.yml @@ -99,7 +99,7 @@ runs: echo "Selected components: $components" printf "%s" "components=$components" >> $GITHUB_OUTPUT - - uses: cloudposse/github-action-matrix-extended@incapsulate-jq + - uses: cloudposse/github-action-matrix-extended@v0 id: matrix with: matrix: components.json From a98b44e7afc25ca88931236aaf384f6a57ba3075 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 13 Dec 2023 16:51:07 +0100 Subject: [PATCH 25/32] Update README --- README.md | 8 ++++++-- README.yaml | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cb5698e..a2bd472 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,9 @@ Now you need to specify only part used in select function of `jq-query`. | `atmos-config-path` | -If you want the same behavior in `v1` as in `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. +For example, if you want the same behavior in `v1` as in `v0`, you should create the `./.github/config/atmos-gitops.yaml` config with the same variables as in `v1` inputs. + +In `v1`, the GItHub Action would invocation would look like this: ```yaml - name: Selected Components @@ -156,7 +158,7 @@ If you want the same behavior in `v1` as in `v0` you should create config `./.gi select-filter: '.settings.github.actions_enabled // false' ``` -same behaviour as +This is the same as the following `v0` configuration: ```yaml - name: Selected Components @@ -167,6 +169,8 @@ same behaviour as jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` +Please note that the atmos-gitops-config-path is not the same file as as the atmos-config-path. + diff --git a/README.yaml b/README.yaml index 8557472..5198545 100644 --- a/README.yaml +++ b/README.yaml @@ -130,7 +130,9 @@ usage: | | `atmos-config-path` | - If you want the same behavior in `v1` as in `v0` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v1` inputs. + For example, if you want the same behavior in `v1` as in `v0`, you should create the `./.github/config/atmos-gitops.yaml` config with the same variables as in `v1` inputs. + + In `v1`, the GItHub Action would invocation would look like this: ```yaml - name: Selected Components @@ -141,7 +143,7 @@ usage: | select-filter: '.settings.github.actions_enabled // false' ``` - same behaviour as + This is the same as the following `v0` configuration: ```yaml - name: Selected Components @@ -151,6 +153,8 @@ usage: | atmos-config-path: "${{ github.workspace }}/rootfs/usr/local/etc/atmos/" jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` + + Please note that the atmos-gitops-config-path is not the same file as as the atmos-config-path. include: From fa50260274fc7ed63044bfd68ef1e5a0eaa2d5f7 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 13 Dec 2023 16:54:38 +0100 Subject: [PATCH 26/32] Update README --- action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b7b572c..bfba471 100644 --- a/action.yml +++ b/action.yml @@ -47,7 +47,9 @@ runs: with: ref: ${{ inputs.head-ref }} - - name: config + - name: Read Atmos GitOps config + ## We have to reference cloudposse fork of https://github.com/blablacar/action-config-levels + ## before https://github.com/blablacar/action-config-levels/pull/16 would be merged uses: cloudposse/github-action-config-levels@nodejs20 id: config with: From 18e0fd70596d5e57c3e42b5c9086d865a1e5ddef Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 14 Dec 2023 22:23:23 +0300 Subject: [PATCH 27/32] Apply suggestions from code review Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- README.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.yaml b/README.yaml index 5198545..af565ee 100644 --- a/README.yaml +++ b/README.yaml @@ -66,8 +66,9 @@ references: usage: | ### Config - The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. - The config should have the following structure: + The action expects the Atmos GitOps configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. + + The config supports the following settings: ```yaml atmos-version: 1.45.3 @@ -83,7 +84,8 @@ usage: | sort-by: .stack_slug group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` - + [!IMPORTANT] + >**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. ### GitHub Actions Workflow Example In following GitHub workflow example first job will filter components that have settings `github.actions_enabled: true` and then in following job `stack_slug` will be printed to stdout. @@ -118,8 +120,8 @@ usage: | ``` ### Migrating from `v0` to `v1` - - `v1` replace `jq-query` input with `selected-filter` variable and simplify the query. + The major changes between versions `v0` and `v1` are as follows: + - `v1` replaced the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. Now you need to specify only part used in select function of `jq-query`. `v1` moved variables from `inputs` to atmos gitops config path `./.github/config/atmos-gitops.yaml` @@ -154,7 +156,7 @@ usage: | jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` - Please note that the atmos-gitops-config-path is not the same file as as the atmos-config-path. + Please note that the `atmos-gitops-config-path` is not the same file as the `atmos-config-path`. include: From bc4ddfe0982d8c80509e216e277e42a2b109b6ac Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 14 Dec 2023 22:27:33 +0300 Subject: [PATCH 28/32] Update README.yaml --- README.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.yaml b/README.yaml index af565ee..33bdaba 100644 --- a/README.yaml +++ b/README.yaml @@ -122,9 +122,9 @@ usage: | ### Migrating from `v0` to `v1` The major changes between versions `v0` and `v1` are as follows: - `v1` replaced the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. - Now you need to specify only part used in select function of `jq-query`. + Now you need to specify only the part used inside of the `select(...)` function of the `jq-query`. - `v1` moved variables from `inputs` to atmos gitops config path `./.github/config/atmos-gitops.yaml` + -`v1` moved parameters from the `inputs` to the Atmos GitOps config file, which defaults to `./.github/config/atmos-gitops.yaml` | name | |--------------------------| From 5188782ead83ba672cb2cf86493daa6caa93b038 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 14 Dec 2023 22:28:49 +0300 Subject: [PATCH 29/32] Update README.yaml --- README.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.yaml b/README.yaml index 33bdaba..4c115ab 100644 --- a/README.yaml +++ b/README.yaml @@ -122,7 +122,7 @@ usage: | ### Migrating from `v0` to `v1` The major changes between versions `v0` and `v1` are as follows: - `v1` replaced the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. - Now you need to specify only the part used inside of the `select(...)` function of the `jq-query`. + Now you need to specify only the part used inside of the `select(...)` function of the `jq-query`. -`v1` moved parameters from the `inputs` to the Atmos GitOps config file, which defaults to `./.github/config/atmos-gitops.yaml` @@ -169,4 +169,4 @@ contributors: - name: "Daniel Miller" github: "milldr" - name: "Igor Rodionov" - github: "goruha" \ No newline at end of file + github: "goruha" From 9b7acb935773c31b156349b814fd6de161000c85 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 14 Dec 2023 20:30:43 +0100 Subject: [PATCH 30/32] Update README --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a2bd472..9593e31 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,9 @@ Output of this action is a list of basic component information. For example: ### Config -The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. -The config should have the following structure: +The action expects the Atmos GitOps configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. + +The config supports the following settings: ```yaml atmos-version: 1.45.3 @@ -98,7 +99,8 @@ The config should have the following structure: sort-by: .stack_slug group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` - + [!IMPORTANT] + >**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. ### GitHub Actions Workflow Example In following GitHub workflow example first job will filter components that have settings `github.actions_enabled: true` and then in following job `stack_slug` will be printed to stdout. @@ -133,11 +135,11 @@ In following GitHub workflow example first job will filter components that have ``` ### Migrating from `v0` to `v1` +The major changes between versions `v0` and `v1` are as follows: +- `v1` replaced the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. + Now you need to specify only the part used inside of the `select(...)` function of the `jq-query`. -`v1` replace `jq-query` input with `selected-filter` variable and simplify the query. -Now you need to specify only part used in select function of `jq-query`. - -`v1` moved variables from `inputs` to atmos gitops config path `./.github/config/atmos-gitops.yaml` +-`v1` moved parameters from the `inputs` to the Atmos GitOps config file, which defaults to `./.github/config/atmos-gitops.yaml` | name | |--------------------------| @@ -169,7 +171,7 @@ This is the same as the following `v0` configuration: jq-query: 'to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",")' ``` -Please note that the atmos-gitops-config-path is not the same file as as the atmos-config-path. +Please note that the `atmos-gitops-config-path` is not the same file as the `atmos-config-path`. From 5996298c8800fddfadcb788409bf7ef6f7a1208f Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Fri, 15 Dec 2023 01:05:42 +0100 Subject: [PATCH 31/32] Fix README --- README.md | 25 ++++++++++++------------- README.yaml | 25 ++++++++++++------------- action.yml | 8 ++++---- docs/github-action.md | 4 ++-- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 9593e31..8b0dbab 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ GitHub Action that outputs list of Atmos components by jq query. For example following query will fetch components that have in settings set `github.actions_enabled: true`: ``` -to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",") +.value.settings.github.actions_enabled // false ``` Output of this action is a list of basic component information. For example: @@ -81,9 +81,8 @@ Output of this action is a list of basic component information. For example: ### Config -The action expects the Atmos GitOps configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. - -The config supports the following settings: +The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. +The config should have the following structure: ```yaml atmos-version: 1.45.3 @@ -99,8 +98,10 @@ The config supports the following settings: sort-by: .stack_slug group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` - [!IMPORTANT] - >**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. + +[!IMPORTANT] +>**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. + ### GitHub Actions Workflow Example In following GitHub workflow example first job will filter components that have settings `github.actions_enabled: true` and then in following job `stack_slug` will be printed to stdout. @@ -135,11 +136,11 @@ In following GitHub workflow example first job will filter components that have ``` ### Migrating from `v0` to `v1` -The major changes between versions `v0` and `v1` are as follows: -- `v1` replaced the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. + +1. `v1` replaces the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. Now you need to specify only the part used inside of the `select(...)` function of the `jq-query`. --`v1` moved parameters from the `inputs` to the Atmos GitOps config file, which defaults to `./.github/config/atmos-gitops.yaml` +2.`v1` moves most of the `inputs` to the Atmos GitOps config path `./.github/config/atmos-gitops.yaml`. Simply create this file, transfer your settings to it, then remove the corresponding arguments from your invocations of the `cloudposse/github-action-atmos-terraform-select-components` action. | name | |--------------------------| @@ -147,9 +148,7 @@ The major changes between versions `v0` and `v1` are as follows: | `atmos-config-path` | -For example, if you want the same behavior in `v1` as in `v0`, you should create the `./.github/config/atmos-gitops.yaml` config with the same variables as in `v1` inputs. - -In `v1`, the GItHub Action would invocation would look like this: +If you want the same behavior in `v2` as in `v1` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v0` inputs. ```yaml - name: Selected Components @@ -160,7 +159,7 @@ In `v1`, the GItHub Action would invocation would look like this: select-filter: '.settings.github.actions_enabled // false' ``` -This is the same as the following `v0` configuration: +Which would produce the same behavior as in `v2`, doing this: ```yaml - name: Selected Components diff --git a/README.yaml b/README.yaml index 4c115ab..5e882db 100644 --- a/README.yaml +++ b/README.yaml @@ -33,7 +33,7 @@ introduction: |- For example following query will fetch components that have in settings set `github.actions_enabled: true`: ``` - to_entries[] | .key as $parent | .value.components.terraform | to_entries[] | select(.value.settings.github.actions_enabled // false) | [$parent, .key] | join(",") + .value.settings.github.actions_enabled // false ``` Output of this action is a list of basic component information. For example: @@ -66,9 +66,8 @@ references: usage: | ### Config - The action expects the Atmos GitOps configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. - - The config supports the following settings: + The action expects the atmos gitops configuration file to be present in the repository in `./.github/config/atmos-gitops.yaml`. + The config should have the following structure: ```yaml atmos-version: 1.45.3 @@ -84,8 +83,10 @@ usage: | sort-by: .stack_slug group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` - [!IMPORTANT] - >**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. + + [!IMPORTANT] + >**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. + ### GitHub Actions Workflow Example In following GitHub workflow example first job will filter components that have settings `github.actions_enabled: true` and then in following job `stack_slug` will be printed to stdout. @@ -120,11 +121,11 @@ usage: | ``` ### Migrating from `v0` to `v1` - The major changes between versions `v0` and `v1` are as follows: - - `v1` replaced the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. + + 1. `v1` replaces the `jq-query` input parameter with a new parameter called `selected-filter` to simplify the query for end-users. Now you need to specify only the part used inside of the `select(...)` function of the `jq-query`. - -`v1` moved parameters from the `inputs` to the Atmos GitOps config file, which defaults to `./.github/config/atmos-gitops.yaml` + 2.`v1` moves most of the `inputs` to the Atmos GitOps config path `./.github/config/atmos-gitops.yaml`. Simply create this file, transfer your settings to it, then remove the corresponding arguments from your invocations of the `cloudposse/github-action-atmos-terraform-select-components` action. | name | |--------------------------| @@ -132,9 +133,7 @@ usage: | | `atmos-config-path` | - For example, if you want the same behavior in `v1` as in `v0`, you should create the `./.github/config/atmos-gitops.yaml` config with the same variables as in `v1` inputs. - - In `v1`, the GItHub Action would invocation would look like this: + If you want the same behavior in `v2` as in `v1` you should create config `./.github/config/atmos-gitops.yaml` with the same variables as in `v0` inputs. ```yaml - name: Selected Components @@ -145,7 +144,7 @@ usage: | select-filter: '.settings.github.actions_enabled // false' ``` - This is the same as the following `v0` configuration: + Which would produce the same behavior as in `v2`, doing this: ```yaml - name: Selected Components diff --git a/action.yml b/action.yml index bfba471..3b205d0 100644 --- a/action.yml +++ b/action.yml @@ -27,18 +27,18 @@ inputs: required: false nested-matrices-count: required: false - description: 'Matrices nested levels count (from 1 to 3)' + description: 'Number of nested matrices that should be returned as the output (from 1 to 3)' default: "2" outputs: selected-components: description: Selected GitOps components value: ${{ steps.selected-components.outputs.components }} - matrix: - description: Matrix for Selected GitOps components - value: ${{ steps.matrix.outputs.matrix }} has-selected-components: description: Whether there are selected components value: ${{ steps.selected-components.outputs.components != '[]' }} + matrix: + description: The selected components as matrix structure suitable for extending matrix size workaround (see README) + value: ${{ steps.matrix.outputs.matrix }} runs: using: "composite" diff --git a/docs/github-action.md b/docs/github-action.md index c920330..78f65a0 100644 --- a/docs/github-action.md +++ b/docs/github-action.md @@ -8,7 +8,7 @@ | debug | Enable action debug mode. Default: 'false' | false | false | | head-ref | The head ref to checkout. If not provided, the head default branch is used. | ${{ github.sha }} | false | | jq-version | The version of jq to install if install-jq is true | 1.6 | false | -| nested-matrices-count | Matrices nested levels count (from 1 to 3) | 2 | false | +| nested-matrices-count | Number of nested matrices that should be returned as the output (from 1 to 3) | 2 | false | | select-filter | jq query that will be used to select atmos components | . | false | @@ -17,6 +17,6 @@ | Name | Description | |------|-------------| | has-selected-components | Whether there are selected components | -| matrix | Matrix for Selected GitOps components | +| matrix | The selected components as matrix structure suitable for extending matrix size workaround (see README) | | selected-components | Selected GitOps components | From 96206101f995cc0847a0cdba3e0f33c1381ea9c4 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Fri, 15 Dec 2023 22:36:45 +0100 Subject: [PATCH 32/32] Added README --- README.md | 4 ++-- README.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8b0dbab..e3a8bf1 100644 --- a/README.md +++ b/README.md @@ -99,8 +99,8 @@ The config should have the following structure: group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` -[!IMPORTANT] ->**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. +> [!IMPORTANT] +> **Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. ### GitHub Actions Workflow Example diff --git a/README.yaml b/README.yaml index 5e882db..d3f7c78 100644 --- a/README.yaml +++ b/README.yaml @@ -84,8 +84,8 @@ usage: | group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-") ``` - [!IMPORTANT] - >**Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. + > [!IMPORTANT] + > **Please note!** the `terraform-state-*` parameters refer to the S3 Bucket and corresponding meta storage DynamoDB table used to store the Terraform Plan files, and not the "Terraform State". These parameters will be renamed in a subsequent release. ### GitHub Actions Workflow Example