-
Notifications
You must be signed in to change notification settings - Fork 12
66 lines (54 loc) · 1.68 KB
/
coverage.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
name: "Unit/Coverage Tests"
on: pull_request_target
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.23
- name: Setup API Key
run: |
KEY=$(echo -n '${{ secrets.VULTR_API_KEY }}' | base64)
cat << EOF > testdata/vultr/api-key.yaml
apiVersion: v1
kind: Secret
metadata:
name: vultr-credentials
type: Opaque
data:
apiKey: "${KEY}"
EOF
- name: Run unit tests and coverage test
id: test-coverage
run: |
TEST_ZONE_NAME=vultr-testing-os.com. make test > output.txt
- name: Transform output
id: results
if: always()
run: |
CONTENT=$(tail output.txt)
CONTENT="${CONTENT//'%'/'%25'}"
CONTENT="${CONTENT//$'\n'/'%0A'}"
CONTENT="${CONTENT//$'\r'/'%0D'}"
echo "::set-output name=content::$CONTENT"
- name: Add Comment
uses: actions/github-script@v5
if: always()
with:
script: |
const output = `### Unit Tests and Coverage Results
<details><summary>Show Output</summary>
\`\`\`
${{ steps.results.outputs.content }}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})