-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (78 loc) · 2.85 KB
/
testacc.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Acceptance Tests
on:
issue_comment:
types: [created]
jobs:
slashCommand:
name: SlashCommand
runs-on: ubuntu-latest
if: (github.event.issue.author_association == 'MEMBER') &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/testacc ')
steps:
- name: Extract Command
id: command
uses: xt0rted/slash-command-action@v2
with:
repo-token: ${{ secrets.TESTACC_PAT }}
command: testacc
reaction: "true"
reaction-type: "rocket"
allow-edits: "false"
permission-level: write
test:
name: Terraform Provider Acceptance Tests
needs: slashCommand
runs-on: ubuntu-latest
timeout-minutes: 35
steps:
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.3.*
terraform_wrapper: false
- run: go mod download
- name : Run Terraform Acceptance Tests
env:
TF_ACC: "1"
CLOUDAVENUE_ORG: ${{ secrets.CLOUDAVENUE_ORG }}
CLOUDAVENUE_USER: ${{ secrets.CLOUDAVENUE_USER }}
CLOUDAVENUE_PASSWORD: ${{ secrets.CLOUDAVENUE_PASSWORD }}
CLOUDAVENUE_URL : ${{ secrets.CLOUDAVENUE_URL }}
CLOUDAVENUE_VDC : ${{ secrets.CLOUDAVENUE_VDC }}
run: |
TEST_NAME=$(echo "${{ github.event.comment.body }}" | cut -d " " -f2)
CATEGORY=$(grep -rilE "$TEST_NAME" * | sed 's![^/]*$!!' | head -1)
if [ -d "$CATEGORY" ]; then
go test -timeout 30m -v ./$CATEGORY -run $TEST_NAME > 'test_output.txt'
else
echo "[no tests to run]" > 'test_output.txt'
fi
timeout-minutes: 30
- name: Comment PR with test results
uses: actions/[email protected]
if: always() # This ensures the step always runs, even if the test step failed
with:
github-token: ${{ secrets.TESTACC_PAT }}
script: |
const fs = require('fs');
let output = fs.readFileSync('test_output.txt', 'utf8'); // Read the test output file
let comment = "";
if (output.includes('[no tests to run]')) {
comment = "Ressource not found, please check the name of the ressource";
} else if (output.includes('--- PASS')) {
comment = "## :rocket: Acceptance Test passed \n\n" + output;
} else {
comment = "## :bangbang: Acceptance Test failed \n\n" + output;
}
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});