From cb0d23c455b73486fd1015f8ca9479b5b7e3585d Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 21 Jan 2020 14:21:10 +0000 Subject: Add latest changes from gitlab-org/gitlab@12-7-stable-ee --- scripts/insert-rspec-profiling-data | 2 ++ scripts/lint-changelog-filenames | 12 ++++++++++++ scripts/notifications.sh | 27 --------------------------- scripts/static-analysis | 6 +++--- scripts/sync-stable-branch.sh | 26 +++++++++++++++++++++----- scripts/trigger-build | 10 ++++++++-- 6 files changed, 46 insertions(+), 37 deletions(-) create mode 100755 scripts/lint-changelog-filenames delete mode 100755 scripts/notifications.sh (limited to 'scripts') diff --git a/scripts/insert-rspec-profiling-data b/scripts/insert-rspec-profiling-data index 88c9d8c12b1..3af5fe763a2 100755 --- a/scripts/insert-rspec-profiling-data +++ b/scripts/insert-rspec-profiling-data @@ -35,6 +35,8 @@ def insert_data(path) files.each do |filename| puts "#{Time.now} Inserting #{filename}..." + # Strip file of NULL bytes to ensure data gets inserted + system("sed", "-i", "-e", "s/\\x00//g", filename) result = RspecProfiling::Collectors::PSQL::Result.copy_from(filename) puts "#{Time.now} Inserted #{result.cmd_tuples} lines in #{filename}, DB response: #{result.cmd_status}" end diff --git a/scripts/lint-changelog-filenames b/scripts/lint-changelog-filenames new file mode 100755 index 00000000000..2355ac6f7b2 --- /dev/null +++ b/scripts/lint-changelog-filenames @@ -0,0 +1,12 @@ +#!/bin/sh + +lint_paths="changelogs/unreleased" +[ -d "ee/" ] && lint_paths="$lint_paths ee/changelogs/unreleased" + +invalid_files=$(find $lint_paths -type f -not -name "*.yml" -not -name ".gitkeep") + +if [ -n "$invalid_files" ]; then + echo "Changelog files must end in .yml, but these did not:" + echo "$invalid_files" | sed -e "s/^/* /" + exit 1 +fi diff --git a/scripts/notifications.sh b/scripts/notifications.sh deleted file mode 100755 index d1b11d44e88..00000000000 --- a/scripts/notifications.sh +++ /dev/null @@ -1,27 +0,0 @@ -# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set). -# ICON_EMOJI needs to be set to an icon emoji name (without the `:` around it). -function notify_slack() { - CHANNEL=$1 - MSG=$2 - ICON_EMOJI=$3 - - if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ]; then - echo "Missing argument(s) - Use: $0 channel message icon_emoji" - echo "and set CI_SLACK_WEBHOOK_URL environment variable." - else - curl -X POST --data-urlencode 'payload={"channel": "#'"${CHANNEL}"'", "username": "GitLab QA Bot", "text": "'"${MSG}"'", "icon_emoji": "'":${ICON_EMOJI}:"'"}' "${CI_SLACK_WEBHOOK_URL}" - fi -} - -function notify_on_job_failure() { - JOB_NAME=$1 - CHANNEL=$2 - MSG=$3 - ICON_EMOJI=$4 - - local job_id - job_id=$(scripts/get-job-id "$CI_PROJECT_ID" "$CI_PIPELINE_ID" "$JOB_NAME" -s failed) - if [ -n "${job_id}" ]; then - notify_slack "${CHANNEL}" "${MSG}" "${ICON_EMOJI}" - fi -} diff --git a/scripts/static-analysis b/scripts/static-analysis index c26c9a55bb1..1f55c035ed1 100755 --- a/scripts/static-analysis +++ b/scripts/static-analysis @@ -35,8 +35,7 @@ ALLOWED_WARNINGS = [ def warning_count(static_analysis) static_analysis.warned_results - .reject { |result| ALLOWED_WARNINGS.include?(result.stderr.strip) } - .count + .count { |result| !ALLOWED_WARNINGS.include?(result.stderr.strip) } end def jobs_to_run(node_index, node_total) @@ -49,7 +48,8 @@ def jobs_to_run(node_index, node_total) %w[bundle exec rubocop --parallel], %w[scripts/lint-conflicts.sh], %w[scripts/lint-rugged], - %w[scripts/frontend/check_no_partial_karma_jest.sh] + %w[scripts/frontend/check_no_partial_karma_jest.sh], + %w[scripts/lint-changelog-filenames] ] case node_total diff --git a/scripts/sync-stable-branch.sh b/scripts/sync-stable-branch.sh index b44bf26a151..5aaec323628 100644 --- a/scripts/sync-stable-branch.sh +++ b/scripts/sync-stable-branch.sh @@ -7,34 +7,50 @@ set -e if [[ "$MERGE_TRAIN_TRIGGER_TOKEN" == '' ]] then - echo 'The variable MERGE_TRAIN_TRIGGER_TOKEN must be set to a non-empy value' + echo 'The variable MERGE_TRAIN_TRIGGER_TOKEN must be set to a non-empty value' exit 1 fi if [[ "$MERGE_TRAIN_TRIGGER_URL" == '' ]] then - echo 'The variable MERGE_TRAIN_TRIGGER_URL must be set to a non-empy value' + echo 'The variable MERGE_TRAIN_TRIGGER_URL must be set to a non-empty value' exit 1 fi if [[ "$CI_COMMIT_REF_NAME" == '' ]] then - echo 'The variable CI_COMMIT_REF_NAME must be set to a non-empy value' + echo 'The variable CI_COMMIT_REF_NAME must be set to a non-empty value' exit 1 fi if [[ "$SOURCE_PROJECT" == '' ]] then - echo 'The variable SOURCE_PROJECT must be set to a non-empy value' + echo 'The variable SOURCE_PROJECT must be set to a non-empty value' exit 1 fi if [[ "$TARGET_PROJECT" == '' ]] then - echo 'The variable TARGET_PROJECT must be set to a non-empy value' + echo 'The variable TARGET_PROJECT must be set to a non-empty value' exit 1 fi +if [[ "$TARGET_PROJECT" != "gitlab-org/gitlab-foss" ]] +then + echo 'This is a security FOSS merge train' + echo "Checking if $CI_COMMIT_SHA is available on canonical" + + gitlab_com_commit_status=$(curl -s "https://gitlab.com/api/v4/projects/278964/repository/commits/$CI_COMMIT_SHA" | jq -M .status) + + if [[ "$gitlab_com_commit_status" != "null" ]] + then + echo 'Commit available on canonical, skipping merge train' + exit 0 + fi + + echo 'Commit not available, triggering a merge train' +fi + curl -X POST \ -F token="$MERGE_TRAIN_TRIGGER_TOKEN" \ -F ref=master \ diff --git a/scripts/trigger-build b/scripts/trigger-build index 537b2692b27..6e50d8907d8 100755 --- a/scripts/trigger-build +++ b/scripts/trigger-build @@ -18,11 +18,16 @@ module Trigger class Base def invoke!(post_comment: false, downstream_job_name: nil) + pipeline_variables = variables + + puts "Triggering downstream pipeline on #{downstream_project_path}" + puts "with variables #{pipeline_variables}" + pipeline = Gitlab.run_trigger( downstream_project_path, trigger_token, ref, - variables) + pipeline_variables) puts "Triggered downstream pipeline: #{pipeline.web_url}\n" puts "Waiting for downstream pipeline status" @@ -85,7 +90,8 @@ module Trigger 'TRIGGER_SOURCE' => ENV['CI_JOB_URL'], 'TOP_UPSTREAM_SOURCE_PROJECT' => ENV['CI_PROJECT_PATH'], 'TOP_UPSTREAM_SOURCE_JOB' => ENV['CI_JOB_URL'], - 'TOP_UPSTREAM_SOURCE_SHA' => ENV['CI_COMMIT_SHA'] + 'TOP_UPSTREAM_SOURCE_SHA' => ENV['CI_COMMIT_SHA'], + 'TOP_UPSTREAM_SOURCE_REF' => ENV['CI_COMMIT_REF_NAME'] } end -- cgit v1.2.1