12
12
description : The LAPI client json to use
13
13
required : true
14
14
default : ' ["main","crowdsecurity/php-lapi-client"]'
15
+ capi_client_json :
16
+ type : string
17
+ description : The CAPI client json to use
18
+ required : true
19
+ default : ' ["main","crowdsecurity/php-capi-client"]'
15
20
remediation_engine_json :
16
21
type : string
17
22
description : The Remediation Engine json to use
37
42
description : The LAPI client json to use
38
43
required : true
39
44
default : ' ["main"]'
45
+ capi_client_json :
46
+ type : string
47
+ description : The CAPI client json to use
48
+ required : true
49
+ default : ' ["main"]'
40
50
remediation_engine_json :
41
51
type : string
42
52
description : The Remediation Engine json to use
@@ -49,9 +59,16 @@ permissions:
49
59
env :
50
60
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
51
61
DDEV_GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
62
+ STANDALONE_BOUNCER_REPO : crowdsecurity/cs-standalone-php-bouncer
63
+ BOUNCER_LIB_REPO : crowdsecurity/php-cs-bouncer
64
+ REMEDIATION_ENGINE_REPO : crowdsecurity/php-remediation-engine
65
+ CAPI_CLIENT_REPO : crowdsecurity/php-capi-client
66
+ LAPI_CLIENT_REPO : crowdsecurity/php-lapi-client
67
+ PHP_COMMON_REPO : crowdsecurity/php-common
52
68
PHP_COMMON_JSON : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.php_common_json || inputs.php_common_json }}
53
69
LAPI_CLIENT_JSON : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.lapi_client_json || inputs.lapi_client_json }}
54
70
REMEDIATION_ENGINE_JSON : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.remediation_engine_json || inputs.remediation_engine_json }}
71
+ CAPI_CLIENT_JSON : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.capi_client_json || inputs.capi_client_json }}
55
72
56
73
jobs :
57
74
test-suite :
65
82
if : ${{ !contains(github.event.head_commit.message, 'chore(') }}
66
83
env :
67
84
EXTENSION_PATH : " my-code/crowdsec-bouncer-lib"
68
- BOUNCER_LIB_REPO : crowdsecurity/php-cs-bouncer
85
+ REMEDIATION_ENGINE_PATH : " my-code/php-remediation-engine"
86
+ CAPI_CLIENT_PATH : " my-code/php-capi-client"
87
+ LAPI_CLIENT_PATH : " my-code/php-lapi-client"
88
+ PHP_COMMON_PATH : " my-code/php-common"
69
89
DDEV_PROJECT : " crowdsec-bouncer-lib"
70
90
JP_TEST_IP : " 210.249.74.42"
71
91
IPV6_TEST_IP : " 2001:0db8:0000:85a3:0000:0000:ac1f:8001"
@@ -75,32 +95,39 @@ jobs:
75
95
- name : Set PHP common variables
76
96
id : set-common-data
77
97
run : |
78
- echo "major_tag=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/crowdsecurity/php-common/releases/latest | grep -oP "\/tag\/v\K(.*)$" | cut -d. -f1)" >> $GITHUB_OUTPUT
79
98
echo "branch=${{ fromJson(env.PHP_COMMON_JSON)[0] }}" >> $GITHUB_OUTPUT
80
99
if [ "${{ inputs.is_call }}" = "true" ]; then
81
- echo "repo=crowdsecurity/php-common " >> $GITHUB_OUTPUT
100
+ echo "repo=${{env.PHP_COMMON_REPO}} " >> $GITHUB_OUTPUT
82
101
else
83
102
echo "repo=${{ fromJson(env.PHP_COMMON_JSON)[1] }}" >> $GITHUB_OUTPUT
84
103
fi
85
104
86
105
- name : Set LAPI client variables
87
106
id : set-lapi-client-data
88
107
run : |
89
- echo "major_tag=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/crowdsecurity/php-lapi-client/releases/latest | grep -oP "\/tag\/v\K(.*)$" | cut -d. -f1)" >> $GITHUB_OUTPUT
90
108
echo "branch=${{ fromJson(env.LAPI_CLIENT_JSON)[0] }}" >> $GITHUB_OUTPUT
91
109
if [ "${{ inputs.is_call }}" = "true" ]; then
92
- echo "repo=crowdsecurity/php-lapi-client " >> $GITHUB_OUTPUT
110
+ echo "repo=${{env.LAPI_CLIENT_REPO}} " >> $GITHUB_OUTPUT
93
111
else
94
112
echo "repo=${{ fromJson(env.LAPI_CLIENT_JSON)[1] }}" >> $GITHUB_OUTPUT
95
113
fi
96
114
115
+ - name : Set CAPI client variables
116
+ id : set-capi-client-data
117
+ run : |
118
+ echo "branch=${{ fromJson(env.CAPI_CLIENT_JSON)[0] }}" >> $GITHUB_OUTPUT
119
+ if [ "${{ inputs.is_call }}" = "true" ]; then
120
+ echo "repo=${{env.CAPI_CLIENT_REPO}}" >> $GITHUB_OUTPUT
121
+ else
122
+ echo "repo=${{ fromJson(env.CAPI_CLIENT_JSON)[1] }}" >> $GITHUB_OUTPUT
123
+ fi
124
+
97
125
- name : Set Remediation engine variables
98
126
id : set-remediation-engine-data
99
127
run : |
100
- echo "major_tag=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/crowdsecurity/php-remediation-engine/releases/latest | grep -oP "\/tag\/v\K(.*)$" | cut -d. -f1)" >> $GITHUB_OUTPUT
101
128
echo "branch=${{ fromJson(env.REMEDIATION_ENGINE_JSON)[0] }}" >> $GITHUB_OUTPUT
102
129
if [ "${{ inputs.is_call }}" = "true" ]; then
103
- echo "repo=crowdsecurity/php-remediation-engine " >> $GITHUB_OUTPUT
130
+ echo "repo=${{env.REMEDIATION_ENGINE_REPO}} " >> $GITHUB_OUTPUT
104
131
else
105
132
echo "repo=${{ fromJson(env.REMEDIATION_ENGINE_JSON)[1] }}" >> $GITHUB_OUTPUT
106
133
fi
@@ -165,38 +192,67 @@ jobs:
165
192
with :
166
193
repository : ${{ steps.set-common-data.outputs.repo}}
167
194
ref : ${{ steps.set-common-data.outputs.branch }}
168
- path : my-code/php-common
195
+ path : ${{env.PHP_COMMON_PATH}}
169
196
170
- - name : Clone PHP LAPI client
197
+ - name : Clone LAPI client
171
198
uses : actions/checkout@v4
172
199
with :
173
200
repository : ${{ steps.set-lapi-client-data.outputs.repo }}
174
201
ref : ${{ steps.set-lapi-client-data.outputs.branch }}
175
- path : my-code/php-lapi-client
202
+ path : ${{env.LAPI_CLIENT_PATH}}
203
+
204
+ - name : Clone CAPI client
205
+ uses : actions/checkout@v4
206
+ with :
207
+ repository : ${{ steps.set-capi-client-data.outputs.repo }}
208
+ ref : ${{ steps.set-capi-client-data.outputs.branch }}
209
+ path : ${{env.CAPI_CLIENT_PATH}}
176
210
177
211
- name : Clone PHP remediation engine
178
212
uses : actions/checkout@v4
179
213
with :
180
214
repository : ${{ steps.set-remediation-engine-data.outputs.repo }}
181
215
ref : ${{ steps.set-remediation-engine-data.outputs.branch }}
182
- path : my-code/php-remediation-engine
216
+ path : ${{env.REMEDIATION_ENGINE_PATH}}
183
217
184
218
- name : Add local repositories to composer
185
219
run : |
220
+ # Bouncer lib
186
221
ddev exec --raw composer config repositories.0 '{"type": "path", "url": "../php-common", "options": {"symlink": true}}' --working-dir ./${{ env.EXTENSION_PATH }}
187
222
ddev exec --raw composer config repositories.1 '{"type": "path", "url": "../php-lapi-client", "options": {"symlink": true}}' --working-dir ./${{ env.EXTENSION_PATH }}
188
223
ddev exec --raw composer config repositories.2 '{"type": "path", "url": "../php-remediation-engine", "options": {"symlink": true}}' --working-dir ./${{ env.EXTENSION_PATH }}
224
+ ddev exec --raw composer config repositories.3 '{"type": "path", "url": "../php-capi-client", "options": {"symlink": true}}' --working-dir ./${{ env.EXTENSION_PATH }}
189
225
190
226
- name : Modify dependencies to use development aliases
191
227
run : |
192
- composer require crowdsec/common:"dev-${{ steps.set-common-data.outputs.branch }} as ${{ steps.set-common-data.outputs.major_tag }}.999.0" --no-update --working-dir ./${{env.EXTENSION_PATH}}
193
- composer require crowdsec/lapi-client:"dev-${{ steps.set-lapi-client-data.outputs.branch }} as ${{ steps.set-lapi-client-data.outputs.major_tag }}.999.0" --no-update --working-dir ./${{env.EXTENSION_PATH}}
194
- composer require crowdsec/remediation-engine:"dev-${{ steps.set-remediation-engine-data.outputs.branch }} as ${{ steps.set-remediation-engine-data.outputs.major_tag }}.999.0" --no-update --working-dir ./${{env.EXTENSION_PATH}}
195
-
196
- cat ./${{env.EXTENSION_PATH}}/composer.json
228
+ # Bouncer lib
229
+ composer require crowdsec/common:"dev-${{ steps.set-common-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.EXTENSION_PATH}}
230
+ composer require crowdsec/lapi-client:"dev-${{ steps.set-lapi-client-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.EXTENSION_PATH}}
231
+ composer require crowdsec/remediation-engine:"dev-${{ steps.set-remediation-engine-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.EXTENSION_PATH}}
232
+ composer require crowdsec/capi-client:"dev-${{ steps.set-capi-client-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.EXTENSION_PATH}}
233
+ # Remediation engine
234
+ composer require crowdsec/common:"dev-${{ steps.set-common-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.REMEDIATION_ENGINE_PATH}}
235
+ composer require crowdsec/lapi-client:"dev-${{ steps.set-lapi-client-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.REMEDIATION_ENGINE_PATH}}
236
+ composer require crowdsec/capi-client:"dev-${{ steps.set-capi-client-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.REMEDIATION_ENGINE_PATH}}
237
+ # CAPI client
238
+ composer require crowdsec/common:"dev-${{ steps.set-common-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.CAPI_CLIENT_PATH}}
239
+ # LAPI client
240
+ composer require crowdsec/common:"dev-${{ steps.set-common-data.outputs.branch }} as 999.999.0" --no-update --working-dir ./${{env.LAPI_CLIENT_PATH}}
197
241
198
242
- name : Validate composer.json
199
- run : ddev composer validate --strict --working-dir ./${{env.EXTENSION_PATH}}
243
+ run : |
244
+ # Bouncer lib
245
+ cat ./${{env.EXTENSION_PATH}}/composer.json
246
+ ddev composer validate --strict --working-dir ./${{env.EXTENSION_PATH}}
247
+ # Remediation engine
248
+ cat ./${{env.REMEDIATION_ENGINE_PATH}}/composer.json
249
+ ddev composer validate --strict --working-dir ./${{env.REMEDIATION_ENGINE_PATH}}
250
+ # CAPI client
251
+ cat ./${{env.CAPI_CLIENT_PATH}}/composer.json
252
+ ddev composer validate --strict --working-dir ./${{env.CAPI_CLIENT_PATH}}
253
+ # LAPI client
254
+ cat ./${{env.LAPI_CLIENT_PATH}}/composer.json
255
+ ddev composer validate --strict --working-dir ./${{env.LAPI_CLIENT_PATH}}
200
256
201
257
- name : Install CrowdSec lib dependencies
202
258
run : |
@@ -223,6 +279,15 @@ jobs:
223
279
echo $LAPI_CLIENT_VERSION
224
280
exit 1
225
281
fi
282
+ CAPI_CLIENT_VERSION=$(ddev composer show crowdsec/capi-client --working-dir ./${{env.EXTENSION_PATH}} | grep -oP "versions : \* \K(.*)")
283
+ if [[ $CAPI_CLIENT_VERSION == "dev-${{ steps.set-capi-client-data.outputs.branch }}" ]]
284
+ then
285
+ echo "CAPI_CLIENT_VERSION COMPARISON OK"
286
+ else
287
+ echo "CAPI_CLIENT_VERSION COMPARISON KO"
288
+ echo $CAPI_CLIENT_VERSION
289
+ exit 1
290
+ fi
226
291
REMEDIATION_ENGINE_VERSION=$(ddev composer show crowdsec/remediation-engine --working-dir ./${{env.EXTENSION_PATH}} | grep -oP "versions : \* \K(.*)")
227
292
if [[ $REMEDIATION_ENGINE_VERSION == "dev-${{ steps.set-remediation-engine-data.outputs.branch }}" ]]
228
293
then
0 commit comments