Skip to content

Commit

Permalink
test script
Browse files Browse the repository at this point in the history
  • Loading branch information
lecrepont01 committed Aug 28, 2024
1 parent f078eb3 commit 6ccc3a6
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 13 deletions.
40 changes: 28 additions & 12 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,30 @@ jobs:
timeout-minutes: 5
runs-on: ubuntu-22.04
services:
mockServer:
image: mockserver/mockserver:5.15.0
ports:
- 1080:1080
volumes:
- ./fixtures:/fixtures
env:
MOCKSERVER_LOG_LEVEL: DEBUG
MOCKSERVER_INITIALIZATION_JSON_PATH: /fixtures/expectationInitialiser.json
# mockServer:
# image: mockserver/mockserver:5.15.0
# ports:
# - 1080:1080
# volumes:
# - ${{ github.workspace }}/zfixtures:/config
# env:
# MOCKSERVER_LOG_LEVEL: DEBUG
# MOCKSERVER_INITIALIZATION_JSON_PATH: /config/expectationInitializer.json
steps:
- name: Checkout 🛎️
uses: actions/[email protected]

- name: Start mockServer with expectation initializer
run: |
docker-compose up -d
sleep 1
docker compose logs
- name: Ensure zfixtures directory exists
run: |
ls -la ${{ github.workspace }}/zfixtures
cat ${{ github.workspace }}/zfixtures/expectationInitializer.json
- name: Install CircleCI CLI
run: curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | bash

Expand All @@ -60,11 +71,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 compose logs
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: /config/expectationInitializer.json
volumes:
- ./zfixtures:/config
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 6ccc3a6

Please sign in to comment.