Skip to content

Commit

Permalink
fix(action): make sure curl fails if HTTP server fails (#10)
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 authored Sep 5, 2024
1 parent 987e793 commit e2a49e9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ jobs:
set -e
test "$CI_ISSUE_GIGID" = "1234azertyuiop"
- name: Clear result file
run: rm result.json

- name: Run action with error scenario ❌
id: error500
continue-on-error: true
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
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ runs:
exit 1
fi
set +e
# 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 All @@ -57,6 +60,14 @@ runs:
-o result.json \
${MERGIFY_API_SERVER}/repos/${REPOSITORY}/ci_issues_upload
if [ $? = 22 ]; then
echo "Upload failed"
test -f result.json && cat result.json
exit 22
fi
set -e
GIGID=$(jq -r .gigid result.json)
echo "::notice title=CI Issues report::CI_ISSUE_GIGID=$GIGID"
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 e2a49e9

Please sign in to comment.