Change ci-cd

This commit is contained in:
Florian Hoss 2023-06-21 17:23:40 +02:00
parent c5f3da0ac5
commit c50d4e629a
5 changed files with 57 additions and 28 deletions

View file

@ -7,38 +7,38 @@ variables:
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:
- test
- build
- analyse
include:
- local: .gitlab/_common.gitlab-ci.yml
- local: .gitlab/_rules.gitlab-ci.yml
- template: Jobs/Secret-Detection.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:
rules: !reference [.release, rules]
rules: !reference [.rules:release, rules]
stage: build
extends: .login_registry
services:
@ -58,7 +58,8 @@ build_release:
- docker push $LATEST_IMAGE
container_scanning:
rules: !reference [.release, rules]
rules: !reference [.rules:release, rules]
stage: analyse
variables:
CS_IMAGE: $LATEST_IMAGE
CS_DOCKERFILE_PATH: docker/Dockerfile

View 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/

View 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
View file

@ -18,7 +18,3 @@ parse_yaml() {
eval $(parse_yaml .gitlab-ci.yml)
echo "GOLANG_VERSION="$variables_GOLANG_VERSION >>.env
yarn install
docker compose up --build &
yarn run tailwind:dev

View file

@ -35,7 +35,7 @@ COPY scripts/entrypoint.sh .
COPY --from=logo /logo.txt .
COPY --from=nodeBuilder /web/static/ ./web/static/
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 .
# Envs