.gitlab-ci.yml 1.16 KB
Newer Older
1
image: privacybydesign/golang_sql:latest
Tomas's avatar
Tomas committed
2

Sietse Ringers's avatar
wip  
Sietse Ringers committed
3 4 5 6
cache:
  key: $CI_COMMIT_REF_SLUG
  paths:
    - vendor/go/pkg/mod/
Tomas's avatar
Tomas committed
7 8 9 10 11 12

stages:
  - test
  - build

variables:
Sietse Ringers's avatar
wip  
Sietse Ringers committed
13 14
  GOFLAGS: -mod=readonly
  GOPATH: ${CI_PROJECT_DIR}/vendor/go
Tomas's avatar
Tomas committed
15 16 17 18 19
  PACKAGE_NAME: github.com/privacybydesign/irmago
  PLATFORMS: linux/amd64 darwin/amd64 windows/amd64 linux/arm linux/arm64

before_script:
  - set -euxo pipefail
20 21 22 23
  - service mysql start
  - mysql -e "create database test"
  - mysql -e "grant all privileges on *.* to 'testuser'@'localhost' identified by 'testpassword'"
  - mysql -e "flush privileges"
Tomas's avatar
Tomas committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

unit_tests:
  stage: test
  script:
  - go test -tags=local_tests -p 1 ./...

binaries:
  stage: build
  artifacts:
    paths:
      - artifacts/*
  script:
    - mkdir -p artifacts
    - for PLATFORM in $PLATFORMS; do
        export GOOS=${PLATFORM%/*};
        export GOARCH=${PLATFORM#*/};
        export CGO_ENABLED=0;
41
        export GOARM=6;
Tomas's avatar
Tomas committed
42 43 44 45 46 47 48 49 50

        OUTPUT_NAME="irma-${CI_COMMIT_REF_SLUG}-${GOOS}-${GOARCH}";
        if [[ "$GOOS" == "windows" ]]; then
          OUTPUT_NAME="${OUTPUT_NAME}.exe";
        fi;

        go build -a -ldflags '-extldflags "-static"' -o "artifacts/$OUTPUT_NAME" ./irma;
      done;