Change ci-cd
This commit is contained in:
parent
c5f3da0ac5
commit
c50d4e629a
5 changed files with 57 additions and 28 deletions
|
@ -7,38 +7,38 @@ variables:
|
||||||
|
|
||||||
image: docker:$DOCKER_VERSION-git
|
image: docker:$DOCKER_VERSION-git
|
||||||
|
|
||||||
.login_registry:
|
|
||||||
before_script:
|
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
||||||
|
|
||||||
.go-cache:
|
|
||||||
variables:
|
|
||||||
GOPATH: $CI_PROJECT_DIR/.go
|
|
||||||
before_script:
|
|
||||||
- mkdir -p .go
|
|
||||||
- export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .go/pkg/mod/
|
|
||||||
|
|
||||||
.if-stable-release-tag: &if-stable-release-tag
|
|
||||||
if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
|
|
||||||
|
|
||||||
.release:
|
|
||||||
rules:
|
|
||||||
- <<: *if-stable-release-tag
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
- analyse
|
- analyse
|
||||||
|
|
||||||
include:
|
include:
|
||||||
|
- local: .gitlab/_common.gitlab-ci.yml
|
||||||
|
- local: .gitlab/_rules.gitlab-ci.yml
|
||||||
- template: Jobs/Secret-Detection.gitlab-ci.yml
|
- template: Jobs/Secret-Detection.gitlab-ci.yml
|
||||||
- template: Jobs/Container-Scanning.gitlab-ci.yml
|
- template: Jobs/Container-Scanning.gitlab-ci.yml
|
||||||
|
|
||||||
|
secret_detection:
|
||||||
|
rules: !reference [.rules:default, rules]
|
||||||
|
|
||||||
|
unit_tests:
|
||||||
|
rules: !reference [.rules:default, rules]
|
||||||
|
stage: test
|
||||||
|
image: golang:$GOLANG_VERSION-alpine
|
||||||
|
extends:
|
||||||
|
- .go-cache
|
||||||
|
script:
|
||||||
|
- go install gotest.tools/gotestsum@latest
|
||||||
|
- gotestsum --junitfile report.xml --format testname -- ./... -coverprofile=profile.cov
|
||||||
|
- go tool cover -func profile.cov
|
||||||
|
coverage: '/\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/'
|
||||||
|
artifacts:
|
||||||
|
when: always
|
||||||
|
reports:
|
||||||
|
junit: report.xml
|
||||||
|
|
||||||
build_release:
|
build_release:
|
||||||
rules: !reference [.release, rules]
|
rules: !reference [.rules:release, rules]
|
||||||
stage: build
|
stage: build
|
||||||
extends: .login_registry
|
extends: .login_registry
|
||||||
services:
|
services:
|
||||||
|
@ -58,7 +58,8 @@ build_release:
|
||||||
- docker push $LATEST_IMAGE
|
- docker push $LATEST_IMAGE
|
||||||
|
|
||||||
container_scanning:
|
container_scanning:
|
||||||
rules: !reference [.release, rules]
|
rules: !reference [.rules:release, rules]
|
||||||
stage: analyse
|
stage: analyse
|
||||||
variables:
|
variables:
|
||||||
CS_IMAGE: $LATEST_IMAGE
|
CS_IMAGE: $LATEST_IMAGE
|
||||||
|
CS_DOCKERFILE_PATH: docker/Dockerfile
|
||||||
|
|
13
.gitlab/_common.gitlab-ci.yml
Normal file
13
.gitlab/_common.gitlab-ci.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
.login_registry:
|
||||||
|
before_script:
|
||||||
|
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||||
|
|
||||||
|
.go-cache:
|
||||||
|
variables:
|
||||||
|
GOPATH: $CI_PROJECT_DIR/.go
|
||||||
|
before_script:
|
||||||
|
- mkdir -p .go
|
||||||
|
- export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .go/pkg/mod/
|
19
.gitlab/_rules.gitlab-ci.yml
Normal file
19
.gitlab/_rules.gitlab-ci.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
.if-release-candidate-tag: &if-release-candidate-tag
|
||||||
|
if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/'
|
||||||
|
|
||||||
|
.if-stable-release-tag: &if-stable-release-tag
|
||||||
|
if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
|
||||||
|
|
||||||
|
.if-default-branch: &if-default-branch
|
||||||
|
if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
|
|
||||||
|
.rules:release:
|
||||||
|
rules:
|
||||||
|
- <<: *if-release-candidate-tag
|
||||||
|
- <<: *if-stable-release-tag
|
||||||
|
|
||||||
|
.rules:default:
|
||||||
|
rules:
|
||||||
|
- <<: *if-release-candidate-tag
|
||||||
|
- <<: *if-stable-release-tag
|
||||||
|
- <<: *if-default-branch
|
4
dev.sh
4
dev.sh
|
@ -18,7 +18,3 @@ parse_yaml() {
|
||||||
eval $(parse_yaml .gitlab-ci.yml)
|
eval $(parse_yaml .gitlab-ci.yml)
|
||||||
|
|
||||||
echo "GOLANG_VERSION="$variables_GOLANG_VERSION >>.env
|
echo "GOLANG_VERSION="$variables_GOLANG_VERSION >>.env
|
||||||
|
|
||||||
yarn install
|
|
||||||
docker compose up --build &
|
|
||||||
yarn run tailwind:dev
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ COPY scripts/entrypoint.sh .
|
||||||
COPY --from=logo /logo.txt .
|
COPY --from=logo /logo.txt .
|
||||||
COPY --from=nodeBuilder /web/static/ ./web/static/
|
COPY --from=nodeBuilder /web/static/ ./web/static/
|
||||||
COPY --from=nodeBuilder /web/templates ./web/templates/
|
COPY --from=nodeBuilder /web/templates ./web/templates/
|
||||||
COPY --from=goBuilder /app/bookmarks/config.yaml ./bookmarks/config.yaml
|
COPY --from=goBuilder /app/internal/bookmarks/config.yaml .internal/bookmarks/config.yaml
|
||||||
COPY --from=goBuilder /app/godash .
|
COPY --from=goBuilder /app/godash .
|
||||||
|
|
||||||
# Envs
|
# Envs
|
||||||
|
|
Loading…
Reference in a new issue