-
Notifications
You must be signed in to change notification settings - Fork 42
125 lines (102 loc) · 3.97 KB
/
scale-test.yaml
File metadata and controls
125 lines (102 loc) · 3.97 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: scale-test
on:
issue_comment:
types: [created]
jobs:
scale-test:
if: github.event.comment.body == '/scale-test' && github.event.issue.pull_request != null
runs-on: ubuntu-24.04
steps:
- name: Check if Commenter is a Collaborator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENTER: ${{ github.event.comment.user.login }}
REPO: ${{ github.repository }}
run: |
PERMISSIONS=$(gh api repos/$REPO/collaborators/$COMMENTER/permission --jq '.permission')
echo "User Permission: $PERMISSIONS"
if [[ "$PERMISSIONS" != "admin" && "$PERMISSIONS" != "write" && "$PERMISSIONS" != "maintain" ]]; then
echo "❌ User does not have permission to trigger this action."
exit 1
fi
- name: Acknowledge Command
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
-f body="🛠️ Scale test has started! Follow the progress here: [Workflow Run]($COMMENT_URL)"
- name: Maximize build space
run: |
df -h
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
sudo rm -Rf ${JAVA_HOME_8_X64}
sudo rm -Rf ${JAVA_HOME_11_X64}
sudo rm -Rf ${JAVA_HOME_17_X64}
sudo rm -Rf ${RUBY_PATH}
df -h
- uses: actions/checkout@v5
with:
repository: "guacsec/trustify-scale-test-runs"
- run: |
mkdir report
mkdir baseline
- name: Provide baseline
run: |
cp publish/baseline.json baseline/
# 'rev' supports the PR number in https://github.com/guacsec/trustify-scale-test-runs/blob/main/Containerfile.trustify
# the PR number is stored in 'github.event.issue.number' when managing an 'issue_comment' event as reported in
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#issue_comment-on-issues-only-or-pull-requests-only
- name: Build Containers
run: |
docker compose -f compose.yaml build --build-arg rev=pr/${{ github.event.issue.number }}
- name: Run
run: |
docker compose -f compose.yaml run loadtests
- if: always()
run: |
docker compose -f compose.yaml logs > containers.log
- name: Cleanup
if: always()
run: |
docker compose -f compose.yaml down
- name: Upload container logs
uses: actions/upload-artifact@v7
if: always()
with:
name: logs
path: |
containers.log
if-no-files-found: error
- name: Upload report
uses: actions/upload-artifact@v7
if: success()
with:
name: report
path: |
report/report.html
report/report.json
report/report.md
if-no-files-found: error
- name: Get Artifact Page URL
id: artifact-url
run: |
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
echo "artifact_url=$ARTIFACT_URL" >> $GITHUB_ENV
- name: Post comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT_BODY=$(cat <<__EOF__
<details><summary>Goose Report</summary>
$(cat report/report.md)
</details>
📄 **[Full Report](${{ env.artifact_url }})** (Go to "Artifacts" and download **report**)
__EOF__
)
gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
-f body="$COMMENT_BODY"