Skip to content

Commit 1ac190b

Browse files
prometherionmjuraga
authored andcommitted
TEST/MINOR: gitlab: diff for swagger generated files
1 parent 6e2bf34 commit 1ac190b

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

.gitlab-ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ variables:
77
DOCKER_BASE_IMAGE: $CI_REGISTRY_GO/haproxy-alpine
88
BATS_VERSION: v1.4.1
99

10+
diff:
11+
stage: lint
12+
image:
13+
name: $CI_REGISTRY_GO/docker:stable-go1.17
14+
entrypoint: [ "" ]
15+
services:
16+
- name: $CI_REGISTRY_GO/docker:20.10.5-dind
17+
alias: docker
18+
tags:
19+
- go
20+
script:
21+
#- apk add make curl bash jq
22+
- SWAGGER_VERSION=$(curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $2}')
23+
- wget -q "https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_VERSION}/swagger_linux_amd64" -O /usr/local/bin/swagger && chmod +x /usr/local/bin/swagger
24+
- make generate-native
25+
- test -z "$(git diff 2> /dev/null)" || exit "Specification is not generated, issue \`make swagger\` and commit the result"
26+
- test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Specification generation created untracked files, cannot proceed"
27+
1028
golangci-lint:
1129
stage: lint
1230
artifacts:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ generate:
3434
--build-arg UID=$(shell id -u) \
3535
--build-arg GID=$(shell id -g) \
3636
-t dataplaneapi-swagger-gen .
37-
docker run --rm -it -v "$(PWD)":/data dataplaneapi-swagger-gen
37+
docker run --rm -v "$(PWD)":/data dataplaneapi-swagger-gen
3838
generate/post_swagger.sh
3939

4040
.PHONY: generate-native

generate/swagger/script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ fi
1717
# check if version is there, if not, use one from require
1818
[ -z "$CN_VERSION" ] && CN_VERSION=$(go mod edit -json | jq -c -r '.Require | .[] | select(.Path | contains("github.com/haproxytech/client-native/v2")) | .Version' 2>/dev/null | awk -F"-" '{print $NF}')
1919
echo " ---> version of client native used: $CN_VERSION"
20-
2120
# extract repository
2221
REPO_PATH=$(go mod edit -json | jq -r '.Replace | .[] | select(.Old.Path | contains("github.com/haproxytech/client-native/v2")) | .New.Path' 2>/dev/null | awk -F"/" '{print $2 "/" $3}') || ""
2322
[ -z "$REPO_PATH" ] && REPO_PATH=haproxytech/client-native
@@ -41,6 +40,7 @@ if [ "$REMOTE_VERSION" = "null" ]; then
4140
else
4241
echo " ---> URL path: $URL_PATH"
4342
echo " ---> repository path: $REPO_PATH"
43+
echo " ---> client native version: $CN_VERSION"
4444
SPEC_URL=https://$URL_PATH/$REPO_PATH/$EXTRA_PATH$CN_VERSION/specification
4545

4646
echo " ---> fetching specification: $SPEC_URL/build/haproxy_spec.yaml"

0 commit comments

Comments
 (0)