summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 205bfa7f81358b9d13f21c21ce4f2d7adfb6ac55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
stages:
  - build
  - test
  - validate
  - runway_staging
  - runway_production
variables:
  CONTAINER_IMAGE_COMMIT: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
include:
  - project: 'gitlab-com/gl-infra/platform/runway/runwayctl'
    file: 'ci-tasks/service-project/runway.yml'
    rules:
      - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    inputs:
      runway_service_id: sparkle
      image: "$CONTAINER_IMAGE_COMMIT"
      runway_version: v3.61.5
build image:
  image: docker:28
  interruptible: true
  stage: build
  services:
    - docker:28-dind
  before_script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  script:
    - docker build --tag $CONTAINER_IMAGE_COMMIT .
    - docker push $CONTAINER_IMAGE_COMMIT
lint:
  image: golang:alpine
  stage: test
  script:
    - go install github.com/google/yamlfmt/cmd/yamlfmt@latest
    - yamlfmt --lint .
unit:
  image: golang:alpine
  stage: test
  script:
    - go test ./...
integration:
  image: golang:1.24.0
  stage: test
  needs:
    - build image
  services:
    - docker:28-dind
  before_script:
    - apt-get update && apt-get install -y docker.io
    - echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token --password-stdin "$CI_REGISTRY"
  script:
    - go test -tags=integration ./test/integration/...
  variables:
    # Variables required by github.com/testcontainers/testcontainers-go
    # ref https://golang.testcontainers.org/system_requirements/ci/gitlab_ci/#example-using-dind-docker-in-docker
    DOCKER_HOST: "tcp://docker:2375"
    DOCKER_TLS_CERTDIR: ""
    IMAGE_TAG: $CONTAINER_IMAGE_COMMIT