From 968f4e7baca9a94b55b2cbbd220232d926d22ae5 Mon Sep 17 00:00:00 2001 From: shanye Date: Mon, 7 Jul 2025 17:11:59 +0800 Subject: [PATCH] CI: support test for tech-solution --- .github/workflows/e2e.yml | 28 ++++++++++--------- scripts/doc-generate.sh | 9 ++++-- {solutions => solution}/CONTRIBUTE.md | 0 {solutions => solution}/README.md | 0 .../cloud-native/README.md | 0 .../cloud-native/function-compute/README.md | 0 .../cloud-native/kubernetes/README.md | 0 {solutions => solution}/landingzone/README.md | 0 .../landingzone/automation/README.md | 0 .../landingzone/security/README.md | 0 .../well-architect-framework/README.md | 0 tech-solution/solution-example/README.md | 25 +++++++++++++++++ tech-solution/solution-example/main.tf | 15 ++++++++++ 13 files changed, 62 insertions(+), 15 deletions(-) rename {solutions => solution}/CONTRIBUTE.md (100%) rename {solutions => solution}/README.md (100%) rename {solutions => solution}/cloud-native/README.md (100%) rename {solutions => solution}/cloud-native/function-compute/README.md (100%) rename {solutions => solution}/cloud-native/kubernetes/README.md (100%) rename {solutions => solution}/landingzone/README.md (100%) rename {solutions => solution}/landingzone/automation/README.md (100%) rename {solutions => solution}/landingzone/security/README.md (100%) rename {solutions => solution}/well-architect-framework/README.md (100%) create mode 100644 tech-solution/solution-example/README.md create mode 100644 tech-solution/solution-example/main.tf diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 5d1a03839b..bfa69ff5a2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -7,42 +7,42 @@ on: types: [ 'opened', 'synchronize' ] paths: - '.github/**' - - '.github/workflows/**' - 'quickstarts/**' + - 'tech-solution/**' jobs: terraform-fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: hashicorp/setup-terraform@v3 - - name: Terraform fmt id: fmt - run: terraform -chdir=quickstarts fmt -check -recursive + run: | + terraform -chdir=quickstarts fmt -check -recursive + terraform -chdir=tech-solution fmt -check -recursive terraform-validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: hashicorp/setup-terraform@v3 - - name: Get changed files id: changed-files uses: tj-actions/changed-files@v34 with: dir_names: "true" separator: "," - files: "quickstarts/*" + files: | + quickstarts/* + tech-solution/* dir_names_max_depth: 3 - - name: pr-check + - name: Terraform validate run: | CHANGED_FOLDERS="${{ steps.changed-files.outputs.all_changed_files }}" if [ -z "$CHANGED_FOLDERS" ]; then - echo "No changed quickstarts found" + echo "No changed terraform code found" exit 0 fi @@ -54,7 +54,7 @@ jobs: terraform -chdir=$f init -upgrade terraform -chdir=$f validate if [[ $? -ne 0 ]]; then - echo -e "\033[31m[ERROR]\033[0m: Some quickstarts codes contain errors, and please running terraform validate command before pushing." + echo -e "\033[31m[ERROR]\033[0m: Some terraform codes contain errors, and please running terraform validate command before pushing." exit 1 fi done @@ -63,7 +63,7 @@ jobs: e2e-check: needs: [terraform-fmt, terraform-validate] runs-on: ubuntu-latest - name: 'e2e check' + name: e2e check steps: - name: checkout uses: actions/checkout@v3 @@ -80,7 +80,9 @@ jobs: with: dir_names: "true" separator: "," - files: "quickstarts/*" + files: | + quickstarts/* + tech-solution/* dir_names_max_depth: 3 - name: set id id: set-job-id @@ -98,7 +100,7 @@ jobs: run: | CHANGED_FOLDERS="${{ steps.changed-files.outputs.all_changed_files }}" if [ -z "$CHANGED_FOLDERS" ]; then - echo "No changed quickstarts found" + echo "No changed terraform code found" exit 0 fi objectPath="github-action/${{github.repository}}/e2e/Action-${{github.run_number}}-${{github.run_id}}-${{ steps.set-job-id.outputs.jobId }}" diff --git a/scripts/doc-generate.sh b/scripts/doc-generate.sh index fb71f302e4..b9eb257d96 100755 --- a/scripts/doc-generate.sh +++ b/scripts/doc-generate.sh @@ -2,11 +2,14 @@ if [ $# -eq 0 ];then exampleDir=$(find ./quickstarts -maxdepth 2 -mindepth 2 -type d) - # echo $exampleDir - for file in $exampleDir;do + techSolutionDir=$(find ./tech-solution -maxdepth 1 -mindepth 1 -type d) + all_dirs="$exampleDir $techSolutionDir" + # echo $all_dirs + for file in $all_dirs;do # echo $file if [ -f $file/"main.tf" ];then terraform-docs $file -c scripts/.terraform-docs.yml + sed -i '' 's|https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/|https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/|g' $file/README.md terraform fmt $file fi done @@ -15,12 +18,14 @@ else do if [ -f $arg/"main.tf" ];then terraform-docs $arg -c scripts/.terraform-docs.yml + sed -i '' 's|https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/|https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/|g' $arg/README.md terraform fmt $file else exampleDir=$(find $arg -maxdepth 2 -mindepth 1 -type d) for file in $exampleDir;do if [ -f $file/"main.tf" ];then terraform-docs $file -c scripts/.terraform-docs.yml + sed -i '' 's|https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/|https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/|g' $file/README.md terraform fmt $file fi done diff --git a/solutions/CONTRIBUTE.md b/solution/CONTRIBUTE.md similarity index 100% rename from solutions/CONTRIBUTE.md rename to solution/CONTRIBUTE.md diff --git a/solutions/README.md b/solution/README.md similarity index 100% rename from solutions/README.md rename to solution/README.md diff --git a/solutions/cloud-native/README.md b/solution/cloud-native/README.md similarity index 100% rename from solutions/cloud-native/README.md rename to solution/cloud-native/README.md diff --git a/solutions/cloud-native/function-compute/README.md b/solution/cloud-native/function-compute/README.md similarity index 100% rename from solutions/cloud-native/function-compute/README.md rename to solution/cloud-native/function-compute/README.md diff --git a/solutions/cloud-native/kubernetes/README.md b/solution/cloud-native/kubernetes/README.md similarity index 100% rename from solutions/cloud-native/kubernetes/README.md rename to solution/cloud-native/kubernetes/README.md diff --git a/solutions/landingzone/README.md b/solution/landingzone/README.md similarity index 100% rename from solutions/landingzone/README.md rename to solution/landingzone/README.md diff --git a/solutions/landingzone/automation/README.md b/solution/landingzone/automation/README.md similarity index 100% rename from solutions/landingzone/automation/README.md rename to solution/landingzone/automation/README.md diff --git a/solutions/landingzone/security/README.md b/solution/landingzone/security/README.md similarity index 100% rename from solutions/landingzone/security/README.md rename to solution/landingzone/security/README.md diff --git a/solutions/well-architect-framework/README.md b/solution/well-architect-framework/README.md similarity index 100% rename from solutions/well-architect-framework/README.md rename to solution/well-architect-framework/README.md diff --git a/tech-solution/solution-example/README.md b/tech-solution/solution-example/README.md new file mode 100644 index 0000000000..01c8dc5340 --- /dev/null +++ b/tech-solution/solution-example/README.md @@ -0,0 +1,25 @@ +## Introduction + + +## Providers + +| Name | Version | +|------|---------| +| [alicloud](#provider\_alicloud) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [alicloud_vpc.foo](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vpc) | resource | +| [alicloud_vswitch.foo](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/vswitch) | resource | +| [alicloud_zones.foo](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/zones) | data source | + +## Inputs + +No inputs. + \ No newline at end of file diff --git a/tech-solution/solution-example/main.tf b/tech-solution/solution-example/main.tf new file mode 100644 index 0000000000..b311063373 --- /dev/null +++ b/tech-solution/solution-example/main.tf @@ -0,0 +1,15 @@ +data "alicloud_zones" "foo" { + available_resource_creation = "VSwitch" +} + +resource "alicloud_vpc" "foo" { + vpc_name = "terraform-example" + cidr_block = "172.16.0.0/12" +} + +resource "alicloud_vswitch" "foo" { + vswitch_name = "terraform-example" + cidr_block = "172.16.0.0/21" + vpc_id = alicloud_vpc.foo.id + zone_id = data.alicloud_zones.foo.zones.0.id +} \ No newline at end of file