-
Notifications
You must be signed in to change notification settings - Fork 181
148 lines (128 loc) · 5.65 KB
/
graphql-api-fuzzer.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: GraphQL API Fuzz Test
on:
workflow_dispatch:
# schedule:
# - cron: "15 4 3 * *" # Run at 4:15am on the 3rd of every month
pull_request:
paths:
- '.github/workflows/graphql-api-fuzzer.yml'
- 'setup/fuzzer-graphql/**/*'
- 'setup/fuzzer/docker-compose-speckle.yml'
- 'setup/fuzzer/speckle.backup.sql'
env:
PYTHON_VERSION: '3.12'
GRAPHQLER_VERSION: '2.3.6'
jobs:
graphql-fuzzer:
name: Fuzz test speckle-server Graphql API
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
name: Checkout speckle-server
with:
path: 'speckle-server'
- uses: actions/checkout@v4
name: Checkout Graphqler Fuzzer
with:
repository: omar2535/GraphQLer
ref: V${{ env.GRAPHQLER_VERSION }}
path: 'graphqler-fuzzer' # The path to clone the repository within the {{ github.workspace }} directory
- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
cache-dependency-path: ${{ github.workspace }}/graphqler-fuzzer/poetry.lock
- name: Install dependencies with Poetry
working-directory: ${{ github.workspace }}/graphqler-fuzzer
run: |
poetry install
- name: Deploy dependencies (docker compose)
run: |
docker compose --file ${{ github.workspace }}/speckle-server/docker-compose-deps.yml up --detach
- name: Seed the database
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
PGPASSWORD=speckle psql -h 127.0.0.1 -U speckle -d speckle -p 5432 -w < ${{ github.workspace }}/speckle-server/setup/fuzzer/speckle.backup.sql
- name: Deploy speckle-server (docker compose)
working-directory: ${{ github.workspace }}
timeout-minutes: 1
run: |
docker compose --file ${{ github.workspace }}/speckle-server/setup/fuzzer/docker-compose-speckle.yml up --detach
- name: Restore cached Graphqler configuration
id: cache-config-restore
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/graphqlerConfig
key: graphqler-config-${{ github.sha }}
- name: Generate Graphqler config from Graphql server
if: steps.cache-config-restore.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}/graphqler-fuzzer
run: |
poetry run python ./graphqler --mode compile --url http://127.0.0.1:3000/graphql --path ${{ github.workspace }}/graphqlerOutput
- name: Print the Graphqler configuration
run: |
ls -la ${{ github.workspace }} || true
ls -la ${{ github.workspace }}/graphqlerOutput || true
ls -la ${{ github.workspace }}/graphqlerOutput/compiled || true
# echo ""
# echo "############################################"
# echo "# Engine settings #"
# echo "# To customize, copy and save this file to #"
# echo "# setup/fuzzer/settings.graphqler.json #"
# echo "############################################"
# echo ""
# cat ${{ github.workspace }}/graphqlerOutput/compiled/engine_settings.json
- name: Save Graphqler Config
if: steps.cache-config-restore.outputs.cache-hit != 'true'
id: cache-config-save
uses: actions/cache/save@v4
with:
path: |
${{ github.workspace }}/graphqlerOutput
key: ${{ steps.cache-config-restore.outputs.cache-primary-key }}
- name: Run Graphqler fuzz test
working-directory: ${{ github.workspace }}/graphqler-fuzzer
run: |
until curl --output /dev/null --silent --head --fail http://127.0.0.1:3000/readiness; do
echo "Waiting a further 3 seconds for speckle-server to start..."
sleep 3
done
poetry run python ./graphqler --mode fuzz --url http://127.0.0.1:3000/graphql --path ${{ github.workspace }}/graphqlerOutput --auth 'Bearer 103b2cf86168ec87fc6ec88978455667feb0f08d12' --config ${{ github.workspace }}/speckle-server/setup/fuzzer/config.graphqler.toml
- name: Print the results
if: always()
run: |
ls -la ${{ github.workspace }}/graphqlerOutput
ls -la ${{ github.workspace }}/graphqlerOutput/logs || true
echo ""
echo "############################################"
echo "# Status.txt #"
echo "############################################"
echo ""
cat ${{ github.workspace }}/graphqlerOutput/stats.txt || true
echo ""
echo "############################################"
echo "# ./logs/fuzzer.log #"
echo "############################################"
echo ""
cat ${{ github.workspace }}/logs/fuzzer.log || true
- uses: actions/upload-artifact@v4
name: Store the Test output
if: always()
with:
name: fuzz-test-graphql-api-output
path: ${{ github.workspace }}/graphqlerOutput
if-no-files-found: error
retention-days: 5
overwrite: true
- name: Print Docker Compose logs
if: always()
run: |
docker compose --file ${{ github.workspace }}/speckle-server/docker-compose-deps.yml logs
docker compose --file ${{ github.workspace }}/speckle-server/setup/fuzzer/docker-compose-speckle.yml logs