Skip to content

Commit

Permalink
Merge branch 'main' into chore/action/reduce-installs
Browse files Browse the repository at this point in the history
  • Loading branch information
dudymas authored Mar 19, 2024
2 parents 31d7904 + c4987d2 commit 0dfe754
Show file tree
Hide file tree
Showing 21 changed files with 592 additions and 365 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,19 @@ jobs:
- shell: bash
run: |
mkdir -p ${{ runner.temp }}
cat > ${{ runner.temp }}/atmos-gitops.yaml <<EOL
atmos-version: 1.45.3
atmos-config-path: ./tests/
terraform-state-bucket: ${{ secrets.TERRAFORM_STATE_BUCKET }}
terraform-state-table: ${{ secrets.TERRAFORM_STATE_TABLE }}
terraform-state-role: ${{ secrets.TERRAFORM_STATE_ROLE }}
terraform-plan-role: ${{ secrets.TERRAFORM_PLAN_ROLE }}
terraform-version: 1.5.2
aws-region: ${{ env.AWS_REGION }}
sort-by: .stack_slug
group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-")
EOL
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__INFRACOST_ENABLED__#false#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_REGION__#${{ env.AWS_REGION }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_BUCKET__#${{ secrets.TERRAFORM_STATE_BUCKET }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_ROLE__#${{ secrets.TERRAFORM_STATE_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__APPLY_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
- name: Plan Atmos Component
uses: ./
with:
component: "foobar"
stack: "plat-ue2-sandbox"
atmos-gitops-config-path: "${{ runner.temp }}/atmos-gitops.yaml"
atmos-config-path: ${{ runner.temp }}
47 changes: 23 additions & 24 deletions .github/workflows/test-changes-exists-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ jobs:
- shell: bash
run: |
mkdir -p ${{ runner.temp }}
cat > ${{ runner.temp }}/atmos-gitops.yaml <<EOL
atmos-version: 1.45.3
atmos-config-path: ./tests/
terraform-state-bucket: ${{ secrets.TERRAFORM_STATE_BUCKET }}
terraform-state-table: ${{ secrets.TERRAFORM_STATE_TABLE }}
terraform-state-role: ${{ secrets.TERRAFORM_STATE_ROLE }}
terraform-plan-role: ${{ secrets.TERRAFORM_PLAN_ROLE }}
terraform-version: 1.5.2
aws-region: ${{ env.AWS_REGION }}
sort-by: .stack_slug
group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-")
EOL
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__INFRACOST_ENABLED__#false#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_REGION__#${{ env.AWS_REGION }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_BUCKET__#${{ secrets.TERRAFORM_STATE_BUCKET }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_ROLE__#${{ secrets.TERRAFORM_STATE_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__APPLY_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
- name: Plan Atmos Component
id: current
Expand All @@ -51,7 +49,8 @@ jobs:
stack: "plat-ue2-sandbox"
sha: da39a3ee5e6b4b0d3255bfef95601890afd80709
drift-detection-mode-enabled: true
atmos-gitops-config-path: "${{ runner.temp }}/atmos-gitops.yaml"
atmos-config-path: ${{ runner.temp }}
atmos-version: 1.63.0

outputs:
result: ${{ steps.current.outcome }}
Expand All @@ -61,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
expected: 'success'
actual: "${{ needs.test.outputs.result }}"
Expand Down Expand Up @@ -96,43 +95,43 @@ jobs:
echo files_json_count=$(ls -lA ./metadata/*.json | wc -l) >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.dir_exists }}"
expected: "0"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.file_exists }}"
expected: "0"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.file_md_exists }}"
expected: "0"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.file_summary_md_exists }}"
expected: "0"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
expected: "${{ fromJSON(steps.metadata.outputs.file_md) }}"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.files_json_count }}"
expected: "1"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ fromJSON(steps.metadata.outputs.file_json) }}"
expected: |
{ "stack": "plat-ue2-sandbox", "component": "foobar/changes", "componentPath": "tests/components/terraform/foobar", "drifted": true, "error": false }
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
expected: |
Expand Down Expand Up @@ -163,7 +162,7 @@ jobs:
---
### <a id="create-plat-ue2-sandbox-foobar_changes" />Create
```diff
+ random_id.foo
+ random_id.foo[0]
```
</details>
Expand All @@ -173,7 +172,7 @@ jobs:
```hcl
# random_id.foo will be created
# random_id.foo[0] will be created
+ resource "random_id" "foo" {
+ b64_std = (known after apply)
+ b64_url = (known after apply)
Expand Down
34 changes: 16 additions & 18 deletions .github/workflows/test-changes-exists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ jobs:
- shell: bash
run: |
mkdir -p ${{ runner.temp }}
cat > ${{ runner.temp }}/atmos-gitops.yaml <<EOL
atmos-version: 1.45.3
atmos-config-path: ./tests/
terraform-state-bucket: ${{ secrets.TERRAFORM_STATE_BUCKET }}
terraform-state-table: ${{ secrets.TERRAFORM_STATE_TABLE }}
terraform-state-role: ${{ secrets.TERRAFORM_STATE_ROLE }}
terraform-plan-role: ${{ secrets.TERRAFORM_PLAN_ROLE }}
terraform-version: 1.5.2
aws-region: ${{ env.AWS_REGION }}
sort-by: .stack_slug
group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-")
EOL
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__INFRACOST_ENABLED__#false#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_REGION__#${{ env.AWS_REGION }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_BUCKET__#${{ secrets.TERRAFORM_STATE_BUCKET }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_ROLE__#${{ secrets.TERRAFORM_STATE_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__APPLY_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
- name: Plan Atmos Component
id: current
Expand All @@ -50,7 +47,8 @@ jobs:
component: "foobar/changes"
stack: "plat-ue2-sandbox"
sha: da39a3ee5e6b4b0d3255bfef95601890afd80709
atmos-gitops-config-path: "${{ runner.temp }}/atmos-gitops.yaml"
atmos-config-path: ${{ runner.temp }}
atmos-version: 1.63.0

outputs:
result: ${{ steps.current.outcome }}
Expand All @@ -60,7 +58,7 @@ jobs:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
expected: 'success'
actual: "${{ needs.test.outputs.result }}"
Expand All @@ -74,12 +72,12 @@ jobs:
DIR_EXISTS=$?
echo "dir_exists=${DIR_EXISTS}" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.dir_exists }}"
expected: "1"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
expected: |
Expand All @@ -105,7 +103,7 @@ jobs:
---
### <a id="create-plat-ue2-sandbox-foobar_changes" />Create
```diff
+ random_id.foo
+ random_id.foo[0]
```
</details>
Expand All @@ -114,7 +112,7 @@ jobs:
```hcl
# random_id.foo will be created
# random_id.foo[0] will be created
+ resource "random_id" "foo" {
+ b64_std = (known after apply)
+ b64_url = (known after apply)
Expand Down
43 changes: 21 additions & 22 deletions .github/workflows/test-failed-plan-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ jobs:
- shell: bash
run: |
mkdir -p ${{ runner.temp }}
cat > ${{ runner.temp }}/atmos-gitops.yaml <<EOL
atmos-version: 1.45.3
atmos-config-path: ./tests/
terraform-state-bucket: ${{ secrets.TERRAFORM_STATE_BUCKET }}
terraform-state-table: ${{ secrets.TERRAFORM_STATE_TABLE }}
terraform-state-role: ${{ secrets.TERRAFORM_STATE_ROLE }}
terraform-plan-role: ${{ secrets.TERRAFORM_PLAN_ROLE }}
terraform-version: 1.5.2
aws-region: ${{ env.AWS_REGION }}
sort-by: .stack_slug
group-by: .stack_slug | split("-") | [.[0], .[2]] | join("-")
EOL
cp ./tests/atmos.yaml ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__INFRACOST_ENABLED__#false#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_REGION__#${{ env.AWS_REGION }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_BUCKET__#${{ secrets.TERRAFORM_STATE_BUCKET }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_TABLE__#${{ secrets.TERRAFORM_STATE_TABLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__STORAGE_ROLE__#${{ secrets.TERRAFORM_STATE_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__PLAN_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
sed -i -e 's#__APPLY_ROLE__#${{ secrets.TERRAFORM_PLAN_ROLE }}#g' ${{ runner.temp }}/atmos.yaml
- name: Plan Atmos Component
id: current
Expand All @@ -51,7 +49,8 @@ jobs:
stack: "plat-ue2-sandbox"
sha: da39a3ee5e6b4b0d3255bfef95601890afd80709
drift-detection-mode-enabled: true
atmos-gitops-config-path: "${{ runner.temp }}/atmos-gitops.yaml"
atmos-config-path: ${{ runner.temp }}
atmos-version: 1.63.0

outputs:
result: ${{ steps.current.outcome }}
Expand All @@ -61,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
expected: 'failure'
actual: "${{ needs.test.outputs.result }}"
Expand Down Expand Up @@ -90,33 +89,33 @@ jobs:
echo "file_json=$(cat ./metadata/plat-ue2-sandbox-foobar-fail.metadata.json | jq -Rs . )" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.dir_exists }}"
expected: "0"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.file_exists }}"
expected: "0"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ steps.metadata.outputs.file_md_exists }}"
expected: "0"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
expected: "${{ fromJSON(steps.metadata.outputs.file_md) }}"

- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ fromJSON(steps.metadata.outputs.file_json) }}"
expected: |
{ "stack": "plat-ue2-sandbox", "component": "foobar-fail", "componentPath": "tests/components/terraform/foobar", "drifted": false, "error": true }
- uses: nick-fields/assert-action@v1
- uses: nick-fields/assert-action@v2
with:
actual: "${{ fromJSON(needs.test.outputs.summary) }}"
expected: |
Expand Down Expand Up @@ -147,8 +146,8 @@ jobs:
```hcl
Error: Invalid function argument
on main.tf line 16, in locals:
16: failure = var.enable_failure ? file("Failed because failure mode is enabled") : null
on main.tf line 17, in locals:
17: failure = var.enabled && var.enable_failure ? file("Failed because failure mode is enabled") : null
├────────────────
│ while calling file(path)
Expand Down
Loading

0 comments on commit 0dfe754

Please sign in to comment.