Skip to content

Commit 89db8ce

Browse files
committed
ci: support e2e test
1 parent e88f2c3 commit 89db8ce

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.github/workflows/e2e.yaml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: E2E Test Check
2+
on:
3+
pull_request:
4+
types: ['opened', 'synchronize']
5+
paths:
6+
- '.github/**'
7+
- '.github/workflows/**'
8+
- 'quickstarts/**'
9+
10+
jobs:
11+
e2e-check:
12+
runs-on: terraform-alicloud-landing
13+
environment:
14+
name: acctests
15+
steps:
16+
- name: checkout
17+
uses: actions/checkout@v3
18+
- name: Get changed files
19+
id: changed-files
20+
uses: tj-actions/changed-files@v34
21+
with:
22+
dir_names: "true"
23+
separator: ","
24+
files: "quickstarts/*"
25+
files_ignore: "**/TestRecord.md"
26+
dir_names_max_depth: 2
27+
- name: test pr
28+
run: |
29+
folders="${{ steps.changed-files.outputs.all_changed_files }}"
30+
for f in ${folders//,/ }
31+
do
32+
f=$(echo $f | xargs echo -n)
33+
echo "===> Terraform testing in" $f
34+
terraform -chdir=$f init -upgrade
35+
cp scripts/plan.tftest.hcl $f/
36+
terraform -chdir=$f test test -verbose
37+
if [[ $? -ne 0 ]]; then
38+
echo -e "\033[31m[ERROR]\033[0m: running terraform test for plan failed."
39+
#exit 1
40+
else
41+
rm -rf scripts/plan.tftest.hcl
42+
cp scripts/apply.tftest.hcl $f/
43+
terraform -chdir=$f test test
44+
if [[ $? -ne 0 ]]; then
45+
echo -e "\033[31m[ERROR]\033[0m: running terraform test for apply failed."
46+
#exit 1
47+
fi
48+
rm -rf scripts/apply.tftest.hcl
49+
fi
50+
done

scripts/apply.tftest.hcl

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
run "apply" {
2+
command = apply
3+
}

scripts/plan.tftest.hcl

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
run "plan" {
2+
command = plan
3+
}

0 commit comments

Comments
 (0)