-
Notifications
You must be signed in to change notification settings - Fork 18
/
.gitlab-ci.yml
82 lines (75 loc) · 2.47 KB
/
.gitlab-ci.yml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
include:
- project: kount/third_party/tpa-ci-shared
file:
- base/sq-scan.yml
- version.yml
- core/rules.yml
# - fod.yml
ref: 2.18.1
stages:
- version
- build and validate
- sonarqube scan
- publish
variables:
FORTIFY_RELEASE_ID: "784315"
.ruby:
image: ruby:3.0
before_script:
- apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
- ruby -v
- which ruby
- gem install bundler --no-document
- bundle install
- mkdir ~/.gem
- echo "---" > ~/.gem/credentials
- curl -u $RUBYGEMS_USERNAME:$RUBYGEMS_PASSWORD https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
- chmod 0600 ~/.gem/credentials
- echo BUILD_VERSION=${BUILD_VERSION:-"0.0.0-${CI_COMMIT_SHORT_SHA}"}
- |
if [ -n "${BUILD_VERSION}" ]
then
BUILD_VERSION=`echo $BUILD_VERSION | cut -c-17`
# BUILD_VERSION is cut to 17 characters so SDK_VERSION will not exceed 32 characters in total
echo "sed -i \"s/0.0.0/${BUILD_VERSION}/g\" ${CI_PROJECT_DIR}/lib/kount/config.rb"
sed -i "s/0.0.0/${BUILD_VERSION}/g" ${CI_PROJECT_DIR}/lib/kount/config.rb
fi
test:
stage: build and validate
extends: .ruby
script:
- bundle exec rake test
- ruby -rjson -e 'sqube = JSON.load(File.read("coverage/.resultset.json"))["RSpec"]["coverage"].transform_values {|lines| lines["lines"]}; total = { "RSpec" => { "coverage" => sqube, "timestamp" => Time.now.to_i }}; puts JSON.dump(total)' > coverage/.resultset.sq.json
rules:
- !reference [.rule-on-tag]
- !reference [.rule-on-master]
- !reference [.rule-on-mr]
artifacts:
paths:
- ${CI_PROJECT_DIR}/coverage/.resultset.sq.json
sonarqube scan:
extends: .sq-scan
stage: sonarqube scan
variables:
SRC_EXCLUSIONS: "**/build/**,**/spec/**,**/vendor/**,**/DS_Store/**,**/idea/**,**/*LICENSE,**/*.gitignore,**/*.yml,**/*.lock"
RUBY_TEST_COVERAGE_REPORT_PATHS: "${CI_PROJECT_DIR}/coverage/.resultset.sq.json"
# The purpose of Below test stage is to approve merger request (As It's mentioned in required approval - pipeline need to be pass for approve the Merge request)
lint:
stage: build and validate
extends: .ruby
rules:
- !reference [.rule-on-tag]
- !reference [.rule-on-master]
- !reference [.rule-on-mr]
script:
- rubocop
build and deploy:
stage: publish
extends: .ruby
rules:
- !reference [.rule-on-tag]
script:
- bash gem_build.sh
artifacts:
paths:
- "*.gem"