diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e1bbe93..f71673b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/.gitlab/_common.gitlab-ci.yml b/.gitlab/_common.gitlab-ci.yml new file mode 100644 index 0000000..391499f --- /dev/null +++ b/.gitlab/_common.gitlab-ci.yml @@ -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/ diff --git a/.gitlab/_rules.gitlab-ci.yml b/.gitlab/_rules.gitlab-ci.yml new file mode 100644 index 0000000..083dd7c --- /dev/null +++ b/.gitlab/_rules.gitlab-ci.yml @@ -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 diff --git a/dev.sh b/dev.sh index d1f8065..9e7e55b 100755 --- a/dev.sh +++ b/dev.sh @@ -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 diff --git a/docker/Dockerfile b/docker/Dockerfile index 572741a..624b3a7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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