-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
89 lines (82 loc) · 2.75 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
83
84
85
86
87
88
89
stages:
- tests
- build
- deploy
.test:
image: rnds/ruby:2.5-test
stage: tests
variables:
COMPOSE_PROJECT_NAME: lusnoc_${CI_PIPELINE_ID}_${CI_JOB_ID}
GIT_BRANCH: ${CI_COMMIT_REF_NAME}
GIT_COMMIT: ${CI_COMMIT_SHA}
script:
- docker-compose build --force-rm --pull test-${CASE}
- docker-compose up --force-recreate -t 1 --remove-orphans -d test-${CASE}
- docker-compose exec -T test-${CASE} rspec | tee .coverage
- docker-compose exec -T test-${CASE} cat rspec.xml > rspec-${CASE}.xml
after_script:
- docker-compose down -v --remove-orphans
coverage: '/\(\d+.\d+\%\) covered/'
artifacts:
reports:
junit: rspec*.xml
name: "coverage"
paths:
- .coverage
ruby-2.6:
extends: .test
variables:
CASE: '2.6'
ruby-3.0:
extends: .test
variables:
CASE: '3.0'
build:
image: rnds/ruby:2.5-test
stage: build
variables:
BUILDVERSION: ${CI_PIPELINE_ID}
script:
- bundle install --jobs=3 --path vendor/bundle && bundle package --all
- gem build `ls | grep gemspec` && gem install `ls | grep -e '.gem$'`
cache:
paths:
- vendor/bundle
- vendor/cache
artifacts:
name: "gem"
paths:
- ./*.gem
only:
- master
pushgem:
image: rnds/ruby:2.5-test
stage: deploy
script:
- mkdir -p ~/.gem
- 'echo ":rubygems_api_key: ${RUBYGEMS_KEY}" > ~/.gem/credentials'
- chmod 600 ~/.gem/credentials
- export GEMFILE=`ls *.gem | tail -n 1`
- gem push $GEMFILE
only:
- master
badges:
image: rnds/ruby:2.5-test
stage: deploy
allow_failure: true
variables:
BRANCH_LOCK: ci/${CI_PROJECT_NAME}/${CI_COMMIT_REF_SLUG}
ENV_LOCK: ci/${CI_PROJECT_NAME}/${CI_ENVIRONMENT_SLUG}
BADGES: https://lysander.rnds.pro/api/v1/badges/lusnoc
script:
- bundle audit update
- bundle audit || true
- bundle outdated --only-explicit --no-pre --group default || true
- vulnerable=$(bundle audit | grep "Name:" | sort | uniq | wc -l) || true
- outdated=$(bundle outdated --only-explicit --no-pre --group default | grep "*" | wc -l) || true
- curl -X PUT --oauth2-bearer ${BADGE_TOKEN} "${BADGES}_vulnerable.json?badge[message]=$(bundle audit | grep "Name:" | sort | uniq | wc -l)%20gems" || true
- curl -X PUT --oauth2-bearer ${BADGE_TOKEN} "${BADGES}_outdated.json?badge[message]=$(bundle outdated --only-explicit --no-pre --group default | grep "*" | wc -l)%20gems" || true
- curl -X PUT --oauth2-bearer ${BADGE_TOKEN} "${BADGES}_quality.json?badge[message]=$(rubycritic -f lint lib | tail -n 1 | cut -d ' ' -f2)%25" || true
- curl -X PUT --oauth2-bearer ${BADGE_TOKEN} "${BADGES}_coverage.json?badge[message]=$(cat .coverage | ruby -e 'puts /\((\d+.\d+)\%\) covered/.match(STDIN.read)[1]')%25" || true
#only:
# - master