Commit f4329d15 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Add workhorse CI check

parent f0e61d9b
......@@ -109,3 +109,4 @@ include:
- local: .gitlab/ci/releases.gitlab-ci.yml
- local: .gitlab/ci/notify.gitlab-ci.yml
- local: .gitlab/ci/dast.gitlab-ci.yml
- local: .gitlab/ci/workhorse.gitlab-ci.yml
workhorse:
image: golang:1.14
stage: test
needs: []
script:
- rm .git/hooks/post-checkout
- git checkout .
- scripts/update-workhorse check
- make -C workhorse
......@@ -32,6 +32,7 @@ AllCops:
- 'builds/**/*'
- 'plugins/**/*'
- 'file_hooks/**/*'
- 'workhorse/**/*'
CacheRootDirectory: tmp
MaxFilesInCache: 18000
......
......@@ -139,4 +139,12 @@ def warn_or_fail_commits(failed_linters, default_to_fail: true)
end
end
lint_commits(git.commits)
# As part of https://gitlab.com/groups/gitlab-org/-/epics/4826 we are
# vendoring workhorse commits from the stand-alone gitlab-workhorse
# repo. There is no point in linting commits that we want to vendor as
# is.
def workhorse_changes?
git.diff.any? { |file| file.path.start_with?('workhorse/') }
end
lint_commits(git.commits) unless workhorse_changes?
#!/bin/sh
set -e
WORKHORSE_DIR=workhorse/
WORKHORSE_REF="v$(cat GITLAB_WORKHORSE_VERSION)"
if [ $# -gt 1 ] || ([ $# = 1 ] && [ x$1 != xcheck ]); then
echo "Usage: update-workhorse [check]"
exit 1
fi
clean="$(git status --porcelain)"
if [ -n "$clean" ] ; then
echo 'error: working directory is not clean:'
echo "$clean"
exit 1
fi
git fetch https://gitlab.com/gitlab-org/gitlab-workhorse.git "$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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment