.gitlab-ci.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. ###################### Begin Defaults
  2. stages:
  3. - all
  4. variables:
  5. GIT_DEPTH: 0
  6. GIT_STRATEGY: clone
  7. default:
  8. before_script:
  9. - |
  10. # before_script
  11. echo "Starting before_script actions."
  12. echo "Finished before_script actions."
  13. after_script:
  14. - |
  15. # after_script
  16. echo "Starting after_script actions."
  17. echo "Finished after_script actions."
  18. ###################### End Defaults
  19. ###################### Begin Common Blocks
  20. .scriptCommon: &scriptCommon |
  21. # scriptCommon
  22. echo "Project Name : $CI_PROJECT_TITLE"
  23. echo "Project Git Commit : $CI_COMMIT_SHA"
  24. echo "Project Git Branch : $CI_COMMIT_BRANCH"
  25. echo "GitLab CI User Details : $GITLAB_USER_LOGIN - $GITLAB_USER_NAME ($GITLAB_USER_ID) $GITLAB_USER_EMAIL"
  26. echo "GitLab CI Job Name : $CI_JOB_NAME"
  27. echo "GitLab CI Job ID : $CI_JOB_ID"
  28. echo "GitLab CI Job Stage : $CI_JOB_STAGE"
  29. echo "GitLab CI Runner Details : $CI_RUNNER_VERSION ($CI_RUNNER_REVISION)"
  30. .scriptGoVersion: &scriptGoVersion |
  31. # scriptGoVersion
  32. echo "Go Compiler Version:"
  33. go version
  34. echo "Go Default Environment:"
  35. go env
  36. echo "Go Current Environment:"
  37. go tool dist env -p
  38. .scriptGitPre: &scriptGitPre |
  39. # scriptGitPre
  40. git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
  41. git --no-pager fetch --tags
  42. git --no-pager fetch --all --recurse-submodules=yes
  43. git --no-pager update-index -q --refresh --really-refresh
  44. git --no-pager for-each-ref --count=1
  45. git --no-pager reset --hard
  46. git --no-pager diff --full-index --exit-code
  47. ###################### End Common Blocks
  48. ###################### Begin Windows Build + Test
  49. windows job:
  50. tags:
  51. - Windows-x86_64
  52. stage: all
  53. script:
  54. - *scriptCommon
  55. - $env:Path += ";C:\Program Files\Git\cmd;C:\Go\bin"
  56. - $env:GO111MODULE="on"
  57. - $env:GOPROXY="https://proxy.golang.org,direct"
  58. - $env:CGO_ENABLED="0"
  59. - *scriptGoVersion
  60. - go clean -modcache -cache -r
  61. - go mod download
  62. - go mod verify
  63. - *scriptGitPre
  64. - go build -v -a -trimpath .\...
  65. - |
  66. # status
  67. echo "Build completed successfully - running tests; coverage and race detector enabled"
  68. echo "TODO: Port of full coverage tools to PowerShell"
  69. - $env:CGO_ENABLED="1"
  70. - go test -v -cover -covermode="atomic" -race -count="1" -cpu="2" -parallel="2" .\...
  71. ###################### End Windows Build + Test
  72. ###################### Begin Linux
  73. linux job:
  74. tags:
  75. - Linux-x86_64
  76. stage: all
  77. script:
  78. - *scriptCommon
  79. - |
  80. # upgrade system, install development tools
  81. - yum install dnf -y
  82. - yum clean all -y
  83. - dnf upgrade --refresh -y
  84. - dnf groupinstall "Development Tools" -y
  85. - dnf install epel-release centos-release-scl centos-release-scl-rh -y
  86. - dnf install ccache pv valgrind graphviz clang zsh scl-utils devtoolset-9 -y
  87. - dnf groupupdate base -y
  88. - source /opt/rh/devtoolset-9/enable
  89. - dnf clean all -y
  90. - |
  91. # gimme go 1.15.6
  92. bash --norc --noprofile --posix -o pipefail -c "set -e && mkdir -p /tools/bin && curl -fsSL -o /tools/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme && chmod a+x /tools/bin/gimme"
  93. bash --norc --noprofile --posix -o pipefail -c "set -e && mkdir -p /tools/gimme && GIMME_SILENT_ENV=1 GIMME_ENV_PREFIX=/tools/gimme/env GIMME_VERSION_PREFIX=/tools/gimme/ver GIMME_GO_VERSION=1.15.6 GIMME_CGO_ENABLED=1 /tools/bin/gimme" > /tools/genv && source /tools/genv
  94. - source /tools/genv
  95. - go env -w GO111MODULE=on && export GO111MODULE=on
  96. - export GOPROXY="https://proxy.golang.org,direct" && go env -w GOPROXY="${GOPROXY:?}"
  97. - *scriptGoVersion
  98. - go clean -modcache -cache -r -x
  99. - *scriptGitPre
  100. - CGO_ENABLED=0 go build -v -a -trimpath $(go list ./... | grep -v test | sort | uniq)
  101. - |
  102. # status
  103. echo "Build completed successfully - running race-enabled testing."
  104. - CGO_ENABLED=1 go test -v -a -cover -covermode=atomic -race -count=1 -cpu=2 -parallel=2 $(go list ./... | grep -v test | sort | uniq)
  105. ###################### End Linux Build + Test
  106. ###################### Begin macOS Build + Test
  107. macos job:
  108. tags:
  109. - macOS_X-x86_64
  110. stage: all
  111. script:
  112. - |
  113. # update tools
  114. bash --norc --noprofile --posix -c "brew update || true" || true
  115. bash --norc --noprofile --posix -c "brew upgrade || true" || true
  116. - *scriptCommon
  117. - if type brew >/dev/null 2>&1; then export HOMEBREW_PREFIX=$(brew --prefix 2>/dev/null); for dir in ${HOMEBREW_PREFIX:?}/opt/*/libexec/gnubin; do export PATH="${dir:?}:${PATH:?}"; done; fi
  118. - export PATH="/usr/local/opt/gcc/bin:${PATH:?}"
  119. - go env -w GO111MODULE=on && export GO111MODULE=on
  120. - export GOPROXY="https://proxy.golang.org,direct" && go env -w GOPROXY="${GOPROXY:?}"
  121. - export PRIVPATH=$(mktemp -d "${HOME:?}/.XXXXXXXXXXXXXXXX")
  122. - export NEW_GOPATH=$(mktemp -d "${PRIVPATH:?}/XXXXXXXXXXXXXXXX")
  123. - export NEW_GOCACHE=$(mktemp -d "${PRIVPATH:?}/XXXXXXXXXXXXXXXX")
  124. - export NEW_GOMODCACHE=$(mktemp -d "${PRIVPATH:?}/XXXXXXXXXXXXXXXX")
  125. - export GOPATH="${NEW_GOPATH:?}" && go env -w GOPATH="${NEW_GOPATH:?}"
  126. - export GOCACHE="${NEW_GOCACHE:?}" && go env -w GOCACHE="${NEW_GOCACHE:?}"
  127. - export GOMODCACHE="${NEW_GOMODCACHE:?}" && go env -w GOMODCACHE="${NEW_GOMODCACHE:?}"
  128. - *scriptGoVersion
  129. - go clean -testcache -modcache -cache -r -x
  130. - *scriptGitPre
  131. - GOMAXPROCS=8 CGO_ENABLED=0 go build -v -a -trimpath $(go list ./... | grep -v test | sort | uniq)
  132. - |
  133. # status
  134. echo "Build completed successfully - running race-enabled tests."
  135. - GOMAXPROCS=8 CGO_ENABLED=1 go test -v -a -cover -covermode=atomic -race -count=1 -cpu=2 -parallel=2 $(go list ./... | grep -v test | sort | uniq)
  136. - |
  137. # cleaning up
  138. - chmod -R u+rwx "${GOPATH:?}"/* 2>/dev/null && rm -rf -- "${GOPATH:?}"/* 2>/dev/null || true :;
  139. - chmod -R u+rwx "${GOCACHE:?}"/* 2>/dev/null && rm -rf -- "${GOCACHE:?}"/* 2>/dev/null || true :;
  140. - chmod -R u+rwx "${GOMODCACHE:?}"/* 2>/dev/null && rm -rf -- "${GOMODCACHE:?}"/* 2>/dev/null || true :;
  141. ###################### End macOS Build + Test