Skip to content

Commit

Permalink
test script
Browse files Browse the repository at this point in the history
  • Loading branch information
lecrepont01 committed Aug 27, 2024
1 parent f078eb3 commit 2d5eedb
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 6 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ jobs:
ports:
- 1080:1080
volumes:
- ./fixtures:/fixtures
- /zfixtures:/config
env:
MOCKSERVER_LOG_LEVEL: DEBUG
MOCKSERVER_INITIALIZATION_JSON_PATH: /fixtures/expectationInitialiser.json
MOCKSERVER_INITIALIZATION_JSON_PATH: /config/expectationInitialiser.json
steps:
- name: Checkout 🛎️
uses: actions/[email protected]

- name: Ensure zfixtures directory exists
run: |
ls -la ${{ github.workspace }}/zfixtures
cat ${{ github.workspace }}/zfixtures/expectationInitialiser.json
- name: Install CircleCI CLI
run: curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | bash

Expand All @@ -60,11 +65,16 @@ jobs:
- name: Test Orb script
run: |
export FAKE_VALID_TOKEN=fake-valid-token
bash src/scripts/upload.sh
env:
REPO_URL: https://github.com/$GITHUB_REPOSITORY
TOKEN: fake-valid-token
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
TOKEN: FAKE_VALID_TOKEN
CIRCLE_JOB: test
CIRCLE_SHA1: 948da8c01b17ac2164039f3150221d5cfcae7ecc
FILES: junit_example.xml
FILES: zfixtures/junit_example.xml
MERGIFY_API_SERVER: http://localhost:1080

- name: Mockserver logs
if: always()
run: docker logs ${{ job.services.mockServer.id }}
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
mockServer:
image: mockserver/mockserver:5.15.0
# command: -logLevel DEBUG
ports:
- 1080:1080
environment:
MOCKSERVER_LOG_LEVEL: DEBUG
MOCKSERVER_INITIALIZATION_JSON_PATH: /zfixtures/expectationInitializer.json
volumes:
- ./zfixtures:/zfixtures
44 changes: 44 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# This example uses envsubst to support variable substitution in the string parameter type.
# https://circleci.com/docs/orbs-best-practices/#accepting-parameters-as-strings-or-environment-variables

#TO=$(circleci env subst "${PARAM_TO}")
# If for any reason the TO variable is not set, default to "World"
#echo "Hello ${TO:-World}!"

set -x

export REPO_URL=https://github.com/Mergifyio/circleci-ci-issues
export FAKE_VALID_TOKEN=fake-valid-token
export TOKEN=FAKE_VALID_TOKEN
export CIRCLE_JOB=test
export CIRCLE_SHA1=948da8c01b17ac2164039f3150221d5cfcae7ecc
export FILES=zfixtures/junit_example.xml
export MERGIFY_API_SERVER=http://localhost:1080


if [[ $REPO_URL =~ ^https:\/\/github\.com\/([a-zA-Z0-9._-]+)\/([a-zA-Z0-9._-]+)$ ]]; then
REPO_FULL_NAME=${BASH_REMATCH[1]}/${BASH_REMATCH[2]}
else
echo "Invalid repository URL: $REPO_URL"
exit 1
fi

# TODO: support multiple files
curl -X POST \
-H "Authorization: bearer ${!TOKEN}" \
-F name=${CIRCLE_JOB} \
-F provider=circleci \
-F head_sha=${CIRCLE_SHA1} \
-F files=@${FILES} \
-o result.json \
${MERGIFY_API_SERVER}/repos/${REPO_FULL_NAME}/ci_issues_upload \

echo "Display result"
cat result.json

GIGID=$(cat result.json | jq -r .gigid)
echo "::notice title=CI Issues report::CI_ISSUE_GIGID=$GIGID"

# echo "CI_ISSUE_GIGID=$GIGID" >> "$GITHUB_OUTPUT"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"body": {
"type": "REGEX",
"regex": ".*Content-Disposition: form-data; name=\"name\"\r\n\r\ntest\r\n.*Content-Disposition: form-data; name=\"provider\"\r\n\r\ncircleci\r\n.*Content-Disposition: form-data; name=\"head_sha\"\r\n\r\n948da8c01b17ac2164039f3150221d5cfcae7ecc\r\n.*Content-Disposition: form-data; name=\"files\"; filename=\"junit_example.xml\"\r\nContent-Type: application/xml\r\n\r\n.*"
"regex": ".*Content-Disposition: form-data; name=\\\"name\\\"\\r\\n\\r\\ntest\\r\\n.*\\r\\nContent-Disposition: form-data; name=\\\"provider\\\"\\r\\n\\r\\ncircleci\\r\\n.*\\r\\nContent-Disposition: form-data; name=\\\"head_sha\\\"\\r\\n\\r\\n948da8c01b17ac2164039f3150221d5cfcae7ecc\\r\\n.*\\r\\nContent-Disposition: form-data; name=\\\"files\\\"; filename=\\\"junit_example.xml\\\"\\r\\nContent-Type: application/xml\\r\\n\\r\\n.*"
}
},
"httpResponse": {
Expand Down
File renamed without changes.

0 comments on commit 2d5eedb

Please sign in to comment.