52 lines
1.7 KiB
YAML
52 lines
1.7 KiB
YAML
stages:
|
|
- test
|
|
- build
|
|
|
|
variables:
|
|
GO_VERSION: "1.25"
|
|
# TODO: confirm final remote URL once go-dw-framework is pushed, and set up
|
|
# a deploy token / CI_JOB_TOKEN with read access if the repo is private.
|
|
FRAMEWORK_REPO_URL: "https://repository.promas.id/prana/go-dw-framework.git"
|
|
|
|
# go.mod currently has `replace repository.promas.id/prana/go-dw-framework => ../go-dw-framework`
|
|
# for pre-release local development. CI clones it into that exact relative
|
|
# path so the replace directive resolves. Once go-dw-framework is tagged
|
|
# (e.g. v0.1.0), remove the replace line from go.mod, drop this clone step,
|
|
# and let `go mod download` fetch the tagged version normally.
|
|
.with-framework:
|
|
image: golang:${GO_VERSION}-alpine
|
|
before_script:
|
|
- apk add --no-cache git
|
|
- git clone --depth 1 "$FRAMEWORK_REPO_URL" ../go-dw-framework
|
|
cache:
|
|
key: go-mod-cache
|
|
paths:
|
|
- .go-cache/
|
|
variables:
|
|
GOPATH: "$CI_PROJECT_DIR/.go-cache"
|
|
|
|
test:
|
|
stage: test
|
|
extends: .with-framework
|
|
script:
|
|
- go vet ./...
|
|
- go test ./tests/... -v
|
|
|
|
# NOTE: assumes the GitLab project path checks out into a folder literally
|
|
# named `omnix-sopiga` (matches CI_PROJECT_DIR's basename) so the Dockerfile's
|
|
# `COPY omnix-sopiga ./omnix-sopiga` line lines up. Adjust if your project slug differs.
|
|
build:
|
|
stage: build
|
|
image: docker:24
|
|
services:
|
|
- docker:24-dind
|
|
before_script:
|
|
- apk add --no-cache git
|
|
- git clone --depth 1 "$FRAMEWORK_REPO_URL" ../go-dw-framework
|
|
script:
|
|
- docker build -f Dockerfile -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" ..
|
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
|
|
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
|
|
rules:
|
|
- if: '$CI_COMMIT_BRANCH == "main"'
|