Fix CI
Use this skill to turn a CircleCI web tests URL like:
https://app.circle.example.com/pipelines/github/example-org/example-repo/19060/workflows/887679f9-1f30-43a6-a600-7292d29b3edc/jobs/215974/tests
into API calls to CircleCI v2 and summarize failing/erroring tests.
Requirements
Make sure that the following environment variables are set in your environment. If not, raise an error.
CIRCLECI_TOKENCIRCLECI_BASE_URL- CircleCI server root URL (for example,https://circle.example.com)
For such test run [ -n "${CIRCLECI_TOKEN}" ] && [ -n "${CIRCLECI_BASE_URL}" ] && echo "ENV OK" || echo "ERROR: MISSING ENV VAR"
Usage
From this skill directory:
python3 scripts/circleci_errors.py '<circleci-tests-url>'
Useful options:
python3 scripts/circleci_errors.py '<url>' --all # print all tests, not just failed/error tests
python3 scripts/circleci_errors.py '<url>' --json # emit normalized JSON
python3 scripts/circleci_errors.py '<url>' --base-url https://circle.example.com/api/v2
Workflow
- Parse the CircleCI web URL.
- Derive the project slug (
github/org/repofrom app URLs, accepted by CircleCI Server; public cloud also acceptsgh/org/repofor cloud URLs). - Call
GET /api/v2/project/{project-slug}/{job-number}/tests, following pagination. - Report tests whose result is
failure,failed,error, orerrored, including class/name/file/message/source where available.
If authentication fails, ask the user to provide/export a valid CircleCI token with permission to read the project/job.