Use the danger-review component
What does this MR do and why?
This dogfood the "official" gitlab-org
component for danger-review
.
Full configuration of the danger-review
job (generated with the Pipeline Editor), note the allow_failure: true
):
danger-review:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
image: "$CI_REGISTRY_IMAGE/base:$CI_DEFAULT_BRANCH"
stage: test
needs: []
allow_failure: true
variables:
GITLAB_API_TOKEN: "$DANGER_GITLAB_API_TOKEN"
retry:
max: 2
when:
- unknown_failure
- api_failure
- runner_system_failure
- stuck_or_timeout_failure
before_script:
- '[[ ! -f "Gemfile" ]] && bundle init && bundle add gitlab-dangerfiles --version
""'
- '[[ ! -f "Gemfile.lock" ]] || bundle config set --local frozen "true"'
- bundle install
script:
- |
if [[ "$CI_MERGE_REQUEST_PROJECT_URL" != "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL" || -z "${GITLAB_API_TOKEN}" ]]; then
git fetch "${CI_SERVER_PROTOCOL}://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/${CI_MERGE_REQUEST_SOURCE_PROJECT_PATH}.git" "$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"
fi
- |
if [ -z "${GITLAB_API_TOKEN}" ]; then
echo '`GITLAB_API_TOKEN` is not set. Skipping CI source GitLab and falling back to "local only git repo".'
unset GITLAB_CI;
# We need to base SHA to help danger determine the base commit for this shallow clone.
bundle exec danger dry_run --fail-on-errors=true --verbose --base="${CI_MERGE_REQUEST_DIFF_BASE_SHA}" --head="${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}" --dangerfile="Dangerfile";
else
danger_id=$(echo -n ${GITLAB_API_TOKEN} | md5sum | awk '{print $1}' | cut -c5-10);
bundle exec danger --fail-on-errors=true --verbose --danger_id="${danger_id}" --dangerfile="Dangerfile";
fi
Content
- Use the danger-review component
Author Check-list
-
Has documentation been updated?
Edited by Rémy Coutable