Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.75 KiB
Newer Older
Gabriel Zachmann's avatar
Gabriel Zachmann committed
image: golang:1.19
stages:
  - build
  - test
  - lint
  - release
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  - deploy
Gabriel Zachmann's avatar
Gabriel Zachmann committed

default:
  tags:
    - linux
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  cache:
    paths:
      - .cache

Gabriel Zachmann's avatar
Gabriel Zachmann committed
before_script:
  - mkdir -p .cache
  - export GOPATH=${CI_PROJECT_DIR}/.cache
Gabriel Zachmann's avatar
Gabriel Zachmann committed

test:
  stage: test
  script:
    - go test -v ./...

test_race:
  stage: test
  script:
    - go test -race -v ./...

staticcheck:
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  stage: lint
  before_script:
    - go install honnef.co/go/tools/cmd/staticcheck@latest
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  script:
    - staticcheck ./...
Gabriel Zachmann's avatar
Gabriel Zachmann committed

vet:
  stage: lint
  script:
    - go vet ./...

build_server:
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  stage: build
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  script:
    - go build github.com/oidc-mytoken/server/cmd/mytoken-server

build_setup:
  stage: build
  script:
    - go build github.com/oidc-mytoken/server/cmd/mytoken-server/mytoken-setup

build_migratedb:
  stage: build
  script:
    - go build github.com/oidc-mytoken/server/cmd/mytoken-server/mytoken-migratedb

prerelease:
  stage: release
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  image:
    name: docker:stable
  services:
    - docker:dind
  only:
Gabriel Zachmann's avatar
Gabriel Zachmann committed
    refs:
      - tags
      - prerel
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  tags:
    - linux
  variables:
cicd's avatar
cicd committed
    GIT_STRATEGY: clone
cicd's avatar
cicd committed
    GIT_DEPTH: 0
Gabriel Zachmann's avatar
Gabriel Zachmann committed
    REPO_HOST: repo.data.kit.edu
    REPO_USER: cicd
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  script:
    - if [ -z "$CI_COMMIT_TAG" ]; then docker run --rm -v $PWD:/tmp/mytoken -w /tmp/mytoken bitnami/git .gitlab-ci-scripts/set-prerel-version.sh; fi;
    - .gitlab-ci-scripts/goreleaser.sh
    - .gitlab-ci-scripts/upload.sh
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  after_script:
Gabriel Zachmann's avatar
Gabriel Zachmann committed
    - docker run --rm curlimages/curl -d "repo=github.com/oidc-mytoken/server" https://goreportcard.com/checks
Gabriel Zachmann's avatar
Gabriel Zachmann committed

deploy-dev:
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  stage: deploy
  only:
    refs:
      - prerel
Gabriel Zachmann's avatar
Gabriel Zachmann committed
  before_script:
    - mkdir -p /root/.ssh
    - cp $KNOWN_HOSTS /root/.ssh/known_hosts
    - cp $DEPLOYMENT_SSH_KEY /root/.ssh/id_ed25519 && chmod 0600 /root/.ssh/id_ed25519
  script:
    - ssh mytoken-dev.vm.fedcloud.eu