Skip to content
Snippets Groups Projects
Commit e698fda2 authored by Tomasz Maczukin's avatar Tomasz Maczukin
Browse files

Merge branch 'remove-dco-validation' into 'main'

Remove DCO validation

See merge request gitlab-org/ci-cd/docker-machine!85
parents 8246c2c5 fb8ed650
No related branches found
No related tags found
No related merge requests found
......@@ -75,11 +75,11 @@ to clean-up build results.
We use the usual `go` tools for this, to run those commands you need at least the linter which you can
install with `go get -u golang.org/x/lint/golint`
To run basic validation (dco, fmt), and the project unit tests, call:
To run basic validation (fmt, test-short, lint, vet), and the project unit tests, call:
$ make test
If you want more indepth validation (vet, lint), and all tests with race detection, call:
If you want all tests with race detection, call:
$ make validate
......@@ -150,7 +150,6 @@ Scrub build results:
make fmt
make vet
make lint
make dco
### Managing dependencies
......
......@@ -41,7 +41,7 @@ include mk/validate.mk
.all_coverage: coverage-generate coverage-html coverage-send coverage-serve coverage-clean
.all_release: release-checksum release
.all_test: test-short test-long test-integration
.all_validate: dco fmt vet lint
.all_validate: fmt vet lint
default: build
......@@ -49,7 +49,7 @@ install:
cp $(PREFIX)/bin/$(PKG_NAME) /usr/local/bin
clean: coverage-clean build-clean
test: dco fmt test-short lint vet
validate: dco fmt lint vet test-long
test: fmt test-short lint vet
validate: fmt lint vet test-long
.PHONY: .all_build .all_coverage .all_release .all_test .all_validate test build validate clean
# Validate DCO on all history
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
# XXX vendorized script miss exec bit, hence the gymnastic
# plus the path resolution...
# TODO migrate away from the shell script and have a make equivalent instead
dco:
@echo `bash $(current_dir)/../script/validate-dco`
fmt:
@test -z "$$(gofmt -s -l . 2>&1 | grep -v vendor/ | tee /dev/stderr)"
......
#!/bin/bash
source "$(dirname "$BASH_SOURCE")/.validate"
adds=$(validate_diff --numstat | awk '{ s += $1 } END { print s }')
dels=$(validate_diff --numstat | awk '{ s += $2 } END { print s }')
notDocs="$(validate_diff --numstat | awk '$3 !~ /^docs\// { print $3 }')"
: ${adds:=0}
: ${dels:=0}
# "Username may only contain alphanumeric characters or dashes and cannot begin with a dash"
githubUsernameRegex='[a-zA-Z0-9][a-zA-Z0-9-]+'
# https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
dcoPrefix='Signed-off-by:'
dcoRegex="^(Docker-DCO-1.1-)?$dcoPrefix ([^<]+) <([^<>@]+@[^<>]+)>( \\(github: ($githubUsernameRegex)\\))?$"
check_dco() {
grep -qE "$dcoRegex"
}
if [ $adds -eq 0 -a $dels -eq 0 ]; then
echo '0 adds, 0 deletions; nothing to validate! :)'
elif [ -z "$notDocs" -a $adds -le 1 -a $dels -le 1 ]; then
echo 'Congratulations! DCO small-patch-exception material!'
else
commits=( $(validate_log --format='format:%H%n') )
badCommits=()
for commit in "${commits[@]}"; do
if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then
# no content (ie, Merge commit, etc)
continue
fi
if ! git log -1 --format='format:%B' "$commit" | check_dco; then
badCommits+=( "$commit" )
fi
done
if [ ${#badCommits[@]} -eq 0 ]; then
echo "Congratulations! All commits are properly signed with the DCO!"
else
{
echo "These commits do not have a proper '$dcoPrefix' marker:"
for commit in "${badCommits[@]}"; do
echo " - $commit"
done
echo
echo 'Please amend each commit to include a properly formatted DCO marker.'
echo
echo 'Visit the following URL for information about the Docker DCO:'
echo ' https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work'
echo
} >&2
false
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment