Skip to content

Commit

Permalink
fix(action): make sure curl fails if HTTP server fails
Browse files Browse the repository at this point in the history
This avoids curl storing the error in the result.json file.

Fixes MRGFY-4028

Change-Id: I1a5ac6866cd3c8cc10df011cdd10abdf098b7b0c
  • Loading branch information
jd committed Sep 4, 2024
1 parent 987e793 commit 35e6a3b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ jobs:
set -e
test "$CI_ISSUE_GIGID" = "1234azertyuiop"
- name: Run action with error scenario 🔍
id: error500
uses: ./
with:
token: fake-valid-token
report_paths: zfixtures/junit_example.xml
mergify_api_server: http://localhost:1085

- name: Check error was reported
if: ${{ steps.error500.outcome == 'success' }}
run: |
echo "Error succeeded, that's not correct."
exit 1
- name: Dump mockserver logs
if: always()
run: |
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ runs:
# TODO(sileht): support multiple files
curl -X POST \
--fail \
-H "Authorization: bearer ${MERGIFY_CI_ISSUES_TOKEN}" \
-F name=${WORKFLOW_JOB_NAME} \
-F provider=github_action \
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@ services:
- type: bind
source: zfixtures
target: /config
mockServerError:
image: mockserver/mockserver:5.15.0
command: -logLevel DEBUG
ports:
- 1085:1080
environment:
MOCKSERVER_INITIALIZATION_JSON_PATH: /config/fake-ci-issue-api-500.json
volumes:
- type: bind
source: zfixtures
target: /config
11 changes: 11 additions & 0 deletions zfixtures/fake-ci-issue-api-500.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"httpRequest": {
"path": ".*"
},
"httpResponse": {
"statusCode": 500,
"body": "Internal Server Error"
}
}
]

0 comments on commit 35e6a3b

Please sign in to comment.