Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 77148e3

Browse files
committed
Add a vendor check
This make sure the `vendor` folder and the `dep` configuration matches. Also, let's run validation in parallel to the build. Signed-off-by: Vincent Demeester <[email protected]>
1 parent ecf93d5 commit 77148e3

File tree

6 files changed

+71
-30
lines changed

6 files changed

+71
-30
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.git
21
*.dockerapp
32
*.tar.gz
43
_build/

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ RUN curl -Ls https://download.docker.com/linux/static/$DOCKERCLI_CHANNEL/x86_64/
1818
WORKDIR /go/src/github.com/docker/app/
1919

2020
FROM build AS dev
21+
ARG DEP_VERSION=v0.4.1
22+
RUN curl -o /usr/bin/dep -L https://github.com/golang/dep/releases/download/${DEP_VERSION}/dep-linux-amd64 && \
23+
chmod +x /usr/bin/dep
2124
COPY . .
2225

2326
FROM dev AS docker-app

Jenkinsfile

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,51 @@ pipeline {
1111

1212
stages {
1313
stage('Build') {
14-
agent {
15-
label 'linux'
16-
}
17-
steps {
18-
dir('src/github.com/docker/app') {
19-
script {
20-
try {
14+
parallel {
15+
stage("Validate") {
16+
agent {
17+
label 'linux'
18+
}
19+
steps {
20+
dir('src/github.com/docker/app') {
2121
checkout scm
22-
sh 'docker image prune -f'
2322
sh 'make -f docker.Makefile lint'
24-
sh 'make -f docker.Makefile cross e2e-cross tars'
25-
dir('bin') {
26-
stash name: 'binaries'
27-
}
28-
dir('e2e') {
29-
stash name: 'e2e'
30-
}
31-
if(!(env.BRANCH_NAME ==~ "PR-\\d+")) {
32-
stash name: 'artifacts', includes: 'bin/*.tar.gz', excludes: 'bin/*-e2e-*'
33-
archiveArtifacts 'bin/*.tar.gz'
34-
}
35-
} finally {
36-
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm -f/
37-
sh clean_images
23+
sh 'make -f docker.Makefile vendor'
3824
}
3925
}
4026
}
41-
}
42-
post {
43-
always {
44-
deleteDir()
27+
stage("Binaries"){
28+
agent {
29+
label 'linux'
30+
}
31+
steps {
32+
dir('src/github.com/docker/app') {
33+
script {
34+
try {
35+
checkout scm
36+
sh 'make -f docker.Makefile cross e2e-cross tars'
37+
dir('bin') {
38+
stash name: 'binaries'
39+
}
40+
dir('e2e') {
41+
stash name: 'e2e'
42+
}
43+
if(!(env.BRANCH_NAME ==~ "PR-\\d+")) {
44+
stash name: 'artifacts', includes: 'bin/*.tar.gz', excludes: 'bin/*-e2e-*'
45+
archiveArtifacts 'bin/*.tar.gz'
46+
}
47+
} finally {
48+
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm -f/
49+
sh clean_images
50+
}
51+
}
52+
}
53+
}
54+
post {
55+
always {
56+
deleteDir()
57+
}
58+
}
4559
}
4660
}
4761
}

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,9 @@ clean:
6868
$(call rm,_build)
6969
$(call rm,docker-app-*.tar.gz)
7070

71-
.PHONY: cross e2e-cross test check lint test-unit test-e2e coverage coverage-bin coverage-test-unit coverage-test-e2e clean
71+
vendor:
72+
$(call rm,vendor)
73+
dep ensure -v
74+
75+
.PHONY: cross e2e-cross test check lint test-unit test-e2e coverage coverage-bin coverage-test-unit coverage-test-e2e clean vendor
7276
.DEFAULT: all

docker.Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ gradle-test: bin/$(BIN_NAME)-linux
8989
docker run --rm $(GRADLE_IMAGE_NAME) bash -c "./gradlew --stacktrace build && cd example && gradle renderIt"
9090

9191
lint:
92-
@echo "Linting..."
92+
$(info Linting...)
9393
docker build -t $(LINT_IMAGE_NAME) $(IMAGE_BUILD_ARGS) -f Dockerfile.lint .
9494
docker run --rm $(LINT_IMAGE_NAME) make lint
9595

96-
.PHONY: lint test-e2e test-unit test cross e2e-cross coverage gradle-test shell build_dev_image tars
96+
vendor: build_dev_image
97+
$(info Vendoring...)
98+
docker run --rm $(DEV_IMAGE_NAME) sh -c "make BUILDTIME=${BUILDTIME} vendor && hack/check-git-diff vendor"
99+
100+
.PHONY: lint test-e2e test-unit test cross e2e-cross coverage gradle-test shell build_dev_image tars vendor

hack/check-git-diff

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
DIFF_PATH=$1
6+
DIFF=$(git status --porcelain -- "$DIFF_PATH")
7+
8+
if [ "$DIFF" ]; then
9+
echo
10+
echo "These files were changed:"
11+
echo
12+
echo "$DIFF"
13+
echo
14+
exit 1
15+
else
16+
echo "$DIFF_PATH is correct"
17+
fi;

0 commit comments

Comments
 (0)