From c3977c8dab24e333783046bb5a040a91302af5d5 Mon Sep 17 00:00:00 2001
From: Jacob Vosmaer <jacob@gitlab.com>
Date: Tue, 23 Feb 2021 15:47:48 +0100
Subject: [PATCH] Move workhorse development to main gitlab repo

---
 .gitlab/CODEOWNERS                 |  3 ++
 .gitlab/ci/workhorse.gitlab-ci.yml | 12 +-----
 GITLAB_WORKHORSE_VERSION           |  2 +-
 scripts/update-workhorse           | 59 ------------------------------
 workhorse/PROCESS.md               |  4 ++
 workhorse/README.md                | 14 ++-----
 workhorse/VERSION                  |  2 +-
 7 files changed, 14 insertions(+), 82 deletions(-)
 mode change 100644 => 120000 GITLAB_WORKHORSE_VERSION
 delete mode 100755 scripts/update-workhorse
 mode change 100644 => 120000 workhorse/VERSION

diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS
index 709a8fa9b2aab..2eda1a890d9c0 100644
--- a/.gitlab/CODEOWNERS
+++ b/.gitlab/CODEOWNERS
@@ -280,3 +280,6 @@ Dangerfile @gl-quality/eng-prod
 
 [Legal]
 /config/dependency_decisions.yml @gitlab-org/legal-reviewers
+
+[Workhorse]
+/workhorse/ @jacobvosmaer-gitlab @nick.thomas @nolith @patrickbajao 
diff --git a/.gitlab/ci/workhorse.gitlab-ci.yml b/.gitlab/ci/workhorse.gitlab-ci.yml
index a40eebd131b7a..8361d20d2b79c 100644
--- a/.gitlab/ci/workhorse.gitlab-ci.yml
+++ b/.gitlab/ci/workhorse.gitlab-ci.yml
@@ -1,20 +1,10 @@
-workhorse:
-  extends: .workhorse:rules:workhorse
-  image: ${GITLAB_DEPENDENCY_PROXY}golang:1.14
-  stage: test
-  needs: []
-  script:
-    - rm .git/hooks/post-checkout
-    - git checkout .
-    - scripts/update-workhorse check
-    - make -C workhorse
-
 workhorse:verify:
   extends: .workhorse:rules:workhorse
   image: ${GITLAB_DEPENDENCY_PROXY}golang:1.15
   stage: test
   needs: []
   script:
+    - make -C workhorse # test build
     - make -C workhorse verify
 
 .workhorse:test:
diff --git a/GITLAB_WORKHORSE_VERSION b/GITLAB_WORKHORSE_VERSION
deleted file mode 100644
index d97ab403ee4a1..0000000000000
--- a/GITLAB_WORKHORSE_VERSION
+++ /dev/null
@@ -1 +0,0 @@
-8.65.0
diff --git a/GITLAB_WORKHORSE_VERSION b/GITLAB_WORKHORSE_VERSION
new file mode 120000
index 0000000000000..974cf28e00837
--- /dev/null
+++ b/GITLAB_WORKHORSE_VERSION
@@ -0,0 +1 @@
+VERSION
\ No newline at end of file
diff --git a/scripts/update-workhorse b/scripts/update-workhorse
deleted file mode 100755
index 2c43b249fe452..0000000000000
--- a/scripts/update-workhorse
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-set -e
-WORKHORSE_DIR=workhorse/
-WORKHORSE_REF="$(cat GITLAB_WORKHORSE_VERSION)"
-WORKHORSE_URL=${GITLAB_WORKHORSE_URL:-https://gitlab.com/gitlab-org/gitlab-workhorse.git}
-
-if [ $# -gt 1 ] || ([ $# = 1 ] && [ x$1 != xcheck ]); then
-  echo "Usage: update-workhorse [check]"
-  exit 1
-fi
-
-if echo "$WORKHORSE_REF" | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+' ; then
-  # Assume this is a tagged release
-  WORKHORSE_REF="v${WORKHORSE_REF}"
-fi
-
-clean="$(git status --porcelain)"
-if [ -n "$clean" ] ; then
-  echo 'error: working directory is not clean:'
-  echo "$clean"
-  exit 1
-fi
-
-git fetch "$WORKHORSE_URL" "$WORKHORSE_REF"
-git rm -rf --quiet -- "$WORKHORSE_DIR"
-git read-tree --prefix="$WORKHORSE_DIR" -u FETCH_HEAD
-
-status="$(git status --porcelain)"
-
-if [ x$1 = xcheck ]; then
-  if [ -n "$status" ]; then
-    cat <<MSG
-error: $WORKHORSE_DIR does not match $WORKHORSE_REF
-
-During the transition period of https://gitlab.com/groups/gitlab-org/-/epics/4826,
-the workhorse/ directory in this repository is read-only. To make changes:
-
-1. Submit a MR to https://gitlab.com/gitlab-org/gitlab-workhorse
-2. Once your MR is merged, have a new gitlab-workhorse tag made
-   by a maintainer
-3. Update the GITLAB_WORKHORSE_VERSION file in this repository
-4. Run scripts/update-workhorse to update the workhorse/ directory
-
-MSG
-    exit 1
-  fi
-  exit 0
-fi
-
-if [ -z "$status" ]; then
-  echo "warn: $WORKHORSE_DIR is already up to date, exiting without commit"
-  exit 0
-fi
-
-tree=$(git write-tree)
-msg="Update vendored workhorse to $WORKHORSE_REF"
-commit=$(git commit-tree -p HEAD -p FETCH_HEAD^{commit} -m "$msg" "$tree")
-git update-ref HEAD "$commit"
-git log -1
diff --git a/workhorse/PROCESS.md b/workhorse/PROCESS.md
index 797de59d47e99..cf29b23b2c043 100644
--- a/workhorse/PROCESS.md
+++ b/workhorse/PROCESS.md
@@ -31,6 +31,10 @@ The final merge must be performed by a maintainer.
 
 ## Releases
 
+> Below we describe the legacy release process, from when Workhorse
+> had its own repository. These instructions are still useful for
+> security backports.
+
 New versions of Workhorse can be released by one of the Workhorse
 maintainers. The release process is:
 
diff --git a/workhorse/README.md b/workhorse/README.md
index c1ff104cda8bd..3284813285f59 100644
--- a/workhorse/README.md
+++ b/workhorse/README.md
@@ -9,17 +9,11 @@ GitLab](doc/architecture/gitlab_features.md) that would not work efficiently wit
 
 ## Canonical source
 
-The canonical source for Workhorse is currently
-[gitlab-org/gitlab-workhorse](https://gitlab.com/gitlab-org/gitlab-workhorse).
-As explained in https://gitlab.com/groups/gitlab-org/-/epics/4826, we
-are in the process of moving the canonical source to
+The canonical source for Workhorse is
 [gitlab-org/gitlab/workhorse](https://gitlab.com/gitlab-org/gitlab/tree/master/workhorse).
-
-Until that transition is complete, changes (Merge Requests) for
-Workhorse should be submitted at
-[gitlab-org/gitlab-workhorse](https://gitlab.com/gitlab-org/gitlab-workhorse).
-Once merged, they will propagate to gitlab-org/gitlab/workhorse via
-the usual Workhorse release process.
+Prior to https://gitlab.com/groups/gitlab-org/-/epics/4826, it was
+[gitlab-org/gitlab/workhorse](https://gitlab.com/gitlab-org/gitlab-workhorse/tree/master),
+but that repository is no longer used for development.
 
 ## Documentation
 
diff --git a/workhorse/VERSION b/workhorse/VERSION
deleted file mode 100644
index d97ab403ee4a1..0000000000000
--- a/workhorse/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-8.65.0
diff --git a/workhorse/VERSION b/workhorse/VERSION
new file mode 120000
index 0000000000000..6ff19de4b804f
--- /dev/null
+++ b/workhorse/VERSION
@@ -0,0 +1 @@
+../VERSION
\ No newline at end of file
-- 
GitLab