2022-01-06 16:49:09 +00:00
|
|
|
|
2021-12-11 01:14:38 +00:00
|
|
|
variables:
|
|
|
|
REPO_NAME: git.ucode.space/Phil/goshorly
|
2022-01-06 16:49:09 +00:00
|
|
|
DOCKER_BUILDKIT: 1
|
2021-12-11 01:14:38 +00:00
|
|
|
|
2022-01-06 17:00:14 +00:00
|
|
|
|
2021-12-07 21:23:41 +00:00
|
|
|
stages:
|
|
|
|
- test
|
|
|
|
- build
|
|
|
|
|
|
|
|
format:
|
|
|
|
image: golang:latest
|
|
|
|
stage: test
|
2021-12-11 01:14:38 +00:00
|
|
|
before_script:
|
|
|
|
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
|
|
|
|
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
|
|
|
|
- cd $GOPATH/src/$REPO_NAME
|
2021-12-07 21:23:41 +00:00
|
|
|
script:
|
|
|
|
- go fmt $(go list ./... | grep -v /vendor/)
|
|
|
|
- go vet $(go list ./... | grep -v /vendor/)
|
|
|
|
- go test -race $(go list ./... | grep -v /vendor/)
|
|
|
|
|
2021-12-11 01:14:38 +00:00
|
|
|
gosec:
|
|
|
|
image: golang:latest
|
|
|
|
before_script:
|
|
|
|
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME)
|
|
|
|
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME
|
|
|
|
- cd $GOPATH/src/$REPO_NAME
|
|
|
|
script:
|
|
|
|
- go install github.com/securego/gosec/v2/cmd/gosec@latest
|
|
|
|
- go get -v -d .
|
|
|
|
- gosec ./...
|
|
|
|
|
2022-01-06 17:00:14 +00:00
|
|
|
docker-build-prod-latest:
|
|
|
|
image: carlallen/docker:buildx
|
2021-12-07 17:13:02 +00:00
|
|
|
stage: build
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
before_script:
|
2022-01-06 17:05:00 +00:00
|
|
|
- docker buildx create --use
|
2021-12-07 17:13:02 +00:00
|
|
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
|
|
script:
|
|
|
|
- |
|
2022-01-06 17:00:14 +00:00
|
|
|
docker buildx build \
|
|
|
|
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
|
|
|
|
--push \
|
|
|
|
--tag $CI_REGISTRY_IMAGE:latest \
|
|
|
|
.
|
|
|
|
only:
|
|
|
|
- main
|
2021-12-11 01:14:38 +00:00
|
|
|
|
|
|
|
docker-build-MR-dry-run:
|
|
|
|
image: docker:latest
|
|
|
|
stage: build
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
script:
|
|
|
|
- |
|
|
|
|
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
|
|
|
tag=""
|
|
|
|
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
|
|
|
else
|
|
|
|
tag=":$CI_COMMIT_REF_SLUG"
|
|
|
|
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
|
|
|
fi
|
|
|
|
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
|
|
|
|
only:
|
|
|
|
- merge_requests
|