201 lines
4.8 KiB
YAML
201 lines
4.8 KiB
YAML
image: gitlab.protontech.ch:4567/go/bridge-internal:latest
|
|
|
|
before_script:
|
|
- eval $(ssh-agent -s)
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
|
|
- mkdir -p .cache/bin
|
|
- export PATH=$(pwd)/.cache/bin:$PATH
|
|
- export GOPATH="$CI_PROJECT_DIR/.cache"
|
|
|
|
- make install-dev-dependencies
|
|
|
|
cache:
|
|
key: go-mod
|
|
paths:
|
|
- .cache
|
|
policy: pull
|
|
|
|
stages:
|
|
- cache
|
|
- test
|
|
- build
|
|
- mirror
|
|
|
|
# Stage: CACHE
|
|
|
|
# This will ensure latest dependency versions and updates the cache for
|
|
# all other following jobs which only pull the cache.
|
|
cache-push:
|
|
stage: cache
|
|
only:
|
|
- branches
|
|
script:
|
|
- echo ""
|
|
cache:
|
|
key: go-mod
|
|
paths:
|
|
- .cache
|
|
|
|
# Stage: TEST
|
|
|
|
lint:
|
|
stage: test
|
|
only:
|
|
- branches
|
|
script:
|
|
- env GOMAXPROCS=$(( ${CI_TAG_CPU} / 2 )) make lint
|
|
tags:
|
|
- medium
|
|
|
|
test:
|
|
stage: test
|
|
only:
|
|
- branches
|
|
script:
|
|
- apt-get -y install pass gnupg rng-tools
|
|
# First have enough of entropy (cat /proc/sys/kernel/random/entropy_avail).
|
|
- rngd -r /dev/urandom
|
|
# Generate GPG key without password for the password manager.
|
|
- gpg --batch --yes --passphrase '' --quick-generate-key 'tester@example.com'
|
|
# Use the last created GPG ID for the password manager.
|
|
- pass init `gpg --list-keys | grep "^ " | tail -1 | tr -d '[:space:]'`
|
|
# Then finally run the tests
|
|
- make test
|
|
tags:
|
|
- medium
|
|
|
|
test-integration:
|
|
stage: test
|
|
only:
|
|
- branches
|
|
script:
|
|
- VERBOSITY=debug make -C test test
|
|
tags:
|
|
- large
|
|
|
|
dependency-updates:
|
|
stage: test
|
|
script:
|
|
- make updates
|
|
|
|
# Stage: BUILD
|
|
|
|
build-qml:
|
|
tags:
|
|
- small
|
|
only:
|
|
- branches
|
|
stage: build
|
|
artifacts:
|
|
name: "bridge-qml-$CI_COMMIT_SHORT_SHA"
|
|
expire_in: 1 day
|
|
paths:
|
|
- bridge_qml.tgz
|
|
script:
|
|
- cd internal/frontend/qml
|
|
- tar -cvzf ../../../bridge_qml.tgz ./*
|
|
|
|
.build-base:
|
|
stage: build
|
|
only:
|
|
- manual
|
|
before_script:
|
|
- mkdir -p .cache/bin
|
|
- export PATH=$(pwd)/.cache/bin:$PATH
|
|
- export GOPATH="$CI_PROJECT_DIR/.cache"
|
|
script:
|
|
- make build
|
|
- git diff && git diff-index --quiet HEAD
|
|
artifacts:
|
|
# Note: The latest artifacts for refs are locked against deletion, and kept
|
|
# regardless of the expiry time. Introduced in GitLab 13.0 behind a
|
|
# disabled feature flag, and made the default behavior in GitLab 13.4.
|
|
expire_in: 1 day
|
|
tags:
|
|
- large
|
|
|
|
build-linux:
|
|
extends: .build-base
|
|
artifacts:
|
|
name: "bridge-linux-$CI_COMMIT_SHORT_SHA"
|
|
paths:
|
|
- bridge_*.tgz
|
|
|
|
build-linux-qa:
|
|
extends: .build-base
|
|
only:
|
|
- web
|
|
script:
|
|
- BUILD_TAGS="build_qa" make build
|
|
artifacts:
|
|
name: "bridge-linux-qa-$CI_COMMIT_SHORT_SHA"
|
|
paths:
|
|
- bridge_*.tgz
|
|
|
|
.build-darwin-base:
|
|
extends: .build-base
|
|
before_script:
|
|
- eval $(ssh-agent -s)
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
|
|
- export PATH=/usr/local/bin:$PATH
|
|
- export PATH=/usr/local/opt/git/bin:$PATH
|
|
- export PATH=/usr/local/opt/make/libexec/gnubin:$PATH
|
|
- export PATH=/usr/local/opt/go@1.13/bin:$PATH
|
|
- export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
|
|
- export GOPATH=~/go
|
|
- export PATH=$GOPATH/bin:$PATH
|
|
- export CGO_CPPFLAGS='-Wno-error -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-builtin-requires-header'
|
|
cache: {}
|
|
tags:
|
|
- macOS
|
|
|
|
build-darwin:
|
|
extends: .build-darwin-base
|
|
artifacts:
|
|
name: "bridge-darwin-$CI_COMMIT_SHORT_SHA"
|
|
paths:
|
|
- bridge_*.tgz
|
|
|
|
build-darwin-qa:
|
|
extends: .build-darwin-base
|
|
only:
|
|
- web
|
|
script:
|
|
- BUILD_TAGS="build_qa" make build
|
|
artifacts:
|
|
name: "bridge-darwin-qa-$CI_COMMIT_SHORT_SHA"
|
|
paths:
|
|
- bridge_*.tgz
|
|
|
|
# Stage: MIRROR
|
|
|
|
mirror-repo:
|
|
stage: mirror
|
|
only:
|
|
refs:
|
|
- master
|
|
script:
|
|
- |
|
|
cat <<EOF > ~/.ssh/config
|
|
Host github.com
|
|
Hostname ssh.github.com
|
|
User git
|
|
Port 443
|
|
ProxyCommand connect-proxy -H $http_proxy %h %p
|
|
EOF
|
|
- ssh-keyscan -t rsa ${CI_SERVER_HOST} > ~/.ssh/known_hosts
|
|
- |
|
|
cat <<EOF >> ~/.ssh/known_hosts
|
|
# ssh.github.com:443 SSH-2.0-babeld-2e9d163d
|
|
[ssh.github.com]:443 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|
|
EOF
|
|
- echo "$mirror_key" | tr -d '\r' | ssh-add - > /dev/null
|
|
- ssh-add -l
|
|
- git clone "$CI_REPOSITORY_URL" --branch master _REPO_CLONE;
|
|
- cd _REPO_CLONE
|
|
- git remote add public $mirror_url
|
|
- git push public master
|
|
# Pushing the latest tag from master history
|
|
- git push public "$(git describe --tags --abbrev=0 || echo master)"
|