diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2021-02-17 11:09:27 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2021-02-22 16:09:53 +0300 |
commit | 2f205ff116ffd9fa152dc333f0a80365595a5428 (patch) | |
tree | ccc7e260c1a019b5ad92c9ea8e21364c9736511c /_support | |
parent | c45afa70f5bd9723f0836ff228a11bc896c45511 (diff) |
_support: Remove unused files
This commit removes a few files that were still in the tree, but gone
unused. Changelog generation and updating downstream dependencies is no
longer our teams concern, but done by the Delivery team.
Diffstat (limited to '_support')
-rwxr-xr-x | _support/generate_changelog | 71 | ||||
-rwxr-xr-x | _support/update-downstream-server-version | 125 |
2 files changed, 0 insertions, 196 deletions
diff --git a/_support/generate_changelog b/_support/generate_changelog deleted file mode 100755 index f34b17d5e..000000000 --- a/_support/generate_changelog +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env ruby -# Generates the changelog from the yaml entries in changelogs/unreleased - -require 'yaml' -require 'fileutils' - -class ChangelogEntry - attr_reader :title, :merge_request, :type, :author - - def initialize(file_path) - yaml = YAML.safe_load(File.read(file_path)) - - @title = yaml['title'] - @merge_request = yaml['merge_request'] - @type = yaml['type'] - @author = yaml['author'] - end - - def to_s - str = "" - str << "- #{title}\n" - str << " https://gitlab.com/gitlab-org/gitaly/merge_requests/#{merge_request}\n" - str << " Contributed by #{author}\n" if author - - str - end -end - -ROOT_DIR = File.expand_path('../..', __FILE__) -UNRELEASED_ENTRIES = File.join(ROOT_DIR, 'changelogs', 'unreleased') -CHANGELOG_FILE = File.join(ROOT_DIR, 'CHANGELOG.md') - -def main(version) - entries = [] - Dir["#{UNRELEASED_ENTRIES}/*.yml"].each do |yml| - entries << ChangelogEntry.new(yml) - FileUtils.rm(yml) - end - - sections = [] - types = entries.map(&:type).uniq.sort - types.each do |type| - text = '' - text << "#### #{type.capitalize}\n" - - entries.each do |e| - next unless e.type == type - - text << e.to_s - end - - sections << text - end - - new_version_entry = ["## v#{version}\n\n", sections.join("\n"), "\n"].join - - current_changelog = File.read(CHANGELOG_FILE).lines - header = current_changelog.shift(2) - - new_changelog = [header, new_version_entry, current_changelog.join] - - File.write(CHANGELOG_FILE, new_changelog.join) -end - -unless ARGV.count == 1 - warn "Usage: #{$0} VERSION" - warn "Specify version as x.y.z" - abort -end - -main(ARGV.first) diff --git a/_support/update-downstream-server-version b/_support/update-downstream-server-version deleted file mode 100755 index b61b237d7..000000000 --- a/_support/update-downstream-server-version +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env ruby - -require 'net/http' -require 'uri' -require 'json' -require_relative 'run.rb' - -def gitlab_api(url, body=nil) - uri = URI.parse(url) - - header = { - 'Content-Type': 'application/json', - 'PRIVATE-TOKEN': ENV['GITLAB_TOKEN'] - } - - # Create the HTTP objects - Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http| - if body - request = Net::HTTP::Post.new(uri.request_uri, header) - request.body = body.to_json - else - request = Net::HTTP::Get.new(uri.request_uri, header) - end - - response = http.request(request) - raise "Request to #{url} failed: #{response.body}" unless Integer(response.code) < 400 - - JSON.parse(response.body) - end -end - -def find_user_id - return ENV["GITLAB_USER_ID"] if ENV["GITLAB_USER_ID"] - - response = gitlab_api("https://gitlab.com/api/v4/user") - response['id'] -end - -def find_project_id(project_name) - encoded_project_name = URI.encode_www_form_component(project_name) - response = gitlab_api("https://gitlab.com/api/v4/projects/#{encoded_project_name}") - - response['id'] -end - -def find_tag - return ENV["CI_COMMIT_TAG"] if ENV["CI_COMMIT_TAG"] - - capture!(%w[git tag --points-at HEAD]).chomp -end - -def update_gitaly_version(project_id, tag_version) - version = tag_version.sub(/^v/, "") - - server_version_commit = { - "branch": "gitaly-version-#{tag_version}", - "start_branch": "master", - "commit_message": "Update Gitaly version to #{tag_version}", - "actions": [{ - "action": "update", - "file_path": "GITALY_SERVER_VERSION", - "content": "#{version}\n" - }] - } - - gitlab_api("https://gitlab.com/api/v4/projects/#{project_id}/repository/commits", server_version_commit) -end - -def create_mr(project_id, tag_version, assignee_id) - anchor = 'v' + tag_version.tr('.', '') - description = <<~MR - Upgrade Gitaly to #{tag_version}. - - See the [Gitaly changelog](https://gitlab.com/gitlab-org/gitaly/blob/master/CHANGELOG.md##{anchor}) - for an overview of the changes. - MR - - merge_request = { - "source_branch": "gitaly-version-#{tag_version}", - "target_branch": "master", - "title": "Upgrade Gitaly to #{tag_version}", - "assignee_id": assignee_id, - "description": description, - "labels": "devops::create,group::gitaly,backstage", - "remove_source_branch": true, - "squash": true - } - - gitlab_api("https://gitlab.com/api/v4/projects/#{project_id}/merge_requests", merge_request) -end - -def add_changelog(project_id, tag_version, merge_request_number) - changelog_commit = { - "branch": "gitaly-version-#{tag_version}", - "start_branch": "gitaly-version-#{tag_version}", - "commit_message": "Add changelog entry", - "actions": [{ - "action": "create", - "file_path": "changelogs/unreleased/gitaly-version-#{tag_version}.yml", - "content": <<~HEREDOC - --- - title: Upgrade to Gitaly #{tag_version} - merge_request: #{merge_request_number} - author: - type: changed - HEREDOC - }] - } - - gitlab_api("https://gitlab.com/api/v4/projects/#{project_id}/repository/commits", changelog_commit) -end - -abort "Please set GITLAB_TOKEN env var" unless ENV['GITLAB_TOKEN'] - -project_id = find_project_id("gitlab-org/gitlab") -tag_version = find_tag -assignee_id = find_user_id - -abort "Unable to determine tag for current HEAD" unless tag_version - -update_gitaly_version(project_id, tag_version) -merge_request = create_mr(project_id, tag_version, assignee_id) -add_changelog(project_id, tag_version, merge_request['iid']) - -puts merge_request['web_url'] |