diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d967b9656c5cb4156098242b9cf2002bc3e71469..e294bbcda9d9ea91879f946c300f5834db257676 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,14 +79,19 @@ include: # From: https://docs.gitlab.com/ci/caching/#cache-go-dependencies .go-cache: variables: + GOCACHE: $CI_PROJECT_DIR/.gocache-$CI_COMMIT_REF_PROTECTED GOPATH: $CI_PROJECT_DIR/.go GOLANGCI_LINT_CACHE: $CI_PROJECT_DIR/.golangci-lint before_script: - - mkdir -p .go .golangci-lint + - mkdir -p "$GOCACHE" + - go env GOCACHE cache: paths: - - .go/pkg/mod/ - - .golangci-lint/ + # The .gocache-false only caches on unprotected branches + - $CI_PROJECT_DIR/.gocache-false/ + - $CI_PROJECT_DIR/.go/pkg/mod/ + - $CI_PROJECT_DIR/.golangci-lint/ + key: "${CI_JOB_NAME}" .documentation: stage: documentation @@ -147,6 +152,7 @@ check_go_generated_code: - .go-cache - .test needs: [] + before_script: [] script: # Workaround config.yaml.lock file permissions - chmod 600 internal/config/config.yaml.lock @@ -163,6 +169,7 @@ check_go_generated_code: lint_commit: stage: test + needs: [] image: ${GITLAB_DEPENDENCY_PROXY}node:24-slim script: - apt-get update && apt-get install -y git @@ -174,14 +181,16 @@ lint_commit: when: always lint: - extends: .test + extends: + - .test + - .go-cache + needs: [] image: ${GITLAB_DEPENDENCY_PROXY}golangci/golangci-lint:v$GOLANGCI_LINT_VERSION script: # Write the code coverage report to gl-code-quality-report.json # and print linting issues to stdout in the format: path/to/file:line description # add `--issues-exit-code 0` to ignore linting issues - golangci-lint run --output.text.path=stdout --output.text.colors=false --output.text.print-issued-lines=false --output.code-climate.path=gl-code-quality-report.json - artifacts: reports: codequality: gl-code-quality-report.json